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

    """Implementation of the 'One Time Charge' model.

    The one-time charge info at the time of checkout.

    Attributes:
        setup_fee (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.
        taxes (Money): The currency and amount for a financial transaction,
            such as a balance or payment due.
        product_price (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        subtotal (Money): The currency and amount for a financial transaction,
            such as a balance or payment due.
        total_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 = {
        "total_amount": 'total_amount',
        "setup_fee": 'setup_fee',
        "shipping_amount": 'shipping_amount',
        "taxes": 'taxes',
        "product_price": 'product_price',
        "subtotal": 'subtotal'
    }

    _optionals = [
        'setup_fee',
        'shipping_amount',
        'taxes',
        'product_price',
        'subtotal',
    ]

    def __init__(self,
                 total_amount=None,
                 setup_fee=APIHelper.SKIP,
                 shipping_amount=APIHelper.SKIP,
                 taxes=APIHelper.SKIP,
                 product_price=APIHelper.SKIP,
                 subtotal=APIHelper.SKIP):
        """Constructor for the OneTimeCharge class"""

        # Initialize members of the class
        if setup_fee is not APIHelper.SKIP:
            self.setup_fee = setup_fee 
        if shipping_amount is not APIHelper.SKIP:
            self.shipping_amount = shipping_amount 
        if taxes is not APIHelper.SKIP:
            self.taxes = taxes 
        if product_price is not APIHelper.SKIP:
            self.product_price = product_price 
        if subtotal is not APIHelper.SKIP:
            self.subtotal = subtotal 
        self.total_amount = total_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
        total_amount = Money.from_dictionary(dictionary.get('total_amount')) if dictionary.get('total_amount') else None
        setup_fee = Money.from_dictionary(dictionary.get('setup_fee')) if 'setup_fee' in dictionary.keys() else APIHelper.SKIP
        shipping_amount = Money.from_dictionary(dictionary.get('shipping_amount')) if 'shipping_amount' in dictionary.keys() else APIHelper.SKIP
        taxes = Money.from_dictionary(dictionary.get('taxes')) if 'taxes' in dictionary.keys() else APIHelper.SKIP
        product_price = Money.from_dictionary(dictionary.get('product_price')) if 'product_price' in dictionary.keys() else APIHelper.SKIP
        subtotal = Money.from_dictionary(dictionary.get('subtotal')) if 'subtotal' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(total_amount,
                   setup_fee,
                   shipping_amount,
                   taxes,
                   product_price,
                   subtotal)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'setup_fee={(self.setup_fee if hasattr(self, "setup_fee") else None)!r}, '
                f'shipping_amount={(self.shipping_amount if hasattr(self, "shipping_amount") else None)!r}, '
                f'taxes={(self.taxes if hasattr(self, "taxes") else None)!r}, '
                f'product_price={(self.product_price if hasattr(self, "product_price") else None)!r}, '
                f'subtotal={(self.subtotal if hasattr(self, "subtotal") else None)!r}, '
                f'total_amount={self.total_amount!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'setup_fee={(self.setup_fee if hasattr(self, "setup_fee") else None)!s}, '
                f'shipping_amount={(self.shipping_amount if hasattr(self, "shipping_amount") else None)!s}, '
                f'taxes={(self.taxes if hasattr(self, "taxes") else None)!s}, '
                f'product_price={(self.product_price if hasattr(self, "product_price") else None)!s}, '
                f'subtotal={(self.subtotal if hasattr(self, "subtotal") else None)!s}, '
                f'total_amount={self.total_amount!s})')
