"""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.application import (
    Application,
)


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

    Attributes:
        status (str): The status of the submitted transaction.
        reason_code (str): Indicates the reason why a request succeeded or failed and
            possible action to take if a request fails.  For details, see the
            appendix of reason codes in the documentation for the relevant payment
            method.
        r_code (str): Indicates whether the service request was successful. Possible
            values:  - `-1`: An error occurred. - `0`: The request was declined. -
            `1`: The request was successful.
        r_flag (str): One-word description of the result of the application.
        applications (List[Application]): The model property of type
            List[Application].
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "status": "status",
        "reason_code": "reasonCode",
        "r_code": "rCode",
        "r_flag": "rFlag",
        "applications": "applications",
    }

    _optionals = [
        "status",
        "reason_code",
        "r_code",
        "r_flag",
        "applications",
    ]

    def __init__(
        self,
        status=APIHelper.SKIP,
        reason_code=APIHelper.SKIP,
        r_code=APIHelper.SKIP,
        r_flag=APIHelper.SKIP,
        applications=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a ApplicationInformation instance."""
        # Initialize members of the class
        if status is not APIHelper.SKIP:
            self.status = status
        if reason_code is not APIHelper.SKIP:
            self.reason_code = reason_code
        if r_code is not APIHelper.SKIP:
            self.r_code = r_code
        if r_flag is not APIHelper.SKIP:
            self.r_flag = r_flag
        if applications is not APIHelper.SKIP:
            self.applications = applications

        # 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
        status =\
            dictionary.get("status")\
            if dictionary.get("status")\
                else APIHelper.SKIP
        reason_code =\
            dictionary.get("reasonCode")\
            if dictionary.get("reasonCode")\
                else APIHelper.SKIP
        r_code =\
            dictionary.get("rCode")\
            if dictionary.get("rCode")\
                else APIHelper.SKIP
        r_flag =\
            dictionary.get("rFlag")\
            if dictionary.get("rFlag")\
                else APIHelper.SKIP
        applications = None
        if dictionary.get("applications") is not None:
            applications = [
                Application.from_dictionary(x)
                    for x in dictionary.get("applications")
            ]
        else:
            applications = 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(status,
                   reason_code,
                   r_code,
                   r_flag,
                   applications,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _status=(
            self.status
            if hasattr(self, "status")
            else None
        )
        _reason_code=(
            self.reason_code
            if hasattr(self, "reason_code")
            else None
        )
        _r_code=(
            self.r_code
            if hasattr(self, "r_code")
            else None
        )
        _r_flag=(
            self.r_flag
            if hasattr(self, "r_flag")
            else None
        )
        _applications=(
            self.applications
            if hasattr(self, "applications")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"status={_status!r}, "
            f"reason_code={_reason_code!r}, "
            f"r_code={_r_code!r}, "
            f"r_flag={_r_flag!r}, "
            f"applications={_applications!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _status=(
            self.status
            if hasattr(self, "status")
            else None
        )
        _reason_code=(
            self.reason_code
            if hasattr(self, "reason_code")
            else None
        )
        _r_code=(
            self.r_code
            if hasattr(self, "r_code")
            else None
        )
        _r_flag=(
            self.r_flag
            if hasattr(self, "r_flag")
            else None
        )
        _applications=(
            self.applications
            if hasattr(self, "applications")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"status={_status!s}, "
            f"reason_code={_reason_code!s}, "
            f"r_code={_r_code!s}, "
            f"r_flag={_r_flag!s}, "
            f"applications={_applications!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
