"""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.passive_profile import (
    PassiveProfile,
)
from visaacceptancemergedspec.models.passive_rule import (
    PassiveRule,
)
from visaacceptancemergedspec.models.profile_2 import (
    Profile2,
)
from visaacceptancemergedspec.models.rule_1 import (
    Rule1,
)
from visaacceptancemergedspec.models.score_1 import (
    Score1,
)


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

    Attributes:
        profile (Profile2): The model property of type Profile2.
        rules (List[Rule1]): The model property of type List[Rule1].
        passive_profile (PassiveProfile): The model property of type PassiveProfile.
        passive_rules (List[PassiveRule]): The model property of type
            List[PassiveRule].
        score (Score1): The model property of type Score1.
        local_time (str): Time that the transaction was submitted in local time.
            Generated by Visa Acceptance.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "profile": "profile",
        "rules": "rules",
        "passive_profile": "passiveProfile",
        "passive_rules": "passiveRules",
        "score": "score",
        "local_time": "localTime",
    }

    _optionals = [
        "profile",
        "rules",
        "passive_profile",
        "passive_rules",
        "score",
        "local_time",
    ]

    def __init__(
        self,
        profile=APIHelper.SKIP,
        rules=APIHelper.SKIP,
        passive_profile=APIHelper.SKIP,
        passive_rules=APIHelper.SKIP,
        score=APIHelper.SKIP,
        local_time=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a RiskInformation5 instance."""
        # Initialize members of the class
        if profile is not APIHelper.SKIP:
            self.profile = profile
        if rules is not APIHelper.SKIP:
            self.rules = rules
        if passive_profile is not APIHelper.SKIP:
            self.passive_profile = passive_profile
        if passive_rules is not APIHelper.SKIP:
            self.passive_rules = passive_rules
        if score is not APIHelper.SKIP:
            self.score = score
        if local_time is not APIHelper.SKIP:
            self.local_time = local_time

        # 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
        profile =\
            Profile2.from_dictionary(
                dictionary.get("profile"))\
                if "profile" in dictionary.keys()\
                else APIHelper.SKIP
        rules = None
        if dictionary.get("rules") is not None:
            rules = [
                Rule1.from_dictionary(x)
                    for x in dictionary.get("rules")
            ]
        else:
            rules = APIHelper.SKIP
        passive_profile =\
            PassiveProfile.from_dictionary(
                dictionary.get("passiveProfile"))\
                if "passiveProfile" in dictionary.keys()\
                else APIHelper.SKIP
        passive_rules = None
        if dictionary.get("passiveRules") is not None:
            passive_rules = [
                PassiveRule.from_dictionary(x)
                    for x in dictionary.get("passiveRules")
            ]
        else:
            passive_rules = APIHelper.SKIP
        score =\
            Score1.from_dictionary(
                dictionary.get("score"))\
                if "score" in dictionary.keys()\
                else APIHelper.SKIP
        local_time =\
            dictionary.get("localTime")\
            if dictionary.get("localTime")\
                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(profile,
                   rules,
                   passive_profile,
                   passive_rules,
                   score,
                   local_time,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _profile=(
            self.profile
            if hasattr(self, "profile")
            else None
        )
        _rules=(
            self.rules
            if hasattr(self, "rules")
            else None
        )
        _passive_profile=(
            self.passive_profile
            if hasattr(self, "passive_profile")
            else None
        )
        _passive_rules=(
            self.passive_rules
            if hasattr(self, "passive_rules")
            else None
        )
        _score=(
            self.score
            if hasattr(self, "score")
            else None
        )
        _local_time=(
            self.local_time
            if hasattr(self, "local_time")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"profile={_profile!r}, "
            f"rules={_rules!r}, "
            f"passive_profile={_passive_profile!r}, "
            f"passive_rules={_passive_rules!r}, "
            f"score={_score!r}, "
            f"local_time={_local_time!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _profile=(
            self.profile
            if hasattr(self, "profile")
            else None
        )
        _rules=(
            self.rules
            if hasattr(self, "rules")
            else None
        )
        _passive_profile=(
            self.passive_profile
            if hasattr(self, "passive_profile")
            else None
        )
        _passive_rules=(
            self.passive_rules
            if hasattr(self, "passive_rules")
            else None
        )
        _score=(
            self.score
            if hasattr(self, "score")
            else None
        )
        _local_time=(
            self.local_time
            if hasattr(self, "local_time")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"profile={_profile!s}, "
            f"rules={_rules!s}, "
            f"passive_profile={_passive_profile!s}, "
            f"passive_rules={_passive_rules!s}, "
            f"score={_score!s}, "
            f"local_time={_local_time!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
