"""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.assurance_details import (
    AssuranceDetails,
)
from paypalserversdk.models.google_pay_decrypted_token_data import (
    GooglePayDecryptedTokenData,
)
from paypalserversdk.models.google_pay_experience_context import (
    GooglePayExperienceContext,
)
from paypalserversdk.models.google_pay_request_card import (
    GooglePayRequestCard,
)
from paypalserversdk.models.phone_number_with_country_code import (
    PhoneNumberWithCountryCode,
)


class GooglePayRequest(object):
    """Implementation of the 'Google Pay Request' model.

    Information needed to pay using Google Pay.

    Attributes:
        name (str): The full name representation like Mr J Smith.
        email_address (str): The internationalized email address. Note: Up to 64
            characters are allowed before and 255 characters are allowed after the @
            sign. However, the generally accepted maximum length for an email address
            is 254 characters. The pattern verifies that an unquoted @ sign exists.
        phone_number (PhoneNumberWithCountryCode): The phone number in its canonical
            international [E.164 numbering plan
            format](https://www.itu.int/rec/T-REC-E.164/en).
        card (GooglePayRequestCard): The payment card used to fund a Google Pay
            payment. Can be a credit or debit card.
        decrypted_token (GooglePayDecryptedTokenData): 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.
        assurance_details (AssuranceDetails): Information about cardholder possession
            validation and cardholder identification and verifications (ID&V).
        experience_context (GooglePayExperienceContext): Customizes the payer
            experience during the approval process for the payment.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "name": "name",
        "email_address": "email_address",
        "phone_number": "phone_number",
        "card": "card",
        "decrypted_token": "decrypted_token",
        "assurance_details": "assurance_details",
        "experience_context": "experience_context",
    }

    _optionals = [
        "name",
        "email_address",
        "phone_number",
        "card",
        "decrypted_token",
        "assurance_details",
        "experience_context",
    ]

    def __init__(
        self,
        name=APIHelper.SKIP,
        email_address=APIHelper.SKIP,
        phone_number=APIHelper.SKIP,
        card=APIHelper.SKIP,
        decrypted_token=APIHelper.SKIP,
        assurance_details=APIHelper.SKIP,
        experience_context=APIHelper.SKIP):
        """Initialize a GooglePayRequest instance."""
        # Initialize members of the class
        if name is not APIHelper.SKIP:
            self.name = name
        if email_address is not APIHelper.SKIP:
            self.email_address = email_address
        if phone_number is not APIHelper.SKIP:
            self.phone_number = phone_number
        if card is not APIHelper.SKIP:
            self.card = card
        if decrypted_token is not APIHelper.SKIP:
            self.decrypted_token = decrypted_token
        if assurance_details is not APIHelper.SKIP:
            self.assurance_details = assurance_details
        if experience_context is not APIHelper.SKIP:
            self.experience_context = experience_context

    @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
        name =\
            dictionary.get("name")\
            if dictionary.get("name")\
                else APIHelper.SKIP
        email_address =\
            dictionary.get("email_address")\
            if dictionary.get("email_address")\
                else APIHelper.SKIP
        phone_number =\
            PhoneNumberWithCountryCode.from_dictionary(
                dictionary.get("phone_number"))\
                if "phone_number" in dictionary.keys()\
                else APIHelper.SKIP
        card =\
            GooglePayRequestCard.from_dictionary(
                dictionary.get("card"))\
                if "card" in dictionary.keys()\
                else APIHelper.SKIP
        decrypted_token =\
            GooglePayDecryptedTokenData.from_dictionary(
                dictionary.get("decrypted_token"))\
                if "decrypted_token" in dictionary.keys()\
                else APIHelper.SKIP
        assurance_details =\
            AssuranceDetails.from_dictionary(
                dictionary.get("assurance_details"))\
                if "assurance_details" in dictionary.keys()\
                else APIHelper.SKIP
        experience_context =\
            GooglePayExperienceContext.from_dictionary(
                dictionary.get("experience_context"))\
                if "experience_context" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(name,
                   email_address,
                   phone_number,
                   card,
                   decrypted_token,
                   assurance_details,
                   experience_context)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _email_address=(
            self.email_address
            if hasattr(self, "email_address")
            else None
        )
        _phone_number=(
            self.phone_number
            if hasattr(self, "phone_number")
            else None
        )
        _card=(
            self.card
            if hasattr(self, "card")
            else None
        )
        _decrypted_token=(
            self.decrypted_token
            if hasattr(self, "decrypted_token")
            else None
        )
        _assurance_details=(
            self.assurance_details
            if hasattr(self, "assurance_details")
            else None
        )
        _experience_context=(
            self.experience_context
            if hasattr(self, "experience_context")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"name={_name!r}, "
            f"email_address={_email_address!r}, "
            f"phone_number={_phone_number!r}, "
            f"card={_card!r}, "
            f"decrypted_token={_decrypted_token!r}, "
            f"assurance_details={_assurance_details!r}, "
            f"experience_context={_experience_context!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _email_address=(
            self.email_address
            if hasattr(self, "email_address")
            else None
        )
        _phone_number=(
            self.phone_number
            if hasattr(self, "phone_number")
            else None
        )
        _card=(
            self.card
            if hasattr(self, "card")
            else None
        )
        _decrypted_token=(
            self.decrypted_token
            if hasattr(self, "decrypted_token")
            else None
        )
        _assurance_details=(
            self.assurance_details
            if hasattr(self, "assurance_details")
            else None
        )
        _experience_context=(
            self.experience_context
            if hasattr(self, "experience_context")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"name={_name!s}, "
            f"email_address={_email_address!s}, "
            f"phone_number={_phone_number!s}, "
            f"card={_card!s}, "
            f"decrypted_token={_decrypted_token!s}, "
            f"assurance_details={_assurance_details!s}, "
            f"experience_context={_experience_context!s}, "
            f")"
        )
