"""mindbodypublicapi.

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

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper
from mindbodypublicapi.models.sale import Sale


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

    A record of a specific client purchase

    Attributes:
        sale (Sale): Contains the Sale details.
        description (str): The item name and description.
        account_payment (bool): If `true`, the item was a payment credited to an
            account.
        price (float): The price paid for the item.
        amount_paid (float): The amount paid for the item.
        discount (float): The discount amount that was applied to the item.
        tax (float): The amount of tax that was applied to the item.
        returned (bool): The return status of the item. If `true`, this item was
            returned.
        quantity (int): The quantity of the item purchased.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "sale": "Sale",
        "description": "Description",
        "account_payment": "AccountPayment",
        "price": "Price",
        "amount_paid": "AmountPaid",
        "discount": "Discount",
        "tax": "Tax",
        "returned": "Returned",
        "quantity": "Quantity",
    }

    _optionals = [
        "sale",
        "description",
        "account_payment",
        "price",
        "amount_paid",
        "discount",
        "tax",
        "returned",
        "quantity",
    ]

    def __init__(
        self,
        sale=APIHelper.SKIP,
        description=APIHelper.SKIP,
        account_payment=APIHelper.SKIP,
        price=APIHelper.SKIP,
        amount_paid=APIHelper.SKIP,
        discount=APIHelper.SKIP,
        tax=APIHelper.SKIP,
        returned=APIHelper.SKIP,
        quantity=APIHelper.SKIP):
        """Initialize a ClientPurchaseRecord instance."""
        # Initialize members of the class
        if sale is not APIHelper.SKIP:
            self.sale = sale
        if description is not APIHelper.SKIP:
            self.description = description
        if account_payment is not APIHelper.SKIP:
            self.account_payment = account_payment
        if price is not APIHelper.SKIP:
            self.price = price
        if amount_paid is not APIHelper.SKIP:
            self.amount_paid = amount_paid
        if discount is not APIHelper.SKIP:
            self.discount = discount
        if tax is not APIHelper.SKIP:
            self.tax = tax
        if returned is not APIHelper.SKIP:
            self.returned = returned
        if quantity is not APIHelper.SKIP:
            self.quantity = quantity

    @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
        sale =\
            Sale.from_dictionary(
                dictionary.get("Sale"))\
                if "Sale" in dictionary.keys()\
                else APIHelper.SKIP
        description =\
            dictionary.get("Description")\
            if dictionary.get("Description")\
                else APIHelper.SKIP
        account_payment =\
            dictionary.get("AccountPayment")\
            if "AccountPayment" in dictionary.keys()\
                else APIHelper.SKIP
        price =\
            dictionary.get("Price")\
            if dictionary.get("Price")\
                else APIHelper.SKIP
        amount_paid =\
            dictionary.get("AmountPaid")\
            if dictionary.get("AmountPaid")\
                else APIHelper.SKIP
        discount =\
            dictionary.get("Discount")\
            if dictionary.get("Discount")\
                else APIHelper.SKIP
        tax =\
            dictionary.get("Tax")\
            if dictionary.get("Tax")\
                else APIHelper.SKIP
        returned =\
            dictionary.get("Returned")\
            if "Returned" in dictionary.keys()\
                else APIHelper.SKIP
        quantity =\
            dictionary.get("Quantity")\
            if dictionary.get("Quantity")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(sale,
                   description,
                   account_payment,
                   price,
                   amount_paid,
                   discount,
                   tax,
                   returned,
                   quantity)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _sale=(
            self.sale
            if hasattr(self, "sale")
            else None
        )
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _account_payment=(
            self.account_payment
            if hasattr(self, "account_payment")
            else None
        )
        _price=(
            self.price
            if hasattr(self, "price")
            else None
        )
        _amount_paid=(
            self.amount_paid
            if hasattr(self, "amount_paid")
            else None
        )
        _discount=(
            self.discount
            if hasattr(self, "discount")
            else None
        )
        _tax=(
            self.tax
            if hasattr(self, "tax")
            else None
        )
        _returned=(
            self.returned
            if hasattr(self, "returned")
            else None
        )
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"sale={_sale!r}, "
            f"description={_description!r}, "
            f"account_payment={_account_payment!r}, "
            f"price={_price!r}, "
            f"amount_paid={_amount_paid!r}, "
            f"discount={_discount!r}, "
            f"tax={_tax!r}, "
            f"returned={_returned!r}, "
            f"quantity={_quantity!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _sale=(
            self.sale
            if hasattr(self, "sale")
            else None
        )
        _description=(
            self.description
            if hasattr(self, "description")
            else None
        )
        _account_payment=(
            self.account_payment
            if hasattr(self, "account_payment")
            else None
        )
        _price=(
            self.price
            if hasattr(self, "price")
            else None
        )
        _amount_paid=(
            self.amount_paid
            if hasattr(self, "amount_paid")
            else None
        )
        _discount=(
            self.discount
            if hasattr(self, "discount")
            else None
        )
        _tax=(
            self.tax
            if hasattr(self, "tax")
            else None
        )
        _returned=(
            self.returned
            if hasattr(self, "returned")
            else None
        )
        _quantity=(
            self.quantity
            if hasattr(self, "quantity")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"sale={_sale!s}, "
            f"description={_description!s}, "
            f"account_payment={_account_payment!s}, "
            f"price={_price!s}, "
            f"amount_paid={_amount_paid!s}, "
            f"discount={_discount!s}, "
            f"tax={_tax!s}, "
            f"returned={_returned!s}, "
            f"quantity={_quantity!s}, "
            f")"
        )
