"""mindbodypublicapi.

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

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


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

    Totals for the purchase

    Attributes:
        total (float): Total payment amount
        sub_total (float): Sub total. For VAT, sum of asking prices (include taxes,
            excludes discounts). For non vat, excludes taxes and discounts.
        discount (float): Discount
        tax (float): Tax

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "total": "Total",
        "sub_total": "SubTotal",
        "discount": "Discount",
        "tax": "Tax",
    }

    _optionals = [
        "total",
        "sub_total",
        "discount",
        "tax",
    ]

    def __init__(
        self,
        total=APIHelper.SKIP,
        sub_total=APIHelper.SKIP,
        discount=APIHelper.SKIP,
        tax=APIHelper.SKIP):
        """Initialize a PurchaseContractResponseTotals instance."""
        # Initialize members of the class
        if total is not APIHelper.SKIP:
            self.total = total
        if sub_total is not APIHelper.SKIP:
            self.sub_total = sub_total
        if discount is not APIHelper.SKIP:
            self.discount = discount
        if tax is not APIHelper.SKIP:
            self.tax = tax

    @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
        total =\
            dictionary.get("Total")\
            if dictionary.get("Total")\
                else APIHelper.SKIP
        sub_total =\
            dictionary.get("SubTotal")\
            if dictionary.get("SubTotal")\
                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

        # Return an object of this model
        return cls(total,
                   sub_total,
                   discount,
                   tax)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _total=(
            self.total
            if hasattr(self, "total")
            else None
        )
        _sub_total=(
            self.sub_total
            if hasattr(self, "sub_total")
            else None
        )
        _discount=(
            self.discount
            if hasattr(self, "discount")
            else None
        )
        _tax=(
            self.tax
            if hasattr(self, "tax")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"total={_total!r}, "
            f"sub_total={_sub_total!r}, "
            f"discount={_discount!r}, "
            f"tax={_tax!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _total=(
            self.total
            if hasattr(self, "total")
            else None
        )
        _sub_total=(
            self.sub_total
            if hasattr(self, "sub_total")
            else None
        )
        _discount=(
            self.discount
            if hasattr(self, "discount")
            else None
        )
        _tax=(
            self.tax
            if hasattr(self, "tax")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"total={_total!s}, "
            f"sub_total={_sub_total!s}, "
            f"discount={_discount!s}, "
            f"tax={_tax!s}, "
            f")"
        )
