"""paypalserversdk.

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

# ruff: noqa: E501
from paypalserversdk.api_helper import APIHelper
from paypalserversdk.models.money import Money


class PricingTier(object):
    """Implementation of the 'Pricing Tier' model.

    The pricing tier details.

    Attributes:
        starting_quantity (str): The starting quantity for the tier.
        ending_quantity (str): The ending quantity for the tier. Optional for the
            last tier.
        amount (Money): The currency and amount for a financial transaction, such as
            a balance or payment due.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "starting_quantity": "starting_quantity",
        "amount": "amount",
        "ending_quantity": "ending_quantity",
    }

    _optionals = [
        "ending_quantity",
    ]

    def __init__(
        self,
        starting_quantity=None,
        amount=None,
        ending_quantity=APIHelper.SKIP):
        """Initialize a PricingTier instance."""
        # Initialize members of the class
        self.starting_quantity = starting_quantity
        if ending_quantity is not APIHelper.SKIP:
            self.ending_quantity = ending_quantity
        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
        starting_quantity =\
            dictionary.get("starting_quantity")\
            if dictionary.get("starting_quantity")\
                else None
        amount =\
            Money.from_dictionary(
                dictionary.get("amount"))\
                if dictionary.get("amount") else None
        ending_quantity =\
            dictionary.get("ending_quantity")\
            if dictionary.get("ending_quantity")\
                else APIHelper.SKIP

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

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

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