# -*- 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 SubscriptionAmountWithBreakdown(object):

    """Implementation of the 'Subscription Amount with Breakdown' model.

    The breakdown details for the amount. Includes the gross, tax, fee, and
    shipping amounts.

    Attributes:
        gross_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        total_item_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        fee_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        shipping_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        tax_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        net_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 = {
        "gross_amount": 'gross_amount',
        "total_item_amount": 'total_item_amount',
        "fee_amount": 'fee_amount',
        "shipping_amount": 'shipping_amount',
        "tax_amount": 'tax_amount',
        "net_amount": 'net_amount'
    }

    _optionals = [
        'total_item_amount',
        'fee_amount',
        'shipping_amount',
        'tax_amount',
        'net_amount',
    ]

    def __init__(self,
                 gross_amount=None,
                 total_item_amount=APIHelper.SKIP,
                 fee_amount=APIHelper.SKIP,
                 shipping_amount=APIHelper.SKIP,
                 tax_amount=APIHelper.SKIP,
                 net_amount=APIHelper.SKIP):
        """Constructor for the SubscriptionAmountWithBreakdown class"""

        # Initialize members of the class
        self.gross_amount = gross_amount 
        if total_item_amount is not APIHelper.SKIP:
            self.total_item_amount = total_item_amount 
        if fee_amount is not APIHelper.SKIP:
            self.fee_amount = fee_amount 
        if shipping_amount is not APIHelper.SKIP:
            self.shipping_amount = shipping_amount 
        if tax_amount is not APIHelper.SKIP:
            self.tax_amount = tax_amount 
        if net_amount is not APIHelper.SKIP:
            self.net_amount = net_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
        gross_amount = Money.from_dictionary(dictionary.get('gross_amount')) if dictionary.get('gross_amount') else None
        total_item_amount = Money.from_dictionary(dictionary.get('total_item_amount')) if 'total_item_amount' in dictionary.keys() else APIHelper.SKIP
        fee_amount = Money.from_dictionary(dictionary.get('fee_amount')) if 'fee_amount' in dictionary.keys() else APIHelper.SKIP
        shipping_amount = Money.from_dictionary(dictionary.get('shipping_amount')) if 'shipping_amount' in dictionary.keys() else APIHelper.SKIP
        tax_amount = Money.from_dictionary(dictionary.get('tax_amount')) if 'tax_amount' in dictionary.keys() else APIHelper.SKIP
        net_amount = Money.from_dictionary(dictionary.get('net_amount')) if 'net_amount' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(gross_amount,
                   total_item_amount,
                   fee_amount,
                   shipping_amount,
                   tax_amount,
                   net_amount)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'gross_amount={self.gross_amount!r}, '
                f'total_item_amount={(self.total_item_amount if hasattr(self, "total_item_amount") else None)!r}, '
                f'fee_amount={(self.fee_amount if hasattr(self, "fee_amount") else None)!r}, '
                f'shipping_amount={(self.shipping_amount if hasattr(self, "shipping_amount") else None)!r}, '
                f'tax_amount={(self.tax_amount if hasattr(self, "tax_amount") else None)!r}, '
                f'net_amount={(self.net_amount if hasattr(self, "net_amount") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'gross_amount={self.gross_amount!s}, '
                f'total_item_amount={(self.total_item_amount if hasattr(self, "total_item_amount") else None)!s}, '
                f'fee_amount={(self.fee_amount if hasattr(self, "fee_amount") else None)!s}, '
                f'shipping_amount={(self.shipping_amount if hasattr(self, "shipping_amount") else None)!s}, '
                f'tax_amount={(self.tax_amount if hasattr(self, "tax_amount") else None)!s}, '
                f'net_amount={(self.net_amount if hasattr(self, "net_amount") else None)!s})')
