"""mindbodypublicapi.

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

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


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

    Attributes:
        staff_id (int): The ID of the staff member the tip is for.
        sale_id (int): The sale’s ID associated with the tip.
        sale_date_time (datetime): The date and time when the tip was given.
        earnings (float): The amount tipped to the staff member.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "staff_id": "StaffId",
        "sale_id": "SaleId",
        "sale_date_time": "SaleDateTime",
        "earnings": "Earnings",
    }

    _optionals = [
        "staff_id",
        "sale_id",
        "sale_date_time",
        "earnings",
    ]

    def __init__(
        self,
        staff_id=APIHelper.SKIP,
        sale_id=APIHelper.SKIP,
        sale_date_time=APIHelper.SKIP,
        earnings=APIHelper.SKIP):
        """Initialize a Tip instance."""
        # Initialize members of the class
        if staff_id is not APIHelper.SKIP:
            self.staff_id = staff_id
        if sale_id is not APIHelper.SKIP:
            self.sale_id = sale_id
        if sale_date_time is not APIHelper.SKIP:
            self.sale_date_time =\
                 APIHelper.apply_datetime_converter(
                sale_date_time, APIHelper.RFC3339DateTime)\
                 if sale_date_time else None
        if earnings is not APIHelper.SKIP:
            self.earnings = earnings

    @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
        staff_id =\
            dictionary.get("StaffId")\
            if dictionary.get("StaffId")\
                else APIHelper.SKIP
        sale_id =\
            dictionary.get("SaleId")\
            if dictionary.get("SaleId")\
                else APIHelper.SKIP
        sale_date_time = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("SaleDateTime")).datetime\
            if dictionary.get("SaleDateTime") else APIHelper.SKIP
        earnings =\
            dictionary.get("Earnings")\
            if dictionary.get("Earnings")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(staff_id,
                   sale_id,
                   sale_date_time,
                   earnings)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _staff_id=(
            self.staff_id
            if hasattr(self, "staff_id")
            else None
        )
        _sale_id=(
            self.sale_id
            if hasattr(self, "sale_id")
            else None
        )
        _sale_date_time=(
            self.sale_date_time
            if hasattr(self, "sale_date_time")
            else None
        )
        _earnings=(
            self.earnings
            if hasattr(self, "earnings")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"staff_id={_staff_id!r}, "
            f"sale_id={_sale_id!r}, "
            f"sale_date_time={_sale_date_time!r}, "
            f"earnings={_earnings!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _staff_id=(
            self.staff_id
            if hasattr(self, "staff_id")
            else None
        )
        _sale_id=(
            self.sale_id
            if hasattr(self, "sale_id")
            else None
        )
        _sale_date_time=(
            self.sale_date_time
            if hasattr(self, "sale_date_time")
            else None
        )
        _earnings=(
            self.earnings
            if hasattr(self, "earnings")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"staff_id={_staff_id!s}, "
            f"sale_id={_sale_id!s}, "
            f"sale_date_time={_sale_date_time!s}, "
            f"earnings={_earnings!s}, "
            f")"
        )
