# -*- 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.checkout_option import CheckoutOption
from paypalserversdk.models.money import Money
from paypalserversdk.models.tax_amount import TaxAmount


class ItemDetails(object):

    """Implementation of the 'Item Details' model.

    The item details.

    Attributes:
        item_code (str): An item code that identifies a merchant's goods or
            service.
        item_name (str): The item name.
        item_description (str): The item description.
        item_options (str): The item options. Describes option choices on the
            purchase of the item in some detail.
        item_quantity (str): The number of purchased units of goods or a
            service.
        item_unit_price (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        item_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        discount_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        adjustment_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        gift_wrap_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        tax_percentage (str): The percentage, as a fixed-point, signed decimal
            number. For example, define a 19.99% interest rate as `19.99`.
        tax_amounts (List[TaxAmount]): An array of tax amounts levied by a
            government on the purchase of goods or services.
        basic_shipping_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        extra_shipping_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        handling_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        insurance_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.
        invoice_number (str): The invoice number. An alphanumeric string that
            identifies a billing for a merchant.
        checkout_options (List[CheckoutOption]): An array of checkout options.
            Each option has a name and value.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "item_code": 'item_code',
        "item_name": 'item_name',
        "item_description": 'item_description',
        "item_options": 'item_options',
        "item_quantity": 'item_quantity',
        "item_unit_price": 'item_unit_price',
        "item_amount": 'item_amount',
        "discount_amount": 'discount_amount',
        "adjustment_amount": 'adjustment_amount',
        "gift_wrap_amount": 'gift_wrap_amount',
        "tax_percentage": 'tax_percentage',
        "tax_amounts": 'tax_amounts',
        "basic_shipping_amount": 'basic_shipping_amount',
        "extra_shipping_amount": 'extra_shipping_amount',
        "handling_amount": 'handling_amount',
        "insurance_amount": 'insurance_amount',
        "total_item_amount": 'total_item_amount',
        "invoice_number": 'invoice_number',
        "checkout_options": 'checkout_options'
    }

    _optionals = [
        'item_code',
        'item_name',
        'item_description',
        'item_options',
        'item_quantity',
        'item_unit_price',
        'item_amount',
        'discount_amount',
        'adjustment_amount',
        'gift_wrap_amount',
        'tax_percentage',
        'tax_amounts',
        'basic_shipping_amount',
        'extra_shipping_amount',
        'handling_amount',
        'insurance_amount',
        'total_item_amount',
        'invoice_number',
        'checkout_options',
    ]

    def __init__(self,
                 item_code=APIHelper.SKIP,
                 item_name=APIHelper.SKIP,
                 item_description=APIHelper.SKIP,
                 item_options=APIHelper.SKIP,
                 item_quantity=APIHelper.SKIP,
                 item_unit_price=APIHelper.SKIP,
                 item_amount=APIHelper.SKIP,
                 discount_amount=APIHelper.SKIP,
                 adjustment_amount=APIHelper.SKIP,
                 gift_wrap_amount=APIHelper.SKIP,
                 tax_percentage=APIHelper.SKIP,
                 tax_amounts=APIHelper.SKIP,
                 basic_shipping_amount=APIHelper.SKIP,
                 extra_shipping_amount=APIHelper.SKIP,
                 handling_amount=APIHelper.SKIP,
                 insurance_amount=APIHelper.SKIP,
                 total_item_amount=APIHelper.SKIP,
                 invoice_number=APIHelper.SKIP,
                 checkout_options=APIHelper.SKIP):
        """Constructor for the ItemDetails class"""

        # Initialize members of the class
        if item_code is not APIHelper.SKIP:
            self.item_code = item_code 
        if item_name is not APIHelper.SKIP:
            self.item_name = item_name 
        if item_description is not APIHelper.SKIP:
            self.item_description = item_description 
        if item_options is not APIHelper.SKIP:
            self.item_options = item_options 
        if item_quantity is not APIHelper.SKIP:
            self.item_quantity = item_quantity 
        if item_unit_price is not APIHelper.SKIP:
            self.item_unit_price = item_unit_price 
        if item_amount is not APIHelper.SKIP:
            self.item_amount = item_amount 
        if discount_amount is not APIHelper.SKIP:
            self.discount_amount = discount_amount 
        if adjustment_amount is not APIHelper.SKIP:
            self.adjustment_amount = adjustment_amount 
        if gift_wrap_amount is not APIHelper.SKIP:
            self.gift_wrap_amount = gift_wrap_amount 
        if tax_percentage is not APIHelper.SKIP:
            self.tax_percentage = tax_percentage 
        if tax_amounts is not APIHelper.SKIP:
            self.tax_amounts = tax_amounts 
        if basic_shipping_amount is not APIHelper.SKIP:
            self.basic_shipping_amount = basic_shipping_amount 
        if extra_shipping_amount is not APIHelper.SKIP:
            self.extra_shipping_amount = extra_shipping_amount 
        if handling_amount is not APIHelper.SKIP:
            self.handling_amount = handling_amount 
        if insurance_amount is not APIHelper.SKIP:
            self.insurance_amount = insurance_amount 
        if total_item_amount is not APIHelper.SKIP:
            self.total_item_amount = total_item_amount 
        if invoice_number is not APIHelper.SKIP:
            self.invoice_number = invoice_number 
        if checkout_options is not APIHelper.SKIP:
            self.checkout_options = checkout_options 

    @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
        item_code = dictionary.get("item_code") if dictionary.get("item_code") else APIHelper.SKIP
        item_name = dictionary.get("item_name") if dictionary.get("item_name") else APIHelper.SKIP
        item_description = dictionary.get("item_description") if dictionary.get("item_description") else APIHelper.SKIP
        item_options = dictionary.get("item_options") if dictionary.get("item_options") else APIHelper.SKIP
        item_quantity = dictionary.get("item_quantity") if dictionary.get("item_quantity") else APIHelper.SKIP
        item_unit_price = Money.from_dictionary(dictionary.get('item_unit_price')) if 'item_unit_price' in dictionary.keys() else APIHelper.SKIP
        item_amount = Money.from_dictionary(dictionary.get('item_amount')) if 'item_amount' in dictionary.keys() else APIHelper.SKIP
        discount_amount = Money.from_dictionary(dictionary.get('discount_amount')) if 'discount_amount' in dictionary.keys() else APIHelper.SKIP
        adjustment_amount = Money.from_dictionary(dictionary.get('adjustment_amount')) if 'adjustment_amount' in dictionary.keys() else APIHelper.SKIP
        gift_wrap_amount = Money.from_dictionary(dictionary.get('gift_wrap_amount')) if 'gift_wrap_amount' in dictionary.keys() else APIHelper.SKIP
        tax_percentage = dictionary.get("tax_percentage") if dictionary.get("tax_percentage") else APIHelper.SKIP
        tax_amounts = None
        if dictionary.get('tax_amounts') is not None:
            tax_amounts = [TaxAmount.from_dictionary(x) for x in dictionary.get('tax_amounts')]
        else:
            tax_amounts = APIHelper.SKIP
        basic_shipping_amount = Money.from_dictionary(dictionary.get('basic_shipping_amount')) if 'basic_shipping_amount' in dictionary.keys() else APIHelper.SKIP
        extra_shipping_amount = Money.from_dictionary(dictionary.get('extra_shipping_amount')) if 'extra_shipping_amount' in dictionary.keys() else APIHelper.SKIP
        handling_amount = Money.from_dictionary(dictionary.get('handling_amount')) if 'handling_amount' in dictionary.keys() else APIHelper.SKIP
        insurance_amount = Money.from_dictionary(dictionary.get('insurance_amount')) if 'insurance_amount' in dictionary.keys() else APIHelper.SKIP
        total_item_amount = Money.from_dictionary(dictionary.get('total_item_amount')) if 'total_item_amount' in dictionary.keys() else APIHelper.SKIP
        invoice_number = dictionary.get("invoice_number") if dictionary.get("invoice_number") else APIHelper.SKIP
        checkout_options = None
        if dictionary.get('checkout_options') is not None:
            checkout_options = [CheckoutOption.from_dictionary(x) for x in dictionary.get('checkout_options')]
        else:
            checkout_options = APIHelper.SKIP
        # Return an object of this model
        return cls(item_code,
                   item_name,
                   item_description,
                   item_options,
                   item_quantity,
                   item_unit_price,
                   item_amount,
                   discount_amount,
                   adjustment_amount,
                   gift_wrap_amount,
                   tax_percentage,
                   tax_amounts,
                   basic_shipping_amount,
                   extra_shipping_amount,
                   handling_amount,
                   insurance_amount,
                   total_item_amount,
                   invoice_number,
                   checkout_options)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'item_code={(self.item_code if hasattr(self, "item_code") else None)!r}, '
                f'item_name={(self.item_name if hasattr(self, "item_name") else None)!r}, '
                f'item_description={(self.item_description if hasattr(self, "item_description") else None)!r}, '
                f'item_options={(self.item_options if hasattr(self, "item_options") else None)!r}, '
                f'item_quantity={(self.item_quantity if hasattr(self, "item_quantity") else None)!r}, '
                f'item_unit_price={(self.item_unit_price if hasattr(self, "item_unit_price") else None)!r}, '
                f'item_amount={(self.item_amount if hasattr(self, "item_amount") else None)!r}, '
                f'discount_amount={(self.discount_amount if hasattr(self, "discount_amount") else None)!r}, '
                f'adjustment_amount={(self.adjustment_amount if hasattr(self, "adjustment_amount") else None)!r}, '
                f'gift_wrap_amount={(self.gift_wrap_amount if hasattr(self, "gift_wrap_amount") else None)!r}, '
                f'tax_percentage={(self.tax_percentage if hasattr(self, "tax_percentage") else None)!r}, '
                f'tax_amounts={(self.tax_amounts if hasattr(self, "tax_amounts") else None)!r}, '
                f'basic_shipping_amount={(self.basic_shipping_amount if hasattr(self, "basic_shipping_amount") else None)!r}, '
                f'extra_shipping_amount={(self.extra_shipping_amount if hasattr(self, "extra_shipping_amount") else None)!r}, '
                f'handling_amount={(self.handling_amount if hasattr(self, "handling_amount") else None)!r}, '
                f'insurance_amount={(self.insurance_amount if hasattr(self, "insurance_amount") else None)!r}, '
                f'total_item_amount={(self.total_item_amount if hasattr(self, "total_item_amount") else None)!r}, '
                f'invoice_number={(self.invoice_number if hasattr(self, "invoice_number") else None)!r}, '
                f'checkout_options={(self.checkout_options if hasattr(self, "checkout_options") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'item_code={(self.item_code if hasattr(self, "item_code") else None)!s}, '
                f'item_name={(self.item_name if hasattr(self, "item_name") else None)!s}, '
                f'item_description={(self.item_description if hasattr(self, "item_description") else None)!s}, '
                f'item_options={(self.item_options if hasattr(self, "item_options") else None)!s}, '
                f'item_quantity={(self.item_quantity if hasattr(self, "item_quantity") else None)!s}, '
                f'item_unit_price={(self.item_unit_price if hasattr(self, "item_unit_price") else None)!s}, '
                f'item_amount={(self.item_amount if hasattr(self, "item_amount") else None)!s}, '
                f'discount_amount={(self.discount_amount if hasattr(self, "discount_amount") else None)!s}, '
                f'adjustment_amount={(self.adjustment_amount if hasattr(self, "adjustment_amount") else None)!s}, '
                f'gift_wrap_amount={(self.gift_wrap_amount if hasattr(self, "gift_wrap_amount") else None)!s}, '
                f'tax_percentage={(self.tax_percentage if hasattr(self, "tax_percentage") else None)!s}, '
                f'tax_amounts={(self.tax_amounts if hasattr(self, "tax_amounts") else None)!s}, '
                f'basic_shipping_amount={(self.basic_shipping_amount if hasattr(self, "basic_shipping_amount") else None)!s}, '
                f'extra_shipping_amount={(self.extra_shipping_amount if hasattr(self, "extra_shipping_amount") else None)!s}, '
                f'handling_amount={(self.handling_amount if hasattr(self, "handling_amount") else None)!s}, '
                f'insurance_amount={(self.insurance_amount if hasattr(self, "insurance_amount") else None)!s}, '
                f'total_item_amount={(self.total_item_amount if hasattr(self, "total_item_amount") else None)!s}, '
                f'invoice_number={(self.invoice_number if hasattr(self, "invoice_number") else None)!s}, '
                f'checkout_options={(self.checkout_options if hasattr(self, "checkout_options") else None)!s})')
