"""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.payment_instrument_1 import (
    PaymentInstrument1,
)
from visaacceptancemergedspec.models.shipping_address_1 import (
    ShippingAddress1,
)
from visaacceptancemergedspec.models.token_provisioning_information import (
    TokenProvisioningInformation,
)


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

    Attributes:
        jti (str): TMS Transient Token, 64 hexadecimal id value representing captured
            payment credentials (including Sensitive Authentication Data, e.g. CVV).
        transient_token_jwt (str): Flex API Transient Token encoded as JWT (JSON Web
            Token), e.g. Flex microform or Unified Payment checkout result.
        payment_instrument (PaymentInstrument1): The model property of type
            PaymentInstrument1.
        shipping_address (ShippingAddress1): The model property of type
            ShippingAddress1.
        network_token_option (str): Indicates whether a payment network token
            associated with a TMS token should be used for authorization. This field
            can contain one of following values:  - `ignore`: Use a tokenized card
            number for an authorization, even if the TMS token has an associated
            payment network token. - `prefer`: (Default) Use an associated payment
            network token for an authorization if the TMS token has one; otherwise,
            use the tokenized card number.
        token_provisioning_information (TokenProvisioningInformation): The model
            property of type TokenProvisioningInformation.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "jti": "jti",
        "transient_token_jwt": "transientTokenJwt",
        "payment_instrument": "paymentInstrument",
        "shipping_address": "shippingAddress",
        "network_token_option": "networkTokenOption",
        "token_provisioning_information": "tokenProvisioningInformation",
    }

    _optionals = [
        "jti",
        "transient_token_jwt",
        "payment_instrument",
        "shipping_address",
        "network_token_option",
        "token_provisioning_information",
    ]

    def __init__(
        self,
        jti=APIHelper.SKIP,
        transient_token_jwt=APIHelper.SKIP,
        payment_instrument=APIHelper.SKIP,
        shipping_address=APIHelper.SKIP,
        network_token_option=APIHelper.SKIP,
        token_provisioning_information=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a TokenInformation instance."""
        # Initialize members of the class
        if jti is not APIHelper.SKIP:
            self.jti = jti
        if transient_token_jwt is not APIHelper.SKIP:
            self.transient_token_jwt = transient_token_jwt
        if payment_instrument is not APIHelper.SKIP:
            self.payment_instrument = payment_instrument
        if shipping_address is not APIHelper.SKIP:
            self.shipping_address = shipping_address
        if network_token_option is not APIHelper.SKIP:
            self.network_token_option = network_token_option
        if token_provisioning_information is not APIHelper.SKIP:
            self.token_provisioning_information = token_provisioning_information

        # 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
        jti =\
            dictionary.get("jti")\
            if dictionary.get("jti")\
                else APIHelper.SKIP
        transient_token_jwt =\
            dictionary.get("transientTokenJwt")\
            if dictionary.get("transientTokenJwt")\
                else APIHelper.SKIP
        payment_instrument =\
            PaymentInstrument1.from_dictionary(
                dictionary.get("paymentInstrument"))\
                if "paymentInstrument" in dictionary.keys()\
                else APIHelper.SKIP
        shipping_address =\
            ShippingAddress1.from_dictionary(
                dictionary.get("shippingAddress"))\
                if "shippingAddress" in dictionary.keys()\
                else APIHelper.SKIP
        network_token_option =\
            dictionary.get("networkTokenOption")\
            if dictionary.get("networkTokenOption")\
                else APIHelper.SKIP
        token_provisioning_information =\
            TokenProvisioningInformation.from_dictionary(
                dictionary.get("tokenProvisioningInformation"))\
                if "tokenProvisioningInformation" in dictionary.keys()\
                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(jti,
                   transient_token_jwt,
                   payment_instrument,
                   shipping_address,
                   network_token_option,
                   token_provisioning_information,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _jti=(
            self.jti
            if hasattr(self, "jti")
            else None
        )
        _transient_token_jwt=(
            self.transient_token_jwt
            if hasattr(self, "transient_token_jwt")
            else None
        )
        _payment_instrument=(
            self.payment_instrument
            if hasattr(self, "payment_instrument")
            else None
        )
        _shipping_address=(
            self.shipping_address
            if hasattr(self, "shipping_address")
            else None
        )
        _network_token_option=(
            self.network_token_option
            if hasattr(self, "network_token_option")
            else None
        )
        _token_provisioning_information=(
            self.token_provisioning_information
            if hasattr(self, "token_provisioning_information")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"jti={_jti!r}, "
            f"transient_token_jwt={_transient_token_jwt!r}, "
            f"payment_instrument={_payment_instrument!r}, "
            f"shipping_address={_shipping_address!r}, "
            f"network_token_option={_network_token_option!r}, "
            f"token_provisioning_information={_token_provisioning_information!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _jti=(
            self.jti
            if hasattr(self, "jti")
            else None
        )
        _transient_token_jwt=(
            self.transient_token_jwt
            if hasattr(self, "transient_token_jwt")
            else None
        )
        _payment_instrument=(
            self.payment_instrument
            if hasattr(self, "payment_instrument")
            else None
        )
        _shipping_address=(
            self.shipping_address
            if hasattr(self, "shipping_address")
            else None
        )
        _network_token_option=(
            self.network_token_option
            if hasattr(self, "network_token_option")
            else None
        )
        _token_provisioning_information=(
            self.token_provisioning_information
            if hasattr(self, "token_provisioning_information")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"jti={_jti!s}, "
            f"transient_token_jwt={_transient_token_jwt!s}, "
            f"payment_instrument={_payment_instrument!s}, "
            f"shipping_address={_shipping_address!s}, "
            f"network_token_option={_network_token_option!s}, "
            f"token_provisioning_information={_token_provisioning_information!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
