"""mindbodypublicapi.

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

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


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

    Request object for using the API to Earn or Redeem reward points

    Attributes:
        client_id (str): The ID of the client that is getting rewards earned or
            redeemed.
        points (int): The amount of points the client is getting earned or redeemed,
            must be a positive number.
        source (str): If Action passed as **Earned**,    possible values are:  *
            Appointment Booking  * Class Booking  * Referral  * Sale    <br />Omit if
            Action passed as **Redeemed**.
        source_id (int): The unique identifier in the MINDBODY system for the
            **Source**. If Action is **Earned**, and an optional SourceID is
            provided, it is validated as follows:     * If Source is Appointment
            Booking, then a provided SourceID must be a valid Visit.AppointmentId for
            the indicated Client.  * If Source is **Class Booking**, then a provided
            SourceID must be a valid Visit.Id for the indicated client.  * If Source
            is **Sale**, then a provided SourceID must be a valid Sale.Id for the
            indicated client.   * If Source is **Referral**, then a provided SourceID
            must be a valid Client.Id (RelatedClientId) and have been referred by the
            indicated client (ClientRelationship.Id = -1).  If Action is
            **Redeemed**, and an optional SourceID is provided, then SourceID must be
            a valid Sale.Id for the indicated client, and refers to the sale where
            the indicated points were redeemed.
        action (str): Indicates if rewards are getting earned or redeemed.
            Possible values are:  *Earned  *Redeemed
        action_date_time (datetime): The date and time when the points were earned or
            redeemed in UTC format. This date may be in the past, however it may not
            be in the future.  Default: **current date/time**

    """

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

    _optionals = [
        "source",
        "source_id",
        "action_date_time",
    ]

    def __init__(
        self,
        client_id=None,
        points=None,
        action=None,
        source=APIHelper.SKIP,
        source_id=APIHelper.SKIP,
        action_date_time=APIHelper.SKIP):
        """Initialize a UpdateClientRewardsRequest instance."""
        # Initialize members of the class
        self.client_id = client_id
        self.points = points
        if source is not APIHelper.SKIP:
            self.source = source
        if source_id is not APIHelper.SKIP:
            self.source_id = source_id
        self.action = action
        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

    @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
        client_id =\
            dictionary.get("ClientId")\
            if dictionary.get("ClientId")\
                else None
        points =\
            dictionary.get("Points")\
            if dictionary.get("Points")\
                else None
        action =\
            dictionary.get("Action")\
            if dictionary.get("Action")\
                else None
        source =\
            dictionary.get("Source")\
            if dictionary.get("Source")\
                else APIHelper.SKIP
        source_id =\
            dictionary.get("SourceId")\
            if dictionary.get("SourceId")\
                else APIHelper.SKIP
        action_date_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ActionDateTime")).datetime\
            if dictionary.get("ActionDateTime") else APIHelper.SKIP

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

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

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