"""paypalserversdk.

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

# ruff: noqa: E501
from paypalserversdk.api_helper import APIHelper
from paypalserversdk.models.google_pay_card import (
    GooglePayCard,
)


class GooglePayDecryptedTokenData(object):
    """Implementation of the 'Google Pay Decrypted Token Data' model.

    Details shared by Google for the merchant to be shared with PayPal. This is
    required to process the transaction using the Google Pay payment method.

    Attributes:
        message_id (str): A unique ID that identifies the message in case it needs to
            be revoked or located at a later time.
        message_expiration (str): Date and time at which the message expires as UTC
            milliseconds since epoch. Integrators should reject any message that's
            expired.
        payment_method (GooglePayPaymentMethod): The type of the payment credential.
            Currently, only CARD is supported.
        card (GooglePayCard): The payment card used to fund a Google Pay payment. Can
            be a credit or debit card.
        authentication_method (GooglePayAuthenticationMethod): Authentication Method
            which is used for the card transaction.
        cryptogram (str): Base-64 cryptographic identifier used by card schemes to
            validate the token verification result. This is a conditionally required
            field if authentication_method is CRYPTOGRAM_3DS.
        eci_indicator (str): Electronic Commerce Indicator may not always be present.
            It is only returned for tokens on the Visa card network. This value is
            passed through in the payment authorization request.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "payment_method": "payment_method",
        "card": "card",
        "authentication_method": "authentication_method",
        "message_id": "message_id",
        "message_expiration": "message_expiration",
        "cryptogram": "cryptogram",
        "eci_indicator": "eci_indicator",
    }

    _optionals = [
        "message_id",
        "message_expiration",
        "cryptogram",
        "eci_indicator",
    ]

    def __init__(
        self,
        payment_method=None,
        card=None,
        authentication_method=None,
        message_id=APIHelper.SKIP,
        message_expiration=APIHelper.SKIP,
        cryptogram=APIHelper.SKIP,
        eci_indicator=APIHelper.SKIP):
        """Initialize a GooglePayDecryptedTokenData instance."""
        # Initialize members of the class
        if message_id is not APIHelper.SKIP:
            self.message_id = message_id
        if message_expiration is not APIHelper.SKIP:
            self.message_expiration = message_expiration
        self.payment_method = payment_method
        self.card = card
        self.authentication_method = authentication_method
        if cryptogram is not APIHelper.SKIP:
            self.cryptogram = cryptogram
        if eci_indicator is not APIHelper.SKIP:
            self.eci_indicator = eci_indicator

    @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
        payment_method =\
            dictionary.get("payment_method")\
            if dictionary.get("payment_method")\
                else None
        card =\
            GooglePayCard.from_dictionary(
                dictionary.get("card"))\
                if dictionary.get("card") else None
        authentication_method =\
            dictionary.get("authentication_method")\
            if dictionary.get("authentication_method")\
                else None
        message_id =\
            dictionary.get("message_id")\
            if dictionary.get("message_id")\
                else APIHelper.SKIP
        message_expiration =\
            dictionary.get("message_expiration")\
            if dictionary.get("message_expiration")\
                else APIHelper.SKIP
        cryptogram =\
            dictionary.get("cryptogram")\
            if dictionary.get("cryptogram")\
                else APIHelper.SKIP
        eci_indicator =\
            dictionary.get("eci_indicator")\
            if dictionary.get("eci_indicator")\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(payment_method,
                   card,
                   authentication_method,
                   message_id,
                   message_expiration,
                   cryptogram,
                   eci_indicator)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _message_id=(
            self.message_id
            if hasattr(self, "message_id")
            else None
        )
        _message_expiration=(
            self.message_expiration
            if hasattr(self, "message_expiration")
            else None
        )
        _payment_method=self.payment_method
        _card=self.card
        _authentication_method=self.authentication_method
        _cryptogram=(
            self.cryptogram
            if hasattr(self, "cryptogram")
            else None
        )
        _eci_indicator=(
            self.eci_indicator
            if hasattr(self, "eci_indicator")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"message_id={_message_id!r}, "
            f"message_expiration={_message_expiration!r}, "
            f"payment_method={_payment_method!r}, "
            f"card={_card!r}, "
            f"authentication_method={_authentication_method!r}, "
            f"cryptogram={_cryptogram!r}, "
            f"eci_indicator={_eci_indicator!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _message_id=(
            self.message_id
            if hasattr(self, "message_id")
            else None
        )
        _message_expiration=(
            self.message_expiration
            if hasattr(self, "message_expiration")
            else None
        )
        _payment_method=self.payment_method
        _card=self.card
        _authentication_method=self.authentication_method
        _cryptogram=(
            self.cryptogram
            if hasattr(self, "cryptogram")
            else None
        )
        _eci_indicator=(
            self.eci_indicator
            if hasattr(self, "eci_indicator")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"message_id={_message_id!s}, "
            f"message_expiration={_message_expiration!s}, "
            f"payment_method={_payment_method!s}, "
            f"card={_card!s}, "
            f"authentication_method={_authentication_method!s}, "
            f"cryptogram={_cryptogram!s}, "
            f"eci_indicator={_eci_indicator!s}, "
            f")"
        )
