# -*- coding: utf-8 -*-

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
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):
        """Constructor for the PricingTier class"""

        # 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):
        """Creates 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 (f'{self.__class__.__name__}('
                f'starting_quantity={self.starting_quantity!r}, '
                f'ending_quantity={(self.ending_quantity if hasattr(self, "ending_quantity") else None)!r}, '
                f'amount={self.amount!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'starting_quantity={self.starting_quantity!s}, '
                f'ending_quantity={(self.ending_quantity if hasattr(self, "ending_quantity") else None)!s}, '
                f'amount={self.amount!s})')
