"""visaacceptancemergedspec.

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

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


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

    Attributes:
        total_amount (str): Amount you requested for the payment or capture.  This
            value is returned for partial authorizations. This field is also returned
            on incremental authorizations will contain the aggregated amount from the
            original authorizations and all the incremental authorizations.
        authorized_amount (str): Amount that was authorized.  Returned by
            authorization service.  #### PIN debit Amount of the purchase.  Returned
            by PIN debit purchase.
        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.
        settlement_amount (str): This is a multicurrency field. It contains the
            transaction amount (field 4), converted to the Currency used to bill the
            cardholder’s account. This field is returned for OCT transactions.
        settlement_currency (str): This is a multicurrency-only field. It contains a
            3-digit numeric code that identifies the currency used by the issuer to
            bill the cardholder's account. This field is returned for OCT
            transactions.
        original_amount (str): Amount in your original local pricing currency.  This
            value cannot be negative. You can include a decimal point (.) in this
            field to denote the currency exponent, but you cannot include any other
            special characters.  If needed, Visa Acceptance truncates the amount to
            the correct number of decimal places.
        original_currency (str): Your local pricing currency code.  For the possible
            values, see the [ISO Standard Currency Codes.](
        processor_transaction_fee (str): Amount up to N digit after the decimals
            separator as defined in ISO 4217 for the appropriate currency code.
        exchange_rate (str): The rate of conversion of the currency given in the
            request to CNY. The conversion happens at the time when Alipay’s trade
            order is created
        foreign_currency (str): Currency code for the transaction performed in cross
            border currency.
        foreign_amount (str): The transaction amount in CNY.
        discount_amount (str): If coupons/vouchers are used in the transaction, the
            discount amount redeemed in the settlement currency will be returned.
            Otherwise, no return.
        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",
        "authorized_amount": "authorizedAmount",
        "currency": "currency",
        "settlement_amount": "settlementAmount",
        "settlement_currency": "settlementCurrency",
        "original_amount": "originalAmount",
        "original_currency": "originalCurrency",
        "processor_transaction_fee": "processorTransactionFee",
        "exchange_rate": "exchangeRate",
        "foreign_currency": "foreignCurrency",
        "foreign_amount": "foreignAmount",
        "discount_amount": "discountAmount",
    }

    _optionals = [
        "total_amount",
        "authorized_amount",
        "currency",
        "settlement_amount",
        "settlement_currency",
        "original_amount",
        "original_currency",
        "processor_transaction_fee",
        "exchange_rate",
        "foreign_currency",
        "foreign_amount",
        "discount_amount",
    ]

    def __init__(
        self,
        total_amount=APIHelper.SKIP,
        authorized_amount=APIHelper.SKIP,
        currency=APIHelper.SKIP,
        settlement_amount=APIHelper.SKIP,
        settlement_currency=APIHelper.SKIP,
        original_amount=APIHelper.SKIP,
        original_currency=APIHelper.SKIP,
        processor_transaction_fee=APIHelper.SKIP,
        exchange_rate=APIHelper.SKIP,
        foreign_currency=APIHelper.SKIP,
        foreign_amount=APIHelper.SKIP,
        discount_amount=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a AmountDetails2 instance."""
        # Initialize members of the class
        if total_amount is not APIHelper.SKIP:
            self.total_amount = total_amount
        if authorized_amount is not APIHelper.SKIP:
            self.authorized_amount = authorized_amount
        if currency is not APIHelper.SKIP:
            self.currency = currency
        if settlement_amount is not APIHelper.SKIP:
            self.settlement_amount = settlement_amount
        if settlement_currency is not APIHelper.SKIP:
            self.settlement_currency = settlement_currency
        if original_amount is not APIHelper.SKIP:
            self.original_amount = original_amount
        if original_currency is not APIHelper.SKIP:
            self.original_currency = original_currency
        if processor_transaction_fee is not APIHelper.SKIP:
            self.processor_transaction_fee = processor_transaction_fee
        if exchange_rate is not APIHelper.SKIP:
            self.exchange_rate = exchange_rate
        if foreign_currency is not APIHelper.SKIP:
            self.foreign_currency = foreign_currency
        if foreign_amount is not APIHelper.SKIP:
            self.foreign_amount = foreign_amount
        if discount_amount is not APIHelper.SKIP:
            self.discount_amount = discount_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
        authorized_amount =\
            dictionary.get("authorizedAmount")\
            if dictionary.get("authorizedAmount")\
                else APIHelper.SKIP
        currency =\
            dictionary.get("currency")\
            if dictionary.get("currency")\
                else APIHelper.SKIP
        settlement_amount =\
            dictionary.get("settlementAmount")\
            if dictionary.get("settlementAmount")\
                else APIHelper.SKIP
        settlement_currency =\
            dictionary.get("settlementCurrency")\
            if dictionary.get("settlementCurrency")\
                else APIHelper.SKIP
        original_amount =\
            dictionary.get("originalAmount")\
            if dictionary.get("originalAmount")\
                else APIHelper.SKIP
        original_currency =\
            dictionary.get("originalCurrency")\
            if dictionary.get("originalCurrency")\
                else APIHelper.SKIP
        processor_transaction_fee =\
            dictionary.get("processorTransactionFee")\
            if dictionary.get("processorTransactionFee")\
                else APIHelper.SKIP
        exchange_rate =\
            dictionary.get("exchangeRate")\
            if dictionary.get("exchangeRate")\
                else APIHelper.SKIP
        foreign_currency =\
            dictionary.get("foreignCurrency")\
            if dictionary.get("foreignCurrency")\
                else APIHelper.SKIP
        foreign_amount =\
            dictionary.get("foreignAmount")\
            if dictionary.get("foreignAmount")\
                else APIHelper.SKIP
        discount_amount =\
            dictionary.get("discountAmount")\
            if dictionary.get("discountAmount")\
                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,
                   authorized_amount,
                   currency,
                   settlement_amount,
                   settlement_currency,
                   original_amount,
                   original_currency,
                   processor_transaction_fee,
                   exchange_rate,
                   foreign_currency,
                   foreign_amount,
                   discount_amount,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _total_amount=(
            self.total_amount
            if hasattr(self, "total_amount")
            else None
        )
        _authorized_amount=(
            self.authorized_amount
            if hasattr(self, "authorized_amount")
            else None
        )
        _currency=(
            self.currency
            if hasattr(self, "currency")
            else None
        )
        _settlement_amount=(
            self.settlement_amount
            if hasattr(self, "settlement_amount")
            else None
        )
        _settlement_currency=(
            self.settlement_currency
            if hasattr(self, "settlement_currency")
            else None
        )
        _original_amount=(
            self.original_amount
            if hasattr(self, "original_amount")
            else None
        )
        _original_currency=(
            self.original_currency
            if hasattr(self, "original_currency")
            else None
        )
        _processor_transaction_fee=(
            self.processor_transaction_fee
            if hasattr(self, "processor_transaction_fee")
            else None
        )
        _exchange_rate=(
            self.exchange_rate
            if hasattr(self, "exchange_rate")
            else None
        )
        _foreign_currency=(
            self.foreign_currency
            if hasattr(self, "foreign_currency")
            else None
        )
        _foreign_amount=(
            self.foreign_amount
            if hasattr(self, "foreign_amount")
            else None
        )
        _discount_amount=(
            self.discount_amount
            if hasattr(self, "discount_amount")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"total_amount={_total_amount!r}, "
            f"authorized_amount={_authorized_amount!r}, "
            f"currency={_currency!r}, "
            f"settlement_amount={_settlement_amount!r}, "
            f"settlement_currency={_settlement_currency!r}, "
            f"original_amount={_original_amount!r}, "
            f"original_currency={_original_currency!r}, "
            f"processor_transaction_fee={_processor_transaction_fee!r}, "
            f"exchange_rate={_exchange_rate!r}, "
            f"foreign_currency={_foreign_currency!r}, "
            f"foreign_amount={_foreign_amount!r}, "
            f"discount_amount={_discount_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
        )
        _authorized_amount=(
            self.authorized_amount
            if hasattr(self, "authorized_amount")
            else None
        )
        _currency=(
            self.currency
            if hasattr(self, "currency")
            else None
        )
        _settlement_amount=(
            self.settlement_amount
            if hasattr(self, "settlement_amount")
            else None
        )
        _settlement_currency=(
            self.settlement_currency
            if hasattr(self, "settlement_currency")
            else None
        )
        _original_amount=(
            self.original_amount
            if hasattr(self, "original_amount")
            else None
        )
        _original_currency=(
            self.original_currency
            if hasattr(self, "original_currency")
            else None
        )
        _processor_transaction_fee=(
            self.processor_transaction_fee
            if hasattr(self, "processor_transaction_fee")
            else None
        )
        _exchange_rate=(
            self.exchange_rate
            if hasattr(self, "exchange_rate")
            else None
        )
        _foreign_currency=(
            self.foreign_currency
            if hasattr(self, "foreign_currency")
            else None
        )
        _foreign_amount=(
            self.foreign_amount
            if hasattr(self, "foreign_amount")
            else None
        )
        _discount_amount=(
            self.discount_amount
            if hasattr(self, "discount_amount")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"total_amount={_total_amount!s}, "
            f"authorized_amount={_authorized_amount!s}, "
            f"currency={_currency!s}, "
            f"settlement_amount={_settlement_amount!s}, "
            f"settlement_currency={_settlement_currency!s}, "
            f"original_amount={_original_amount!s}, "
            f"original_currency={_original_currency!s}, "
            f"processor_transaction_fee={_processor_transaction_fee!s}, "
            f"exchange_rate={_exchange_rate!s}, "
            f"foreign_currency={_foreign_currency!s}, "
            f"foreign_amount={_foreign_amount!s}, "
            f"discount_amount={_discount_amount!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
