"""visaacceptancemergedspec.

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

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


class AmountDetails27(object):
    """Implementation of the 'AmountDetails27' 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
        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",
    }

    _optionals = [
        "total_amount",
        "currency",
    ]

    def __init__(
        self,
        total_amount=APIHelper.SKIP,
        currency=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a AmountDetails27 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

        # 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

        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,
                   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
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"total_amount={_total_amount!r}, "
            f"currency={_currency!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
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"total_amount={_total_amount!s}, "
            f"currency={_currency!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
