"""visaacceptancemergedspec.

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

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)
from visaacceptancemergedspec.models.transaction_advice_addendum import (
    TransactionAdviceAddendum,
)


class InvoiceDetails4(object):
    """Implementation of the 'InvoiceDetails4' model.

    Attributes:
        purchase_order_number (str): Value used by your customer to identify the
            order. This value is typically a purchase order number. Visa Acceptance
            recommends that you do not populate the field with all zeros or nines.
        purchase_order_date (str): Date the order was processed. `Format: YYYY-MM-DD`.
        purchase_contact_name (str): The name of the individual or the company
            contacted for company authorized purchases.
        taxable (bool): Flag that indicates whether an order is taxable. This value
            must be true if the sum of all _lineItems[].taxAmount_ values > 0.  If
            you do not include any `lineItems[].taxAmount` values in your request,
            Visa Acceptance does not include `invoiceDetails.taxable` in the data it
            sends to the processor.  Possible values:  - **true**  - **false**
        vat_invoice_reference_number (str): VAT invoice number associated with the
            transaction.
        commodity_code (str): International description code of the overall order’s
            goods or services or the Categorizes purchases for VAT reporting. Contact
            your acquirer for a list of codes.
        transaction_advice_addendum (List[TransactionAdviceAddendum]): The model
            property of type List[TransactionAdviceAddendum].
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "purchase_order_number": "purchaseOrderNumber",
        "purchase_order_date": "purchaseOrderDate",
        "purchase_contact_name": "purchaseContactName",
        "taxable": "taxable",
        "vat_invoice_reference_number": "vatInvoiceReferenceNumber",
        "commodity_code": "commodityCode",
        "transaction_advice_addendum": "transactionAdviceAddendum",
    }

    _optionals = [
        "purchase_order_number",
        "purchase_order_date",
        "purchase_contact_name",
        "taxable",
        "vat_invoice_reference_number",
        "commodity_code",
        "transaction_advice_addendum",
    ]

    def __init__(
        self,
        purchase_order_number=APIHelper.SKIP,
        purchase_order_date=APIHelper.SKIP,
        purchase_contact_name=APIHelper.SKIP,
        taxable=APIHelper.SKIP,
        vat_invoice_reference_number=APIHelper.SKIP,
        commodity_code=APIHelper.SKIP,
        transaction_advice_addendum=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a InvoiceDetails4 instance."""
        # Initialize members of the class
        if purchase_order_number is not APIHelper.SKIP:
            self.purchase_order_number = purchase_order_number
        if purchase_order_date is not APIHelper.SKIP:
            self.purchase_order_date = purchase_order_date
        if purchase_contact_name is not APIHelper.SKIP:
            self.purchase_contact_name = purchase_contact_name
        if taxable is not APIHelper.SKIP:
            self.taxable = taxable
        if vat_invoice_reference_number is not APIHelper.SKIP:
            self.vat_invoice_reference_number = vat_invoice_reference_number
        if commodity_code is not APIHelper.SKIP:
            self.commodity_code = commodity_code
        if transaction_advice_addendum is not APIHelper.SKIP:
            self.transaction_advice_addendum = transaction_advice_addendum

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @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
        purchase_order_number =\
            dictionary.get("purchaseOrderNumber")\
            if dictionary.get("purchaseOrderNumber")\
                else APIHelper.SKIP
        purchase_order_date =\
            dictionary.get("purchaseOrderDate")\
            if dictionary.get("purchaseOrderDate")\
                else APIHelper.SKIP
        purchase_contact_name =\
            dictionary.get("purchaseContactName")\
            if dictionary.get("purchaseContactName")\
                else APIHelper.SKIP
        taxable =\
            dictionary.get("taxable")\
            if "taxable" in dictionary.keys()\
                else APIHelper.SKIP
        vat_invoice_reference_number =\
            dictionary.get("vatInvoiceReferenceNumber")\
            if dictionary.get("vatInvoiceReferenceNumber")\
                else APIHelper.SKIP
        commodity_code =\
            dictionary.get("commodityCode")\
            if dictionary.get("commodityCode")\
                else APIHelper.SKIP
        transaction_advice_addendum = None
        if dictionary.get("transactionAdviceAddendum") is not None:
            transaction_advice_addendum = [
                TransactionAdviceAddendum.from_dictionary(x)
                    for x in dictionary.get("transactionAdviceAddendum")
            ]
        else:
            transaction_advice_addendum = APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(purchase_order_number,
                   purchase_order_date,
                   purchase_contact_name,
                   taxable,
                   vat_invoice_reference_number,
                   commodity_code,
                   transaction_advice_addendum,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _purchase_order_number=(
            self.purchase_order_number
            if hasattr(self, "purchase_order_number")
            else None
        )
        _purchase_order_date=(
            self.purchase_order_date
            if hasattr(self, "purchase_order_date")
            else None
        )
        _purchase_contact_name=(
            self.purchase_contact_name
            if hasattr(self, "purchase_contact_name")
            else None
        )
        _taxable=(
            self.taxable
            if hasattr(self, "taxable")
            else None
        )
        _vat_invoice_reference_number=(
            self.vat_invoice_reference_number
            if hasattr(self, "vat_invoice_reference_number")
            else None
        )
        _commodity_code=(
            self.commodity_code
            if hasattr(self, "commodity_code")
            else None
        )
        _transaction_advice_addendum=(
            self.transaction_advice_addendum
            if hasattr(self, "transaction_advice_addendum")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"purchase_order_number={_purchase_order_number!r}, "
            f"purchase_order_date={_purchase_order_date!r}, "
            f"purchase_contact_name={_purchase_contact_name!r}, "
            f"taxable={_taxable!r}, "
            f"vat_invoice_reference_number={_vat_invoice_reference_number!r}, "
            f"commodity_code={_commodity_code!r}, "
            f"transaction_advice_addendum={_transaction_advice_addendum!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _purchase_order_number=(
            self.purchase_order_number
            if hasattr(self, "purchase_order_number")
            else None
        )
        _purchase_order_date=(
            self.purchase_order_date
            if hasattr(self, "purchase_order_date")
            else None
        )
        _purchase_contact_name=(
            self.purchase_contact_name
            if hasattr(self, "purchase_contact_name")
            else None
        )
        _taxable=(
            self.taxable
            if hasattr(self, "taxable")
            else None
        )
        _vat_invoice_reference_number=(
            self.vat_invoice_reference_number
            if hasattr(self, "vat_invoice_reference_number")
            else None
        )
        _commodity_code=(
            self.commodity_code
            if hasattr(self, "commodity_code")
            else None
        )
        _transaction_advice_addendum=(
            self.transaction_advice_addendum
            if hasattr(self, "transaction_advice_addendum")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"purchase_order_number={_purchase_order_number!s}, "
            f"purchase_order_date={_purchase_order_date!s}, "
            f"purchase_contact_name={_purchase_contact_name!s}, "
            f"taxable={_taxable!s}, "
            f"vat_invoice_reference_number={_vat_invoice_reference_number!s}, "
            f"commodity_code={_commodity_code!s}, "
            f"transaction_advice_addendum={_transaction_advice_addendum!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
