"""cellpointapi.

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

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


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

    Acquirer or Payment Service Provider (PSP) that processed the payment.

    Attributes:
        name (str): Name of the payment processor.
        mid (str): Merchant Id (MID) used with the payment processor.
        external_transaction_id (str): Transaction Identifer in the external payment
            processor's system.
        authorization_code (str): Authorization code received from payment processor.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "name": "name",
        "mid": "mid",
        "external_transaction_id": "externalTransactionId",
        "authorization_code": "authorizationCode",
    }

    _optionals = [
        "mid",
        "external_transaction_id",
        "authorization_code",
    ]

    def __init__(
        self,
        name=None,
        mid=APIHelper.SKIP,
        external_transaction_id=APIHelper.SKIP,
        authorization_code=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a PaymentProcessor instance."""
        # Initialize members of the class
        self.name = name
        if mid is not APIHelper.SKIP:
            self.mid = mid
        if external_transaction_id is not APIHelper.SKIP:
            self.external_transaction_id = external_transaction_id
        if authorization_code is not APIHelper.SKIP:
            self.authorization_code = authorization_code

        # 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
        name =\
            dictionary.get("name")\
            if dictionary.get("name")\
                else None
        mid =\
            dictionary.get("mid")\
            if dictionary.get("mid")\
                else APIHelper.SKIP
        external_transaction_id =\
            dictionary.get("externalTransactionId")\
            if dictionary.get("externalTransactionId")\
                else APIHelper.SKIP
        authorization_code =\
            dictionary.get("authorizationCode")\
            if dictionary.get("authorizationCode")\
                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(name,
                   mid,
                   external_transaction_id,
                   authorization_code,
                   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.name,
                    type_callable=lambda value:
                        isinstance(
                        value,
                        str,
                ))

        if not isinstance(dictionary, dict):
            return False

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

    def __repr__(self):
        """Return a unambiguous string representation."""
        _name=self.name
        _mid=(
            self.mid
            if hasattr(self, "mid")
            else None
        )
        _external_transaction_id=(
            self.external_transaction_id
            if hasattr(self, "external_transaction_id")
            else None
        )
        _authorization_code=(
            self.authorization_code
            if hasattr(self, "authorization_code")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"name={_name!r}, "
            f"mid={_mid!r}, "
            f"external_transaction_id={_external_transaction_id!r}, "
            f"authorization_code={_authorization_code!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _name=self.name
        _mid=(
            self.mid
            if hasattr(self, "mid")
            else None
        )
        _external_transaction_id=(
            self.external_transaction_id
            if hasattr(self, "external_transaction_id")
            else None
        )
        _authorization_code=(
            self.authorization_code
            if hasattr(self, "authorization_code")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"name={_name!s}, "
            f"mid={_mid!s}, "
            f"external_transaction_id={_external_transaction_id!s}, "
            f"authorization_code={_authorization_code!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
