"""visaacceptancemergedspec.

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

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


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

    Attributes:
        authentication_transaction_context_id (str): Payer authentication transaction
            identifier passed to link the validation and authorization calls.
        cavv (str): Unique identifier generated by the card-issuing bank for Visa,
            American Express, JCB, Diners Club, and Discover transactions after the
            customer is authenticated. The value is in base64. When you request the
            card authorization service, Visa Acceptance automatically converts the
            value, not the field name, to the format required by your payment
            processor.
        transaction_token (str): Web based token used to authenticate consumer with
            Rupay authentication provider.
        xid (str): Transaction identifier generated by Visa Acceptance for successful
            enrollment or validation checks. Use this value, which is in base64, to
            match an outgoing PAReq with an incoming PARes. Visa Acceptance forwards
            the XID with the card authorization service to these payment processors
            in these cases: - Barclays - Streamline (when the
            **ecommerceIndicator**`=spa`)
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "authentication_transaction_context_id": "authenticationTransactionContextId",
        "cavv": "cavv",
        "transaction_token": "transactionToken",
        "xid": "xid",
    }

    _optionals = [
        "authentication_transaction_context_id",
        "cavv",
        "transaction_token",
        "xid",
    ]

    def __init__(
        self,
        authentication_transaction_context_id=APIHelper.SKIP,
        cavv=APIHelper.SKIP,
        transaction_token=APIHelper.SKIP,
        xid=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a ConsumerAuthenticationInformation2 instance."""
        # Initialize members of the class
        if authentication_transaction_context_id is not APIHelper.SKIP:
            self.authentication_transaction_context_id =\
                 authentication_transaction_context_id
        if cavv is not APIHelper.SKIP:
            self.cavv = cavv
        if transaction_token is not APIHelper.SKIP:
            self.transaction_token = transaction_token
        if xid is not APIHelper.SKIP:
            self.xid = xid

        # 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
        authentication_transaction_context_id =\
            dictionary.get("authenticationTransactionContextId")\
            if dictionary.get("authenticationTransactionContextId")\
                else APIHelper.SKIP
        cavv =\
            dictionary.get("cavv")\
            if dictionary.get("cavv")\
                else APIHelper.SKIP
        transaction_token =\
            dictionary.get("transactionToken")\
            if dictionary.get("transactionToken")\
                else APIHelper.SKIP
        xid =\
            dictionary.get("xid")\
            if dictionary.get("xid")\
                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(authentication_transaction_context_id,
                   cavv,
                   transaction_token,
                   xid,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _authentication_transaction_context_id=(
            self.authentication_transaction_context_id
            if hasattr(self, "authentication_transaction_context_id")
            else None
        )
        _cavv=(
            self.cavv
            if hasattr(self, "cavv")
            else None
        )
        _transaction_token=(
            self.transaction_token
            if hasattr(self, "transaction_token")
            else None
        )
        _xid=(
            self.xid
            if hasattr(self, "xid")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"authentication_transaction_context_id={_authentication_transaction_context_id!r}, "
            f"cavv={_cavv!r}, "
            f"transaction_token={_transaction_token!r}, "
            f"xid={_xid!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _authentication_transaction_context_id=(
            self.authentication_transaction_context_id
            if hasattr(self, "authentication_transaction_context_id")
            else None
        )
        _cavv=(
            self.cavv
            if hasattr(self, "cavv")
            else None
        )
        _transaction_token=(
            self.transaction_token
            if hasattr(self, "transaction_token")
            else None
        )
        _xid=(
            self.xid
            if hasattr(self, "xid")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"authentication_transaction_context_id={_authentication_transaction_context_id!s}, "
            f"cavv={_cavv!s}, "
            f"transaction_token={_transaction_token!s}, "
            f"xid={_xid!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
