# -*- 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.item_details import ItemDetails


class CartInformation(object):

    """Implementation of the 'Cart Information' model.

    The cart information.

    Attributes:
        item_details (List[ItemDetails]): An array of item details.
        tax_inclusive (bool): Indicates whether the item amount or the
            shipping amount already includes tax.
        paypal_invoice_id (str): The ID of the invoice. Appears for only
            PayPal-generated invoices.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "item_details": 'item_details',
        "tax_inclusive": 'tax_inclusive',
        "paypal_invoice_id": 'paypal_invoice_id'
    }

    _optionals = [
        'item_details',
        'tax_inclusive',
        'paypal_invoice_id',
    ]

    def __init__(self,
                 item_details=APIHelper.SKIP,
                 tax_inclusive=False,
                 paypal_invoice_id=APIHelper.SKIP):
        """Constructor for the CartInformation class"""

        # Initialize members of the class
        if item_details is not APIHelper.SKIP:
            self.item_details = item_details 
        self.tax_inclusive = tax_inclusive 
        if paypal_invoice_id is not APIHelper.SKIP:
            self.paypal_invoice_id = paypal_invoice_id 

    @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_details = None
        if dictionary.get('item_details') is not None:
            item_details = [ItemDetails.from_dictionary(x) for x in dictionary.get('item_details')]
        else:
            item_details = APIHelper.SKIP
        tax_inclusive = dictionary.get("tax_inclusive") if dictionary.get("tax_inclusive") else False
        paypal_invoice_id = dictionary.get("paypal_invoice_id") if dictionary.get("paypal_invoice_id") else APIHelper.SKIP
        # Return an object of this model
        return cls(item_details,
                   tax_inclusive,
                   paypal_invoice_id)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'item_details={(self.item_details if hasattr(self, "item_details") else None)!r}, '
                f'tax_inclusive={(self.tax_inclusive if hasattr(self, "tax_inclusive") else None)!r}, '
                f'paypal_invoice_id={(self.paypal_invoice_id if hasattr(self, "paypal_invoice_id") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'item_details={(self.item_details if hasattr(self, "item_details") else None)!s}, '
                f'tax_inclusive={(self.tax_inclusive if hasattr(self, "tax_inclusive") else None)!s}, '
                f'paypal_invoice_id={(self.paypal_invoice_id if hasattr(self, "paypal_invoice_id") else None)!s})')
