"""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.amex_additional_amount import (
    AmexAdditionalAmount,
)
from visaacceptancemergedspec.models.tax_details_1 import (
    TaxDetails1,
)


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

    Attributes:
        total_amount (str): Grand total for the order. This value cannot be negative.
            You can include a decimal point (.), but no other special characters.
            Visa Acceptance truncates the amount to the correct number of decimal
            places.  **Note** For CTV, FDCCompass, Paymentech processors, the maximum
            length for this field is 12.  **Important** Some processors have specific
            requirements and limitations, such as maximum amounts and maximum field
            lengths.  If your processor supports zero amount authorizations, you can
            set this field to 0 for the authorization to check if the card is lost or
            stolen.   #### Card Present Required to include either this field or
            `orderInformation.lineItems[].unitPrice` for the order.  #### Invoicing /
            Pay By Link Required for creating a new invoice or payment link.  ####
            PIN Debit Amount you requested for the PIN debit purchase. This value is
            returned for partial authorizations. The issuing bank can approve a
            partial amount if the balance on the debit card is less than the
            requested transaction amount.  Required field for PIN Debit purchase and
            PIN Debit credit requests. Optional field for PIN Debit reversal
            requests.  #### GPX This field is optional for reversing an authorization
            or credit; however, for all other processors, these fields are required.
            #### DCC with a Third-Party Provider Set this field to the converted
            amount that was returned by the DCC provider. You must include either
            this field or the 1st line item in the order and the specific line-order
            amount in your request.   #### DCC for First Data Not used.
        currency (str): Currency used for the order. Use the three-character [ISO
            Standard Currency Codes.](  #### Used by **Authorization** Required
            field.  **Authorization Reversal** For an authorization reversal
            (`reversalInformation`) or a capture (`processingOptions.capture` is set
            to `true`), you must use the same currency that you used in your payment
            authorization request.  #### PIN Debit Currency for the amount you
            requested for the PIN debit purchase. This value is returned for partial
            authorizations. The issuing bank can approve a partial amount if the
            balance on the debit card is less than the requested transaction amount.
            For the possible values, see the [ISO Standard Currency Codes]( Returned
            by PIN debit purchase.  For PIN debit reversal requests, you must use the
            same currency that was used for the PIN debit purchase or PIN debit
            credit that you are reversing. For the possible values, see the [ISO
            Standard Currency Codes](  Required field for PIN Debit purchase and PIN
            Debit credit requests. Optional field for PIN Debit reversal requests.
            #### GPX This field is optional for reversing an authorization or credit.
            #### DCC for First Data Your local currency.  #### Tax Calculation
            Required for international tax and value added tax only. Optional for
            U.S. and Canadian taxes. Your local currency.
        discount_amount (str): Total discount amount applied to the order.
        duty_amount (str): Total charges for any import or export duties included in
            the order.
        gratuity_amount (str): Gratuity or tip amount for restaurants. Allowed only
            when industryDatatype=restaurant. When your customer uses a debit card or
            prepaid card, and you receive a partial authorization, the payment
            networks recommend that you do not submit a capture amount that is higher
            than the authorized amount. When the capture amount exceeds the partial
            amount that was approved, the issuer has chargeback rights for the excess
            amount.  Used by **Capture** Optional field.  #### Visa Acceptance
            through VisaNet Restaurant data is supported only on Visa Acceptance
            through VisaNet when card is present.
        tax_amount (str): Total tax amount for all the items in the order.
        national_tax_included (str): Flag that indicates whether a national tax is
            included in the order total.  Possible values:   - **0**: national tax
            not included  - **1**: national tax included
        tax_applied_after_discount (str): Flag that indicates how the merchant
            manages discounts.  Possible values:   - **0**: no invoice level discount
            included  - **1**: tax calculated on the postdiscount invoice total  -
            **2**: tax calculated on the prediscount invoice total
        tax_applied_level (str): Flag that indicates how you calculate tax.  Possible
            values:   - **0**: net prices with tax calculated at line item level  -
            **1**: net prices with tax calculated at invoice level  - **2**: gross
            prices with tax provided at line item level  - **3**: gross prices with
            tax provided at invoice level  - **4**: no tax applies on the invoice for
            the transaction
        tax_type_code (str): For tax amounts that can be categorized as one tax type.
            This field contains the tax type code that corresponds to the entry in
            the _lineItems.taxAmount_ field.  Possible values:   - **056**: sales tax
            (U.S only)  - **TX~**: all taxes (Canada only)   Note ~ = space.
        freight_amount (str): Total freight or shipping and handling charges for the
            order. When you include this field in your request, you must also include
            the **totalAmount** field.
        foreign_amount (str): Set this field to the converted amount that was
            returned by the DCC provider.
        foreign_currency (str): Set this field to the converted amount that was
            returned by the DCC provider.
        exchange_rate (str): Exchange rate returned by the DCC service. Includes a
            decimal point and a maximum of 4 decimal places.
        exchange_rate_time_stamp (str): Time stamp for the exchange rate. This value
            is returned by the DCC service.  Format: `YYYYMMDD~HH:MM`  where ~
            denotes a space.
        amex_additional_amounts (List[AmexAdditionalAmount]): The model property of
            type List[AmexAdditionalAmount].
        tax_details (List[TaxDetails1]): The model property of type List[TaxDetails1].
        service_fee_amount (str): Service fee. Required for service fee transactions.
        original_currency (str): Your local pricing currency code.  For the possible
            values, see the [ISO Standard Currency Codes.](
        cashback_amount (str): Cashback amount in the acquirer’s currency. If a
            cashback amount is included in the request, it must be included in the
            `orderInformation.amountDetails.totalAmount` value.  This field is
            supported only on Visa Acceptance through VisaNet.  #### Used by
            **Authorization** Optional. **Authorization Reversal** Optional.  ####
            PIN debit Optional field for PIN debit purchase, PIN debit credit or PIN
            debit reversal.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "total_amount": "totalAmount",
        "currency": "currency",
        "discount_amount": "discountAmount",
        "duty_amount": "dutyAmount",
        "gratuity_amount": "gratuityAmount",
        "tax_amount": "taxAmount",
        "national_tax_included": "nationalTaxIncluded",
        "tax_applied_after_discount": "taxAppliedAfterDiscount",
        "tax_applied_level": "taxAppliedLevel",
        "tax_type_code": "taxTypeCode",
        "freight_amount": "freightAmount",
        "foreign_amount": "foreignAmount",
        "foreign_currency": "foreignCurrency",
        "exchange_rate": "exchangeRate",
        "exchange_rate_time_stamp": "exchangeRateTimeStamp",
        "amex_additional_amounts": "amexAdditionalAmounts",
        "tax_details": "taxDetails",
        "service_fee_amount": "serviceFeeAmount",
        "original_currency": "originalCurrency",
        "cashback_amount": "cashbackAmount",
    }

    _optionals = [
        "total_amount",
        "currency",
        "discount_amount",
        "duty_amount",
        "gratuity_amount",
        "tax_amount",
        "national_tax_included",
        "tax_applied_after_discount",
        "tax_applied_level",
        "tax_type_code",
        "freight_amount",
        "foreign_amount",
        "foreign_currency",
        "exchange_rate",
        "exchange_rate_time_stamp",
        "amex_additional_amounts",
        "tax_details",
        "service_fee_amount",
        "original_currency",
        "cashback_amount",
    ]

    def __init__(
        self,
        total_amount=APIHelper.SKIP,
        currency=APIHelper.SKIP,
        discount_amount=APIHelper.SKIP,
        duty_amount=APIHelper.SKIP,
        gratuity_amount=APIHelper.SKIP,
        tax_amount=APIHelper.SKIP,
        national_tax_included=APIHelper.SKIP,
        tax_applied_after_discount=APIHelper.SKIP,
        tax_applied_level=APIHelper.SKIP,
        tax_type_code=APIHelper.SKIP,
        freight_amount=APIHelper.SKIP,
        foreign_amount=APIHelper.SKIP,
        foreign_currency=APIHelper.SKIP,
        exchange_rate=APIHelper.SKIP,
        exchange_rate_time_stamp=APIHelper.SKIP,
        amex_additional_amounts=APIHelper.SKIP,
        tax_details=APIHelper.SKIP,
        service_fee_amount=APIHelper.SKIP,
        original_currency=APIHelper.SKIP,
        cashback_amount=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a AmountDetails9 instance."""
        # Initialize members of the class
        if total_amount is not APIHelper.SKIP:
            self.total_amount = total_amount
        if currency is not APIHelper.SKIP:
            self.currency = currency
        if discount_amount is not APIHelper.SKIP:
            self.discount_amount = discount_amount
        if duty_amount is not APIHelper.SKIP:
            self.duty_amount = duty_amount
        if gratuity_amount is not APIHelper.SKIP:
            self.gratuity_amount = gratuity_amount
        if tax_amount is not APIHelper.SKIP:
            self.tax_amount = tax_amount
        if national_tax_included is not APIHelper.SKIP:
            self.national_tax_included = national_tax_included
        if tax_applied_after_discount is not APIHelper.SKIP:
            self.tax_applied_after_discount = tax_applied_after_discount
        if tax_applied_level is not APIHelper.SKIP:
            self.tax_applied_level = tax_applied_level
        if tax_type_code is not APIHelper.SKIP:
            self.tax_type_code = tax_type_code
        if freight_amount is not APIHelper.SKIP:
            self.freight_amount = freight_amount
        if foreign_amount is not APIHelper.SKIP:
            self.foreign_amount = foreign_amount
        if foreign_currency is not APIHelper.SKIP:
            self.foreign_currency = foreign_currency
        if exchange_rate is not APIHelper.SKIP:
            self.exchange_rate = exchange_rate
        if exchange_rate_time_stamp is not APIHelper.SKIP:
            self.exchange_rate_time_stamp = exchange_rate_time_stamp
        if amex_additional_amounts is not APIHelper.SKIP:
            self.amex_additional_amounts = amex_additional_amounts
        if tax_details is not APIHelper.SKIP:
            self.tax_details = tax_details
        if service_fee_amount is not APIHelper.SKIP:
            self.service_fee_amount = service_fee_amount
        if original_currency is not APIHelper.SKIP:
            self.original_currency = original_currency
        if cashback_amount is not APIHelper.SKIP:
            self.cashback_amount = cashback_amount

        # 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
        total_amount =\
            dictionary.get("totalAmount")\
            if dictionary.get("totalAmount")\
                else APIHelper.SKIP
        currency =\
            dictionary.get("currency")\
            if dictionary.get("currency")\
                else APIHelper.SKIP
        discount_amount =\
            dictionary.get("discountAmount")\
            if dictionary.get("discountAmount")\
                else APIHelper.SKIP
        duty_amount =\
            dictionary.get("dutyAmount")\
            if dictionary.get("dutyAmount")\
                else APIHelper.SKIP
        gratuity_amount =\
            dictionary.get("gratuityAmount")\
            if dictionary.get("gratuityAmount")\
                else APIHelper.SKIP
        tax_amount =\
            dictionary.get("taxAmount")\
            if dictionary.get("taxAmount")\
                else APIHelper.SKIP
        national_tax_included =\
            dictionary.get("nationalTaxIncluded")\
            if dictionary.get("nationalTaxIncluded")\
                else APIHelper.SKIP
        tax_applied_after_discount =\
            dictionary.get("taxAppliedAfterDiscount")\
            if dictionary.get("taxAppliedAfterDiscount")\
                else APIHelper.SKIP
        tax_applied_level =\
            dictionary.get("taxAppliedLevel")\
            if dictionary.get("taxAppliedLevel")\
                else APIHelper.SKIP
        tax_type_code =\
            dictionary.get("taxTypeCode")\
            if dictionary.get("taxTypeCode")\
                else APIHelper.SKIP
        freight_amount =\
            dictionary.get("freightAmount")\
            if dictionary.get("freightAmount")\
                else APIHelper.SKIP
        foreign_amount =\
            dictionary.get("foreignAmount")\
            if dictionary.get("foreignAmount")\
                else APIHelper.SKIP
        foreign_currency =\
            dictionary.get("foreignCurrency")\
            if dictionary.get("foreignCurrency")\
                else APIHelper.SKIP
        exchange_rate =\
            dictionary.get("exchangeRate")\
            if dictionary.get("exchangeRate")\
                else APIHelper.SKIP
        exchange_rate_time_stamp =\
            dictionary.get("exchangeRateTimeStamp")\
            if dictionary.get("exchangeRateTimeStamp")\
                else APIHelper.SKIP
        amex_additional_amounts = None
        if dictionary.get("amexAdditionalAmounts") is not None:
            amex_additional_amounts = [
                AmexAdditionalAmount.from_dictionary(x)
                    for x in dictionary.get("amexAdditionalAmounts")
            ]
        else:
            amex_additional_amounts = APIHelper.SKIP
        tax_details = None
        if dictionary.get("taxDetails") is not None:
            tax_details = [
                TaxDetails1.from_dictionary(x)
                    for x in dictionary.get("taxDetails")
            ]
        else:
            tax_details = APIHelper.SKIP
        service_fee_amount =\
            dictionary.get("serviceFeeAmount")\
            if dictionary.get("serviceFeeAmount")\
                else APIHelper.SKIP
        original_currency =\
            dictionary.get("originalCurrency")\
            if dictionary.get("originalCurrency")\
                else APIHelper.SKIP
        cashback_amount =\
            dictionary.get("cashbackAmount")\
            if dictionary.get("cashbackAmount")\
                else 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(total_amount,
                   currency,
                   discount_amount,
                   duty_amount,
                   gratuity_amount,
                   tax_amount,
                   national_tax_included,
                   tax_applied_after_discount,
                   tax_applied_level,
                   tax_type_code,
                   freight_amount,
                   foreign_amount,
                   foreign_currency,
                   exchange_rate,
                   exchange_rate_time_stamp,
                   amex_additional_amounts,
                   tax_details,
                   service_fee_amount,
                   original_currency,
                   cashback_amount,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _total_amount=(
            self.total_amount
            if hasattr(self, "total_amount")
            else None
        )
        _currency=(
            self.currency
            if hasattr(self, "currency")
            else None
        )
        _discount_amount=(
            self.discount_amount
            if hasattr(self, "discount_amount")
            else None
        )
        _duty_amount=(
            self.duty_amount
            if hasattr(self, "duty_amount")
            else None
        )
        _gratuity_amount=(
            self.gratuity_amount
            if hasattr(self, "gratuity_amount")
            else None
        )
        _tax_amount=(
            self.tax_amount
            if hasattr(self, "tax_amount")
            else None
        )
        _national_tax_included=(
            self.national_tax_included
            if hasattr(self, "national_tax_included")
            else None
        )
        _tax_applied_after_discount=(
            self.tax_applied_after_discount
            if hasattr(self, "tax_applied_after_discount")
            else None
        )
        _tax_applied_level=(
            self.tax_applied_level
            if hasattr(self, "tax_applied_level")
            else None
        )
        _tax_type_code=(
            self.tax_type_code
            if hasattr(self, "tax_type_code")
            else None
        )
        _freight_amount=(
            self.freight_amount
            if hasattr(self, "freight_amount")
            else None
        )
        _foreign_amount=(
            self.foreign_amount
            if hasattr(self, "foreign_amount")
            else None
        )
        _foreign_currency=(
            self.foreign_currency
            if hasattr(self, "foreign_currency")
            else None
        )
        _exchange_rate=(
            self.exchange_rate
            if hasattr(self, "exchange_rate")
            else None
        )
        _exchange_rate_time_stamp=(
            self.exchange_rate_time_stamp
            if hasattr(self, "exchange_rate_time_stamp")
            else None
        )
        _amex_additional_amounts=(
            self.amex_additional_amounts
            if hasattr(self, "amex_additional_amounts")
            else None
        )
        _tax_details=(
            self.tax_details
            if hasattr(self, "tax_details")
            else None
        )
        _service_fee_amount=(
            self.service_fee_amount
            if hasattr(self, "service_fee_amount")
            else None
        )
        _original_currency=(
            self.original_currency
            if hasattr(self, "original_currency")
            else None
        )
        _cashback_amount=(
            self.cashback_amount
            if hasattr(self, "cashback_amount")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"total_amount={_total_amount!r}, "
            f"currency={_currency!r}, "
            f"discount_amount={_discount_amount!r}, "
            f"duty_amount={_duty_amount!r}, "
            f"gratuity_amount={_gratuity_amount!r}, "
            f"tax_amount={_tax_amount!r}, "
            f"national_tax_included={_national_tax_included!r}, "
            f"tax_applied_after_discount={_tax_applied_after_discount!r}, "
            f"tax_applied_level={_tax_applied_level!r}, "
            f"tax_type_code={_tax_type_code!r}, "
            f"freight_amount={_freight_amount!r}, "
            f"foreign_amount={_foreign_amount!r}, "
            f"foreign_currency={_foreign_currency!r}, "
            f"exchange_rate={_exchange_rate!r}, "
            f"exchange_rate_time_stamp={_exchange_rate_time_stamp!r}, "
            f"amex_additional_amounts={_amex_additional_amounts!r}, "
            f"tax_details={_tax_details!r}, "
            f"service_fee_amount={_service_fee_amount!r}, "
            f"original_currency={_original_currency!r}, "
            f"cashback_amount={_cashback_amount!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _total_amount=(
            self.total_amount
            if hasattr(self, "total_amount")
            else None
        )
        _currency=(
            self.currency
            if hasattr(self, "currency")
            else None
        )
        _discount_amount=(
            self.discount_amount
            if hasattr(self, "discount_amount")
            else None
        )
        _duty_amount=(
            self.duty_amount
            if hasattr(self, "duty_amount")
            else None
        )
        _gratuity_amount=(
            self.gratuity_amount
            if hasattr(self, "gratuity_amount")
            else None
        )
        _tax_amount=(
            self.tax_amount
            if hasattr(self, "tax_amount")
            else None
        )
        _national_tax_included=(
            self.national_tax_included
            if hasattr(self, "national_tax_included")
            else None
        )
        _tax_applied_after_discount=(
            self.tax_applied_after_discount
            if hasattr(self, "tax_applied_after_discount")
            else None
        )
        _tax_applied_level=(
            self.tax_applied_level
            if hasattr(self, "tax_applied_level")
            else None
        )
        _tax_type_code=(
            self.tax_type_code
            if hasattr(self, "tax_type_code")
            else None
        )
        _freight_amount=(
            self.freight_amount
            if hasattr(self, "freight_amount")
            else None
        )
        _foreign_amount=(
            self.foreign_amount
            if hasattr(self, "foreign_amount")
            else None
        )
        _foreign_currency=(
            self.foreign_currency
            if hasattr(self, "foreign_currency")
            else None
        )
        _exchange_rate=(
            self.exchange_rate
            if hasattr(self, "exchange_rate")
            else None
        )
        _exchange_rate_time_stamp=(
            self.exchange_rate_time_stamp
            if hasattr(self, "exchange_rate_time_stamp")
            else None
        )
        _amex_additional_amounts=(
            self.amex_additional_amounts
            if hasattr(self, "amex_additional_amounts")
            else None
        )
        _tax_details=(
            self.tax_details
            if hasattr(self, "tax_details")
            else None
        )
        _service_fee_amount=(
            self.service_fee_amount
            if hasattr(self, "service_fee_amount")
            else None
        )
        _original_currency=(
            self.original_currency
            if hasattr(self, "original_currency")
            else None
        )
        _cashback_amount=(
            self.cashback_amount
            if hasattr(self, "cashback_amount")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"total_amount={_total_amount!s}, "
            f"currency={_currency!s}, "
            f"discount_amount={_discount_amount!s}, "
            f"duty_amount={_duty_amount!s}, "
            f"gratuity_amount={_gratuity_amount!s}, "
            f"tax_amount={_tax_amount!s}, "
            f"national_tax_included={_national_tax_included!s}, "
            f"tax_applied_after_discount={_tax_applied_after_discount!s}, "
            f"tax_applied_level={_tax_applied_level!s}, "
            f"tax_type_code={_tax_type_code!s}, "
            f"freight_amount={_freight_amount!s}, "
            f"foreign_amount={_foreign_amount!s}, "
            f"foreign_currency={_foreign_currency!s}, "
            f"exchange_rate={_exchange_rate!s}, "
            f"exchange_rate_time_stamp={_exchange_rate_time_stamp!s}, "
            f"amex_additional_amounts={_amex_additional_amounts!s}, "
            f"tax_details={_tax_details!s}, "
            f"service_fee_amount={_service_fee_amount!s}, "
            f"original_currency={_original_currency!s}, "
            f"cashback_amount={_cashback_amount!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
