"""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.apple_pay_payment_token import (
    ApplePayPaymentToken,
)
from paypalserversdk.models.card_payment_token_entity import (
    CardPaymentTokenEntity,
)
from paypalserversdk.models.paypal_payment_token import (
    PaypalPaymentToken,
)
from paypalserversdk.models.venmo_payment_token import (
    VenmoPaymentToken,
)


class PaymentTokenResponsePaymentSource(object):
    """Implementation of the 'Payment Token Response Payment Source' model.

    The vaulted payment method details.

    Attributes:
        card (CardPaymentTokenEntity): Full representation of a Card Payment Token
            including network token.
        paypal (PaypalPaymentToken): Full representation of a PayPal Payment Token.
        venmo (VenmoPaymentToken): Full representation of a Venmo Payment Token.
        apple_pay (ApplePayPaymentToken): A resource representing a response for
            Apple Pay.

    """

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

    _optionals = [
        "card",
        "paypal",
        "venmo",
        "apple_pay",
    ]

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

    @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 =\
            CardPaymentTokenEntity.from_dictionary(
                dictionary.get("card"))\
                if "card" in dictionary.keys()\
                else APIHelper.SKIP
        paypal =\
            PaypalPaymentToken.from_dictionary(
                dictionary.get("paypal"))\
                if "paypal" in dictionary.keys()\
                else APIHelper.SKIP
        venmo =\
            VenmoPaymentToken.from_dictionary(
                dictionary.get("venmo"))\
                if "venmo" in dictionary.keys()\
                else APIHelper.SKIP
        apple_pay =\
            ApplePayPaymentToken.from_dictionary(
                dictionary.get("apple_pay"))\
                if "apple_pay" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(card,
                   paypal,
                   venmo,
                   apple_pay)

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

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