"""cellpointapi.

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

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


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

    List of transactions associated with an order.

    Attributes:
        transactions (List[PaymentTransaction | RefundTransaction |
            ExternalTransaction] | None): The model property of type
            List[PaymentTransaction | RefundTransaction | ExternalTransaction] | None.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

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

    _optionals = [
        "transactions",
    ]

    def __init__(
        self,
        transactions=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a OrderTransactions instance."""
        # Initialize members of the class
        if transactions is not APIHelper.SKIP:
            self.transactions = transactions

        # 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.

        """
        from cellpointapi.utilities.union_type_lookup import (
            UnionTypeLookUp,
        )

        if not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        transactions = APIHelper.deserialize_union_type(
            UnionTypeLookUp.get("Transaction"),
            dictionary.get("transactions"),
            False)\
            if dictionary.get("transactions") is not None\
            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(transactions,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _transactions=(
            self.transactions
            if hasattr(self, "transactions")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"transactions={_transactions!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _transactions=(
            self.transactions
            if hasattr(self, "transactions")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"transactions={_transactions!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
