"""visaacceptancemergedspec.

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

# ruff: noqa: E501
from visaacceptancemergedspec.api_helper import (
    APIHelper,
)
from visaacceptancemergedspec.models.mself import (
    Self,
)
from visaacceptancemergedspec.models.related_transaction import (
    RelatedTransaction,
)


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

    Attributes:
        mself (Self): The model property of type Self.
        related_transactions (List[RelatedTransaction]): The model property of type
            List[RelatedTransaction].
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "mself": "self",
        "related_transactions": "relatedTransactions",
    }

    _optionals = [
        "mself",
        "related_transactions",
    ]

    def __init__(
        self,
        mself=APIHelper.SKIP,
        related_transactions=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a Links219 instance."""
        # Initialize members of the class
        if mself is not APIHelper.SKIP:
            self.mself = mself
        if related_transactions is not APIHelper.SKIP:
            self.related_transactions = related_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.

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

        # Extract variables from the dictionary
        mself =\
            Self.from_dictionary(
                dictionary.get("self"))\
                if "self" in dictionary.keys()\
                else APIHelper.SKIP
        related_transactions = None
        if dictionary.get("relatedTransactions") is not None:
            related_transactions = [
                RelatedTransaction.from_dictionary(x)
                    for x in dictionary.get("relatedTransactions")
            ]
        else:
            related_transactions = 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(mself,
                   related_transactions,
                   additional_properties)

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

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