"""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.address import Address


class GooglePayCard(object):
    """Implementation of the 'Google Pay Card' model.

    The payment card used to fund a Google Pay payment. Can be a credit or debit card.

    Attributes:
        name (str): The card holder's name as it appears on the card.
        number (str): The primary account number (PAN) for the payment card.
        expiry (str): The year and month, in ISO-8601 `YYYY-MM` date format. See
            [Internet date and time
            format](https://tools.ietf.org/html/rfc3339#section-5.6).
        last_digits (str): The last digits of the payment card.
        mtype (CardType): Type of card. i.e Credit, Debit and so on.
        brand (CardBrand): The card network or brand. Applies to credit, debit, gift,
            and payment cards.
        billing_address (Address): The portable international postal address. Maps to
            [AddressValidationMetadata](https://github.com/googlei18n/libaddressinput/
            wiki/AddressValidationMetadata) and HTML 5.1 [Autofilling form controls:
            the autocomplete
            attribute](https://www.w3.org/TR/html51/sec-forms.html#autofilling-form-co
            ntrols-the-autocomplete-attribute).

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "name": "name",
        "number": "number",
        "expiry": "expiry",
        "last_digits": "last_digits",
        "mtype": "type",
        "brand": "brand",
        "billing_address": "billing_address",
    }

    _optionals = [
        "name",
        "number",
        "expiry",
        "last_digits",
        "mtype",
        "brand",
        "billing_address",
    ]

    def __init__(
        self,
        name=APIHelper.SKIP,
        number=APIHelper.SKIP,
        expiry=APIHelper.SKIP,
        last_digits=APIHelper.SKIP,
        mtype=APIHelper.SKIP,
        brand=APIHelper.SKIP,
        billing_address=APIHelper.SKIP):
        """Initialize a GooglePayCard instance."""
        # Initialize members of the class
        if name is not APIHelper.SKIP:
            self.name = name
        if number is not APIHelper.SKIP:
            self.number = number
        if expiry is not APIHelper.SKIP:
            self.expiry = expiry
        if last_digits is not APIHelper.SKIP:
            self.last_digits = last_digits
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype
        if brand is not APIHelper.SKIP:
            self.brand = brand
        if billing_address is not APIHelper.SKIP:
            self.billing_address = billing_address

    @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
        number =\
            dictionary.get("number")\
            if dictionary.get("number")\
                else APIHelper.SKIP
        expiry =\
            dictionary.get("expiry")\
            if dictionary.get("expiry")\
                else APIHelper.SKIP
        last_digits =\
            dictionary.get("last_digits")\
            if dictionary.get("last_digits")\
                else APIHelper.SKIP
        mtype =\
            dictionary.get("type")\
            if dictionary.get("type")\
                else APIHelper.SKIP
        brand =\
            dictionary.get("brand")\
            if dictionary.get("brand")\
                else APIHelper.SKIP
        billing_address =\
            Address.from_dictionary(
                dictionary.get("billing_address"))\
                if "billing_address" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(name,
                   number,
                   expiry,
                   last_digits,
                   mtype,
                   brand,
                   billing_address)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _number=(
            self.number
            if hasattr(self, "number")
            else None
        )
        _expiry=(
            self.expiry
            if hasattr(self, "expiry")
            else None
        )
        _last_digits=(
            self.last_digits
            if hasattr(self, "last_digits")
            else None
        )
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _brand=(
            self.brand
            if hasattr(self, "brand")
            else None
        )
        _billing_address=(
            self.billing_address
            if hasattr(self, "billing_address")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"name={_name!r}, "
            f"number={_number!r}, "
            f"expiry={_expiry!r}, "
            f"last_digits={_last_digits!r}, "
            f"mtype={_mtype!r}, "
            f"brand={_brand!r}, "
            f"billing_address={_billing_address!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _number=(
            self.number
            if hasattr(self, "number")
            else None
        )
        _expiry=(
            self.expiry
            if hasattr(self, "expiry")
            else None
        )
        _last_digits=(
            self.last_digits
            if hasattr(self, "last_digits")
            else None
        )
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _brand=(
            self.brand
            if hasattr(self, "brand")
            else None
        )
        _billing_address=(
            self.billing_address
            if hasattr(self, "billing_address")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"name={_name!s}, "
            f"number={_number!s}, "
            f"expiry={_expiry!s}, "
            f"last_digits={_last_digits!s}, "
            f"mtype={_mtype!s}, "
            f"brand={_brand!s}, "
            f"billing_address={_billing_address!s}, "
            f")"
        )
