"""cellpointapi.

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

# ruff: noqa: E501
from cellpointapi.api_helper import APIHelper
from cellpointapi.models.payment_data import (
    PaymentData,
)
from cellpointapi.models.pk_payment_method import (
    PkPaymentMethod,
)


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

    Encrypted Apple Pay token with metadata.

    Attributes:
        transaction_identifier (str): Transaction identifier, generated on the client
            device.
        payment_method (PkPaymentMethod): Apple Pay payment method.
        payment_data (PaymentData): Encrypted payment data.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "transaction_identifier": "transactionIdentifier",
        "payment_method": "paymentMethod",
        "payment_data": "paymentData",
    }

    def __init__(
        self,
        transaction_identifier=None,
        payment_method=None,
        payment_data=None,
        additional_properties=None):
        """Initialize a PkPaymentToken instance."""
        # Initialize members of the class
        self.transaction_identifier = transaction_identifier
        self.payment_method = payment_method
        self.payment_data = payment_data

        # 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
        transaction_identifier =\
            dictionary.get("transactionIdentifier")\
            if dictionary.get("transactionIdentifier")\
                else None
        payment_method =\
            PkPaymentMethod.from_dictionary(
                dictionary.get("paymentMethod"))\
                if dictionary.get("paymentMethod") else None
        payment_data =\
            PaymentData.from_dictionary(
                dictionary.get("paymentData"))\
                if dictionary.get("paymentData") else None

        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(transaction_identifier,
                   payment_method,
                   payment_data,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _transaction_identifier=self.transaction_identifier
        _payment_method=self.payment_method
        _payment_data=self.payment_data
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"transaction_identifier={_transaction_identifier!r}, "
            f"payment_method={_payment_method!r}, "
            f"payment_data={_payment_data!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _transaction_identifier=self.transaction_identifier
        _payment_method=self.payment_method
        _payment_data=self.payment_data
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"transaction_identifier={_transaction_identifier!s}, "
            f"payment_method={_payment_method!s}, "
            f"payment_data={_payment_data!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
