"""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.transaction_action import (
    TransactionAction,
)


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

    Result of a single action performed in bulk.

    Attributes:
        action (TransactionAction): 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.
        status (ActionResultStatus): Result of the action.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

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

    def __init__(
        self,
        action=None,
        status=None,
        additional_properties=None):
        """Initialize a TransactionActionResult instance."""
        # Initialize members of the class
        self.action = action
        self.status = status

        # 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
        action =\
            TransactionAction.from_dictionary(
                dictionary.get("action"))\
                if dictionary.get("action") else None
        status =\
            dictionary.get("status")\
            if dictionary.get("status")\
                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(action,
                   status,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _action=self.action
        _status=self.status
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"action={_action!r}, "
            f"status={_status!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _action=self.action
        _status=self.status
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"action={_action!s}, "
            f"status={_status!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
