"""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 CardResponseWithBillingAddress(object):
    """Implementation of the 'Card Response with Billing Address' model.

    The payment card used to fund the payment. Card can be a credit or debit card.

    Attributes:
        name (str): The card holder's name as it appears on the card.
        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).
        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).
        currency_code (str): The [three-character ISO-4217 currency
            code](/api/rest/reference/currency-codes/) that identifies the currency.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "name": "name",
        "billing_address": "billing_address",
        "expiry": "expiry",
        "currency_code": "currency_code",
    }

    _optionals = [
        "name",
        "billing_address",
        "expiry",
        "currency_code",
    ]

    def __init__(
        self,
        name=APIHelper.SKIP,
        billing_address=APIHelper.SKIP,
        expiry=APIHelper.SKIP,
        currency_code=APIHelper.SKIP):
        """Initialize a CardResponseWithBillingAddress instance."""
        # Initialize members of the class
        if name is not APIHelper.SKIP:
            self.name = name
        if billing_address is not APIHelper.SKIP:
            self.billing_address = billing_address
        if expiry is not APIHelper.SKIP:
            self.expiry = expiry
        if currency_code is not APIHelper.SKIP:
            self.currency_code = currency_code

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

        # Return an object of this model
        return cls(name,
                   billing_address,
                   expiry,
                   currency_code)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _billing_address=(
            self.billing_address
            if hasattr(self, "billing_address")
            else None
        )
        _expiry=(
            self.expiry
            if hasattr(self, "expiry")
            else None
        )
        _currency_code=(
            self.currency_code
            if hasattr(self, "currency_code")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"name={_name!r}, "
            f"billing_address={_billing_address!r}, "
            f"expiry={_expiry!r}, "
            f"currency_code={_currency_code!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _name=(
            self.name
            if hasattr(self, "name")
            else None
        )
        _billing_address=(
            self.billing_address
            if hasattr(self, "billing_address")
            else None
        )
        _expiry=(
            self.expiry
            if hasattr(self, "expiry")
            else None
        )
        _currency_code=(
            self.currency_code
            if hasattr(self, "currency_code")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"name={_name!s}, "
            f"billing_address={_billing_address!s}, "
            f"expiry={_expiry!s}, "
            f"currency_code={_currency_code!s}, "
            f")"
        )
