"""cellpointapi.

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

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


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

    Amount canceled from an authorized transaction.

    Attributes:
        currency (str): ISO 4217 currency code. Must be UPPERCASE.
        value (int): Cost in the lowest denominator of the currency.   E.g. 101 for
            £1.01
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "currency": "currency",
        "value": "value",
    }

    def __init__(
        self,
        currency=None,
        value=None,
        additional_properties=None):
        """Initialize a PaymentTransactionCanceledAmount instance."""
        # Initialize members of the class
        self.currency = currency
        self.value = value

        # 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
        currency =\
            dictionary.get("currency")\
            if dictionary.get("currency")\
                else None
        value =\
            dictionary.get("value")\
            if dictionary.get("value")\
                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(currency,
                   value,
                   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.currency,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                )) \
                and APIHelper.is_valid_type(
                    value=dictionary.value,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        int,
                ))

        if not isinstance(dictionary, dict):
            return False

        return APIHelper.is_valid_type(
                value=dictionary.get("currency"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    str,
            )) \
            and APIHelper.is_valid_type(
                value=dictionary.get("value"),
                type_callable=lambda value:
                    isinstance(
                    value,
                    int,
            ))

    def __repr__(self):
        """Return a unambiguous string representation."""
        _currency=self.currency
        _value=self.value
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"currency={_currency!r}, "
            f"value={_value!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _currency=self.currency
        _value=self.value
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"currency={_currency!s}, "
            f"value={_value!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
