"""mindbodypublicapi.

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

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


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

    Discount for a promo code

    Attributes:
        mtype (str): Type of discount percentage/amount
        amount (float): Amount of discount

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "mtype": "Type",
        "amount": "Amount",
    }

    _optionals = [
        "mtype",
        "amount",
    ]

    def __init__(
        self,
        mtype=APIHelper.SKIP,
        amount=APIHelper.SKIP):
        """Initialize a Discount instance."""
        # Initialize members of the class
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype
        if amount is not APIHelper.SKIP:
            self.amount = amount

    @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
        mtype =\
            dictionary.get("Type")\
            if dictionary.get("Type")\
                else APIHelper.SKIP
        amount =\
            dictionary.get("Amount")\
            if dictionary.get("Amount")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(mtype,
                   amount)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!r}, "
            f"amount={_amount!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!s}, "
            f"amount={_amount!s}, "
            f")"
        )
