"""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.non_negative_amount import (
    NonNegativeAmount,
)


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

    Represents an action to be performed on a transaction within a bulk operation.
    Used to specify operations such as cancellation, capture, refund, closing,
    reconciliation, or post-authorization fraud check.
    Each action is applied to a specific transaction and order, with an associated
    amount.
    The 'type' property determines the nature of the action:
      - CANCEL: Cancel the transaction.
      - CAPTURE: Capture funds for the transaction.
      - REFUND: Refund the transaction.
      - CLOSE: Close the transaction.
      - RECONCILIATION: Reconcile the transaction.
      - POST_AUTH_FRAUD_CHECK: Perform a fraud check after authorization.

    Attributes:
        transaction_id (str): The model property of type str.
        order_id (str): The model property of type str.
        amount (NonNegativeAmount): An amount that is a nonnegative number, i.e. {0,
            1, 2, 3, 4, 5,…}
        mtype (Type4): The model property of type Type4.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "transaction_id": "transactionId",
        "order_id": "orderId",
        "amount": "amount",
        "mtype": "type",
    }

    def __init__(
        self,
        transaction_id=None,
        order_id=None,
        amount=None,
        mtype=None,
        additional_properties=None):
        """Initialize a TransactionAction instance."""
        # Initialize members of the class
        self.transaction_id = transaction_id
        self.order_id = order_id
        self.amount = amount
        self.mtype = mtype

        # 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_id =\
            dictionary.get("transactionId")\
            if dictionary.get("transactionId")\
                else None
        order_id =\
            dictionary.get("orderId")\
            if dictionary.get("orderId")\
                else None
        amount =\
            NonNegativeAmount.from_dictionary(
                dictionary.get("amount"))\
                if dictionary.get("amount") else None
        mtype =\
            dictionary.get("type")\
            if dictionary.get("type")\
                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_id,
                   order_id,
                   amount,
                   mtype,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _transaction_id=self.transaction_id
        _order_id=self.order_id
        _amount=self.amount
        _mtype=self.mtype
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"transaction_id={_transaction_id!r}, "
            f"order_id={_order_id!r}, "
            f"amount={_amount!r}, "
            f"mtype={_mtype!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _transaction_id=self.transaction_id
        _order_id=self.order_id
        _amount=self.amount
        _mtype=self.mtype
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"transaction_id={_transaction_id!s}, "
            f"order_id={_order_id!s}, "
            f"amount={_amount!s}, "
            f"mtype={_mtype!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
