"""cellpointapi.

This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
"""

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper


class ApplePayInstrumentApplePayNode(object):
    """Implementation of the 'ApplePayInstrumentApplePayNode' model.

    Apple Pay token that was used in the payment.

    Attributes:
        token (str): Card token identifier. Used for both cards and Apple Pay.
        scheme (CardScheme): Card Scheme networks connects acquiring banks to issuing
            banks so that a customer transaction can be verified.  Is a middle man
            that also provide additional services, such as data processing,
            international transactions, etc.
        display_name (str): Display Payment Card Name.  A string, suitable for
            display, that describes the card.  For debit and credit cards, the
            display name often includes the card brand and the last four digits of
            the credit card number when available, for example: “************0492”,
            “Visa 1233”, “MasterCard 5678”, “AmEx 9876”. For Apple Pay Cash cards,
            the display name is “Apple Pay Cash”. However, there is no guarantee
            about the display name’s content or format.  To protect the user’s
            privacy, Apple Pay sets the display name only after the user authorizes
            the purchase.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "token": "token",
        "scheme": "scheme",
        "display_name": "displayName",
    }

    _optionals = [
        "scheme",
        "display_name",
    ]

    def __init__(
        self,
        token=None,
        scheme=APIHelper.SKIP,
        display_name=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a ApplePayInstrumentApplePayNode instance."""
        # Initialize members of the class
        self.token = token
        if scheme is not APIHelper.SKIP:
            self.scheme = scheme
        if display_name is not APIHelper.SKIP:
            self.display_name = display_name

        # Add additional model properties to the instance
        if additional_properties is None:
            additional_properties = {}
        self.additional_properties = additional_properties

    @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
        token =\
            dictionary.get("token")\
            if dictionary.get("token")\
                else None
        scheme =\
            dictionary.get("scheme")\
            if dictionary.get("scheme")\
                else APIHelper.SKIP
        display_name =\
            dictionary.get("displayName")\
            if dictionary.get("displayName")\
                else APIHelper.SKIP

        additional_properties = APIHelper.get_additional_properties(
            dictionary={k: v for k, v in dictionary.items()
                        if k not in cls._names.values()},
            unboxing_function=lambda value: value)

        # Return an object of this model
        return cls(token,
                   scheme,
                   display_name,
                   additional_properties)

    @classmethod
    def validate(cls, dictionary):
        """Validate dictionary against class required properties

        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:
            boolean : if dictionary is valid contains required properties.

        """
        if isinstance(dictionary, cls):
            return APIHelper.is_valid_type(
                    value=dictionary.token,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                ))

        if not isinstance(dictionary, dict):
            return False

        return APIHelper.is_valid_type(
                value=dictionary.get("token"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            ))

    def __repr__(self):
        """Return a unambiguous string representation."""
        _token=self.token
        _scheme=(
            self.scheme
            if hasattr(self, "scheme")
            else None
        )
        _display_name=(
            self.display_name
            if hasattr(self, "display_name")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"token={_token!r}, "
            f"scheme={_scheme!r}, "
            f"display_name={_display_name!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _token=self.token
        _scheme=(
            self.scheme
            if hasattr(self, "scheme")
            else None
        )
        _display_name=(
            self.display_name
            if hasattr(self, "display_name")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"token={_token!s}, "
            f"scheme={_scheme!s}, "
            f"display_name={_display_name!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
