"""mindbodypublicapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper


class ClientRewardTransaction(object):
    """Implementation of the 'ClientRewardTransaction' model.

    Contains information about the transaction details.

    Attributes:
        action_date_time (datetime): The date and time when the points were earned or
            redeemed in the site local time zone.
        action (Action10Enum): Indicates if rewards were earned or redeemed.
        source (str): The source of the reward transaction.
        source_id (int): The unique identifier in the MINDBODY system for the
            **Source**.
        expiration_date_time (datetime): The date and time when earned points expire.
            This is calculated based on site and client rewards settings. This date
            will be in the site local time zone and may be **null**.
        points (int): The amount of points the client earned or redeemed.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "action_date_time": "ActionDateTime",
        "action": "Action",
        "source": "Source",
        "source_id": "SourceID",
        "expiration_date_time": "ExpirationDateTime",
        "points": "Points",
    }

    _optionals = [
        "action_date_time",
        "action",
        "source",
        "source_id",
        "expiration_date_time",
        "points",
    ]

    def __init__(
        self,
        action_date_time=APIHelper.SKIP,
        action=APIHelper.SKIP,
        source=APIHelper.SKIP,
        source_id=APIHelper.SKIP,
        expiration_date_time=APIHelper.SKIP,
        points=APIHelper.SKIP):
        """Initialize a ClientRewardTransaction instance."""
        # Initialize members of the class
        if action_date_time is not APIHelper.SKIP:
            self.action_date_time =\
                 APIHelper.apply_datetime_converter(
                action_date_time, APIHelper.RFC3339DateTime)\
                 if action_date_time else None
        if action is not APIHelper.SKIP:
            self.action = action
        if source is not APIHelper.SKIP:
            self.source = source
        if source_id is not APIHelper.SKIP:
            self.source_id = source_id
        if expiration_date_time is not APIHelper.SKIP:
            self.expiration_date_time =\
                 APIHelper.apply_datetime_converter(
                expiration_date_time, APIHelper.RFC3339DateTime)\
                 if expiration_date_time else None
        if points is not APIHelper.SKIP:
            self.points = points

    @classmethod
    def from_dictionary(cls,
                        dictionary):
        """Create an instance of this model from a dictionary

        Args:
            dictionary (dictionary): A dictionary representation of the object
            as obtained from the deserialization of the server's response. The
            keys MUST match property names in the API description.

        Returns:
            object: An instance of this structure class.

        """
        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        action_date_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ActionDateTime")).datetime\
            if dictionary.get("ActionDateTime") else APIHelper.SKIP
        action =\
            dictionary.get("Action")\
            if dictionary.get("Action")\
                else APIHelper.SKIP
        source =\
            dictionary.get("Source")\
            if dictionary.get("Source")\
                else APIHelper.SKIP
        source_id =\
            dictionary.get("SourceID")\
            if dictionary.get("SourceID")\
                else APIHelper.SKIP
        expiration_date_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ExpirationDateTime")).datetime\
            if dictionary.get("ExpirationDateTime") else APIHelper.SKIP
        points =\
            dictionary.get("Points")\
            if dictionary.get("Points")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(action_date_time,
                   action,
                   source,
                   source_id,
                   expiration_date_time,
                   points)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _action_date_time=(
            self.action_date_time
            if hasattr(self, "action_date_time")
            else None
        )
        _action=(
            self.action
            if hasattr(self, "action")
            else None
        )
        _source=(
            self.source
            if hasattr(self, "source")
            else None
        )
        _source_id=(
            self.source_id
            if hasattr(self, "source_id")
            else None
        )
        _expiration_date_time=(
            self.expiration_date_time
            if hasattr(self, "expiration_date_time")
            else None
        )
        _points=(
            self.points
            if hasattr(self, "points")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"action_date_time={_action_date_time!r}, "
            f"action={_action!r}, "
            f"source={_source!r}, "
            f"source_id={_source_id!r}, "
            f"expiration_date_time={_expiration_date_time!r}, "
            f"points={_points!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _action_date_time=(
            self.action_date_time
            if hasattr(self, "action_date_time")
            else None
        )
        _action=(
            self.action
            if hasattr(self, "action")
            else None
        )
        _source=(
            self.source
            if hasattr(self, "source")
            else None
        )
        _source_id=(
            self.source_id
            if hasattr(self, "source_id")
            else None
        )
        _expiration_date_time=(
            self.expiration_date_time
            if hasattr(self, "expiration_date_time")
            else None
        )
        _points=(
            self.points
            if hasattr(self, "points")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"action_date_time={_action_date_time!s}, "
            f"action={_action!s}, "
            f"source={_source!s}, "
            f"source_id={_source_id!s}, "
            f"expiration_date_time={_expiration_date_time!s}, "
            f"points={_points!s}, "
            f")"
        )
