"""visaacceptancemergedspec.

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

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)


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

    Attributes:
        key_serial_number (str): The encoded or encrypted value that a payment
            solution returns for an authorization request. For details about the
            valid values for a key, see [Creating an Online Authorization](
        descriptor (str): The identifier for a payment solution, which is sending the
            encrypted payment data for decryption. Valid values: Samsung Pay:
            RklEPUNPTU1PTi5TQU1TVU5HLklOQVBQLlBBWU1FTlQ= Note: For other payment
            solutions, the value may be specific to the terminal or device initiatinf
            the payment. For example, the descriptor for a Bluefin payment encryption
            would be a device-generated descriptor. Used by Authorization and
            Standalone Credits. Required for authorizations and standalone credits.
            Card Present processing: Format of the encrypted payment data. The value
            for Bluefin PCI P2PE is `Ymx1ZWZpbg==`.
            paymentInformation.fluidData.encoding must be `Base64`. The value for
            Visa Acceptance P2PE decryption depends on the encoding method used and
            identified in encoding field. If paymentInformation.fluidData.encoding is
            `Base64`, the value is: `RklEPUVNVi5QQVlNRU5ULkFQSQ==` If
            paymentInformation.fluidData.encoding is `HEX`, the value is:
            `4649443D454D562E5041594D454E542E41504`
        value (str): Represents the encrypted payment data BLOB. The entry for this
            field is dependent on the payment solution used by the merchant. Used by
            Authorization and Standalone Credits. Required for authorizations and
            standalone credits that use a Visa Acceptance suppored Point-to-Point
            encryption method. Card Present processing This field represents the
            encrypted payment data generated by the payment terminal/device.
        encoding (str): Encoding method used to encrypt the payment data. Valid
            values: `Base64`, `HEX` If no value is provided, `Base64` is taken as the
            default value. And the `Base64` descriptor is used for
            paymentInformation.fluidData.encoding
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "key_serial_number": "keySerialNumber",
        "descriptor": "descriptor",
        "value": "value",
        "encoding": "encoding",
    }

    _optionals = [
        "key_serial_number",
        "descriptor",
        "value",
        "encoding",
    ]

    def __init__(
        self,
        key_serial_number=APIHelper.SKIP,
        descriptor=APIHelper.SKIP,
        value=APIHelper.SKIP,
        encoding=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a FluidData instance."""
        # Initialize members of the class
        if key_serial_number is not APIHelper.SKIP:
            self.key_serial_number = key_serial_number
        if descriptor is not APIHelper.SKIP:
            self.descriptor = descriptor
        if value is not APIHelper.SKIP:
            self.value = value
        if encoding is not APIHelper.SKIP:
            self.encoding = encoding

        # 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
        key_serial_number =\
            dictionary.get("keySerialNumber")\
            if dictionary.get("keySerialNumber")\
                else APIHelper.SKIP
        descriptor =\
            dictionary.get("descriptor")\
            if dictionary.get("descriptor")\
                else APIHelper.SKIP
        value =\
            dictionary.get("value")\
            if dictionary.get("value")\
                else APIHelper.SKIP
        encoding =\
            dictionary.get("encoding")\
            if dictionary.get("encoding")\
                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(key_serial_number,
                   descriptor,
                   value,
                   encoding,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _key_serial_number=(
            self.key_serial_number
            if hasattr(self, "key_serial_number")
            else None
        )
        _descriptor=(
            self.descriptor
            if hasattr(self, "descriptor")
            else None
        )
        _value=(
            self.value
            if hasattr(self, "value")
            else None
        )
        _encoding=(
            self.encoding
            if hasattr(self, "encoding")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"key_serial_number={_key_serial_number!r}, "
            f"descriptor={_descriptor!r}, "
            f"value={_value!r}, "
            f"encoding={_encoding!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _key_serial_number=(
            self.key_serial_number
            if hasattr(self, "key_serial_number")
            else None
        )
        _descriptor=(
            self.descriptor
            if hasattr(self, "descriptor")
            else None
        )
        _value=(
            self.value
            if hasattr(self, "value")
            else None
        )
        _encoding=(
            self.encoding
            if hasattr(self, "encoding")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"key_serial_number={_key_serial_number!s}, "
            f"descriptor={_descriptor!s}, "
            f"value={_value!s}, "
            f"encoding={_encoding!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
