"""paypalserversdk.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
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):
        """Initialize a CartInformation instance."""
        # 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):
        """Create 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 a unambiguous string representation."""
        _item_details=(
            self.item_details
            if hasattr(self, "item_details")
            else None
        )
        _tax_inclusive=(
            self.tax_inclusive
            if hasattr(self, "tax_inclusive")
            else None
        )
        _paypal_invoice_id=(
            self.paypal_invoice_id
            if hasattr(self, "paypal_invoice_id")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"item_details={_item_details!r}, "
            f"tax_inclusive={_tax_inclusive!r}, "
            f"paypal_invoice_id={_paypal_invoice_id!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _item_details=(
            self.item_details
            if hasattr(self, "item_details")
            else None
        )
        _tax_inclusive=(
            self.tax_inclusive
            if hasattr(self, "tax_inclusive")
            else None
        )
        _paypal_invoice_id=(
            self.paypal_invoice_id
            if hasattr(self, "paypal_invoice_id")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"item_details={_item_details!s}, "
            f"tax_inclusive={_tax_inclusive!s}, "
            f"paypal_invoice_id={_paypal_invoice_id!s}, "
            f")"
        )
