"""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.card_response_with_billing_address import (
    CardResponseWithBillingAddress,
)


class SubscriptionPaymentSourceResponse(object):
    """Implementation of the 'Subscription Payment Source Response' model.

    The payment source used to fund the payment.

    Attributes:
        card (CardResponseWithBillingAddress): The payment card used to fund the
            payment. Card can be a credit or debit card.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "card": "card",
    }

    _optionals = [
        "card",
    ]

    def __init__(
        self,
        card=APIHelper.SKIP):
        """Initialize a SubscriptionPaymentSourceResponse instance."""
        # Initialize members of the class
        if card is not APIHelper.SKIP:
            self.card = card

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

        # Return an object of this model
        return cls(card)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _card=(
            self.card
            if hasattr(self, "card")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"card={_card!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _card=(
            self.card
            if hasattr(self, "card")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"card={_card!s}, "
            f")"
        )
