"""visaacceptancemergedspec.

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

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


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

    Attributes:
        mtype (str): Indicates the type of tax data for the _taxDetails_ object.
            Possible values:  - `alternate` - `local` - `national` - `vat` - `other`
            - `green`
        amount (str): Indicates the amount of tax based on the `type` field as
            described in the table below:  | type      | type description | |
            ------------- |:-------------:| | `alternate` | Total amount of alternate
            tax for the order. | | `local`     | Sales tax for the order. | |
            `national`  | National tax for the order. | | `vat`       | Total amount
            of value added tax (VAT) included in the order. | | `other`     | Other
            tax. | | `green`     | Green tax amount for Korean Processing. |
        rate (str): Rate of VAT or other tax for the order.  Example 0.040 (=4%)
            Valid range: 0.01 to 0.99 (1% to 99%, with only whole percentage values
            accepted; values with additional decimal places will be truncated)
        code (str): Type of tax being applied to the item.  #### FDC Nashville Global
            - `alternate_tax_type_applied` - `alternate_tax_type_identifier`  ####
            Worldpay VAP - `alternate_tax_type_identifier`  #### RBS WorldPay Atlanta
            - `tax_type_applied`  #### TSYS Acquiring Solutions - `tax_type_applied`
            - `local_tax_indicator`  #### Chase Paymentech Solutions -
            `tax_type_applied`  #### Elavon Americas - `local_tax_indicator`  ####
            FDC Compass - `tax_type_applied`  #### OmniPay Direct -
            `local_tax_indicator`
        tax_id (str): Your tax ID number to use for the alternate tax amount.
            Required if you set alternate tax amount to any value, including zero.
            You may send this field without sending alternate tax amount.
        applied (bool): Flag that indicates whether the alternate tax amount
            (`orderInformation.amountDetails.taxDetails[].amount`) is included in the
            request.  Possible values: - `false`: alternate tax amount is not
            included in the request. - `true`: alternate tax amount is included in
            the request.
        exemption_code (str): Status code for exemption from sales and use tax. This
            field is a pass-through, which means that Visa Acceptance does not verify
            the value or modify it in any way before sending it to the processor.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "mtype": "type",
        "amount": "amount",
        "rate": "rate",
        "code": "code",
        "tax_id": "taxId",
        "applied": "applied",
        "exemption_code": "exemptionCode",
    }

    _optionals = [
        "mtype",
        "amount",
        "rate",
        "code",
        "tax_id",
        "applied",
        "exemption_code",
    ]

    def __init__(
        self,
        mtype=APIHelper.SKIP,
        amount=APIHelper.SKIP,
        rate=APIHelper.SKIP,
        code=APIHelper.SKIP,
        tax_id=APIHelper.SKIP,
        applied=APIHelper.SKIP,
        exemption_code=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a TaxDetails1 instance."""
        # Initialize members of the class
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype
        if amount is not APIHelper.SKIP:
            self.amount = amount
        if rate is not APIHelper.SKIP:
            self.rate = rate
        if code is not APIHelper.SKIP:
            self.code = code
        if tax_id is not APIHelper.SKIP:
            self.tax_id = tax_id
        if applied is not APIHelper.SKIP:
            self.applied = applied
        if exemption_code is not APIHelper.SKIP:
            self.exemption_code = exemption_code

        # 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
        mtype =\
            dictionary.get("type")\
            if dictionary.get("type")\
                else APIHelper.SKIP
        amount =\
            dictionary.get("amount")\
            if dictionary.get("amount")\
                else APIHelper.SKIP
        rate =\
            dictionary.get("rate")\
            if dictionary.get("rate")\
                else APIHelper.SKIP
        code =\
            dictionary.get("code")\
            if dictionary.get("code")\
                else APIHelper.SKIP
        tax_id =\
            dictionary.get("taxId")\
            if dictionary.get("taxId")\
                else APIHelper.SKIP
        applied =\
            dictionary.get("applied")\
            if "applied" in dictionary.keys()\
                else APIHelper.SKIP
        exemption_code =\
            dictionary.get("exemptionCode")\
            if dictionary.get("exemptionCode")\
                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(mtype,
                   amount,
                   rate,
                   code,
                   tax_id,
                   applied,
                   exemption_code,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _rate=(
            self.rate
            if hasattr(self, "rate")
            else None
        )
        _code=(
            self.code
            if hasattr(self, "code")
            else None
        )
        _tax_id=(
            self.tax_id
            if hasattr(self, "tax_id")
            else None
        )
        _applied=(
            self.applied
            if hasattr(self, "applied")
            else None
        )
        _exemption_code=(
            self.exemption_code
            if hasattr(self, "exemption_code")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!r}, "
            f"amount={_amount!r}, "
            f"rate={_rate!r}, "
            f"code={_code!r}, "
            f"tax_id={_tax_id!r}, "
            f"applied={_applied!r}, "
            f"exemption_code={_exemption_code!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _rate=(
            self.rate
            if hasattr(self, "rate")
            else None
        )
        _code=(
            self.code
            if hasattr(self, "code")
            else None
        )
        _tax_id=(
            self.tax_id
            if hasattr(self, "tax_id")
            else None
        )
        _applied=(
            self.applied
            if hasattr(self, "applied")
            else None
        )
        _exemption_code=(
            self.exemption_code
            if hasattr(self, "exemption_code")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!s}, "
            f"amount={_amount!s}, "
            f"rate={_rate!s}, "
            f"code={_code!s}, "
            f"tax_id={_tax_id!s}, "
            f"applied={_applied!s}, "
            f"exemption_code={_exemption_code!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
