"""visaacceptancemergedspec.

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

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


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

    Attributes:
        amount (str): Indicates the amount of tax based on the `type` field as
            described in the table below:
        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)
        applied (bool): Flag that indicates whether the tax amount
            (`travelInformation.autoRental.taxDetails.amount`) is included in the
            request.  Possible values: - `false`: tax amount is not included in the
            request. - `true`:  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.
        tax_type (str): Different taxes the rental agency applies to the rental
            agreement such as tourist tax, airport tax, or rental tax.
        tax_summary (str): Summary of all tax types
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "amount": "amount",
        "rate": "rate",
        "applied": "applied",
        "exemption_code": "exemptionCode",
        "tax_type": "taxType",
        "tax_summary": "taxSummary",
    }

    _optionals = [
        "amount",
        "rate",
        "applied",
        "exemption_code",
        "tax_type",
        "tax_summary",
    ]

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

        # 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
        amount =\
            dictionary.get("amount")\
            if dictionary.get("amount")\
                else APIHelper.SKIP
        rate =\
            dictionary.get("rate")\
            if dictionary.get("rate")\
                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
        tax_type =\
            dictionary.get("taxType")\
            if dictionary.get("taxType")\
                else APIHelper.SKIP
        tax_summary =\
            dictionary.get("taxSummary")\
            if dictionary.get("taxSummary")\
                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(amount,
                   rate,
                   applied,
                   exemption_code,
                   tax_type,
                   tax_summary,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _rate=(
            self.rate
            if hasattr(self, "rate")
            else None
        )
        _applied=(
            self.applied
            if hasattr(self, "applied")
            else None
        )
        _exemption_code=(
            self.exemption_code
            if hasattr(self, "exemption_code")
            else None
        )
        _tax_type=(
            self.tax_type
            if hasattr(self, "tax_type")
            else None
        )
        _tax_summary=(
            self.tax_summary
            if hasattr(self, "tax_summary")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"amount={_amount!r}, "
            f"rate={_rate!r}, "
            f"applied={_applied!r}, "
            f"exemption_code={_exemption_code!r}, "
            f"tax_type={_tax_type!r}, "
            f"tax_summary={_tax_summary!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _amount=(
            self.amount
            if hasattr(self, "amount")
            else None
        )
        _rate=(
            self.rate
            if hasattr(self, "rate")
            else None
        )
        _applied=(
            self.applied
            if hasattr(self, "applied")
            else None
        )
        _exemption_code=(
            self.exemption_code
            if hasattr(self, "exemption_code")
            else None
        )
        _tax_type=(
            self.tax_type
            if hasattr(self, "tax_type")
            else None
        )
        _tax_summary=(
            self.tax_summary
            if hasattr(self, "tax_summary")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"amount={_amount!s}, "
            f"rate={_rate!s}, "
            f"applied={_applied!s}, "
            f"exemption_code={_exemption_code!s}, "
            f"tax_type={_tax_type!s}, "
            f"tax_summary={_tax_summary!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
