"""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_header import (
    PaymentDataHeader,
)


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

    Encrypted payment data.

    Attributes:
        data (str): Encrypted payment data.
        signature (str): Signature of the payment and header data The signature
            includes the signing certificate, its intermediate CA certificate, and
            information about the signing algorithm. Tokenized cards will last 15
            minutes. If the card should be persisted longer term as a stored card,
            then the save card endpoint should be used.
        header (PaymentDataHeader): Payment data header for EC token, RSA is not
            supported
        version (str): Version information about the payment token.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "data": "data",
        "signature": "signature",
        "header": "header",
        "version": "version",
    }

    def __init__(
        self,
        data=None,
        signature=None,
        header=None,
        additional_properties=None):
        """Initialize a PaymentData instance."""
        # Initialize members of the class
        self.data = data
        self.signature = signature
        self.header = header
        self.version = "EC_v1"

        # 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
        data =\
            dictionary.get("data")\
            if dictionary.get("data")\
                else None
        signature =\
            dictionary.get("signature")\
            if dictionary.get("signature")\
                else None
        header =\
            PaymentDataHeader.from_dictionary(
                dictionary.get("header"))\
                if dictionary.get("header") 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(data,
                   signature,
                   header,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _data=self.data
        _signature=self.signature
        _header=self.header
        _version=self.version
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"data={_data!r}, "
            f"signature={_signature!r}, "
            f"header={_header!r}, "
            f"version={_version!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _data=self.data
        _signature=self.signature
        _header=self.header
        _version=self.version
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"data={_data!s}, "
            f"signature={_signature!s}, "
            f"header={_header!s}, "
            f"version={_version!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
