"""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.provider import Provider


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

    Assessment of if the transaction chance of fraud is considered acceptable or not.

    Attributes:
        mtype (Type3): Type of fraud assessment being performed.  Options:    <table>
            <thead>       <tr>         <th>Type</th>         <th>Description</th>
            </tr>     </thead>     <tbody>       <tr>
            <td>PRE_AUTHORIZATION</td>         <td>Assessment is performed before
            authorization.</td>       </tr>       <tr>
            <td>POST_AUTHORIZATION</td>         <td>Assessment is performed after
            authorization.</td>       </tr>     </tbody>   </table>
        status (Status1): The status of the fraud assessment.
        created_at (datetime): When the fraud assessment was created.
        reviewed_at (datetime): When the fraud assessment was reviewed.
        provider (Provider): Provider that performed the fraud assessment.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "mtype": "type",
        "status": "status",
        "created_at": "createdAt",
        "reviewed_at": "reviewedAt",
        "provider": "provider",
    }

    _optionals = [
        "mtype",
        "status",
        "created_at",
        "reviewed_at",
        "provider",
    ]

    def __init__(
        self,
        mtype=APIHelper.SKIP,
        status=APIHelper.SKIP,
        created_at=APIHelper.SKIP,
        reviewed_at=APIHelper.SKIP,
        provider=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a FraudAssessment instance."""
        # Initialize members of the class
        if mtype is not APIHelper.SKIP:
            self.mtype = mtype
        if status is not APIHelper.SKIP:
            self.status = status
        if created_at is not APIHelper.SKIP:
            self.created_at =\
                 APIHelper.apply_datetime_converter(
                created_at, APIHelper.RFC3339DateTime)\
                 if created_at else None
        if reviewed_at is not APIHelper.SKIP:
            self.reviewed_at =\
                 APIHelper.apply_datetime_converter(
                reviewed_at, APIHelper.RFC3339DateTime)\
                 if reviewed_at else None
        if provider is not APIHelper.SKIP:
            self.provider = provider

        # 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
        mtype =\
            dictionary.get("type")\
            if dictionary.get("type")\
                else APIHelper.SKIP
        status =\
            dictionary.get("status")\
            if dictionary.get("status")\
                else APIHelper.SKIP
        created_at = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("createdAt")).datetime\
            if dictionary.get("createdAt") else APIHelper.SKIP
        reviewed_at = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("reviewedAt")).datetime\
            if dictionary.get("reviewedAt") else APIHelper.SKIP
        provider =\
            Provider.from_dictionary(
                dictionary.get("provider"))\
                if "provider" in dictionary.keys()\
                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(mtype,
                   status,
                   created_at,
                   reviewed_at,
                   provider,
                   additional_properties)

    @classmethod
    def validate(cls, dictionary):
        """Validate dictionary against class required properties

        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:
            boolean : if dictionary is valid contains required properties.

        """
        if isinstance(dictionary, cls):
            return True

        if not isinstance(dictionary, dict):
            return False

        return True

    def __repr__(self):
        """Return a unambiguous string representation."""
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _status=(
            self.status
            if hasattr(self, "status")
            else None
        )
        _created_at=(
            self.created_at
            if hasattr(self, "created_at")
            else None
        )
        _reviewed_at=(
            self.reviewed_at
            if hasattr(self, "reviewed_at")
            else None
        )
        _provider=(
            self.provider
            if hasattr(self, "provider")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!r}, "
            f"status={_status!r}, "
            f"created_at={_created_at!r}, "
            f"reviewed_at={_reviewed_at!r}, "
            f"provider={_provider!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _mtype=(
            self.mtype
            if hasattr(self, "mtype")
            else None
        )
        _status=(
            self.status
            if hasattr(self, "status")
            else None
        )
        _created_at=(
            self.created_at
            if hasattr(self, "created_at")
            else None
        )
        _reviewed_at=(
            self.reviewed_at
            if hasattr(self, "reviewed_at")
            else None
        )
        _provider=(
            self.provider
            if hasattr(self, "provider")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"mtype={_mtype!s}, "
            f"status={_status!s}, "
            f"created_at={_created_at!s}, "
            f"reviewed_at={_reviewed_at!s}, "
            f"provider={_provider!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
