"""cellpointapi.

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

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


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

    Buyer's account history, used for fraud checks.

    Attributes:
        created_at (datetime): Date and time of when the account was created.
        email_modifed_at (datetime): Date and time of when the email on the account
            was last updated.
        email_verified_at (datetime): Date and time of when the email on the account
            was last verified.
        password_modified_at (datetime): Date and time of when the password on the
            account was last updated.
        password_history_type (PasswordChangeType): If the buyer has changed their
            password before and if it was recent or historical.
        purchases_past_day (int): Number of purchases made in the past day by this
            account.
        purchases_past_year (int): Number of purchases made in the past year by this
            account.
        purchases_total (int): Total number of purchases made during the lifetime of
            this account.
        refunds_total (int): Total number of refunds made during the lifetime of this
            account.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "created_at": "createdAt",
        "email_modifed_at": "emailModifedAt",
        "email_verified_at": "emailVerifiedAt",
        "password_modified_at": "passwordModifiedAt",
        "password_history_type": "passwordHistoryType",
        "purchases_past_day": "purchasesPastDay",
        "purchases_past_year": "purchasesPastYear",
        "purchases_total": "purchasesTotal",
        "refunds_total": "refundsTotal",
    }

    _optionals = [
        "created_at",
        "email_modifed_at",
        "email_verified_at",
        "password_modified_at",
        "password_history_type",
        "purchases_past_day",
        "purchases_past_year",
        "purchases_total",
        "refunds_total",
    ]

    def __init__(
        self,
        created_at=APIHelper.SKIP,
        email_modifed_at=APIHelper.SKIP,
        email_verified_at=APIHelper.SKIP,
        password_modified_at=APIHelper.SKIP,
        password_history_type=APIHelper.SKIP,
        purchases_past_day=APIHelper.SKIP,
        purchases_past_year=APIHelper.SKIP,
        purchases_total=APIHelper.SKIP,
        refunds_total=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a BuyerHistory instance."""
        # Initialize members of the class
        if created_at is not APIHelper.SKIP:
            self.created_at =\
                 APIHelper.apply_datetime_converter(
                created_at, APIHelper.RFC3339DateTime)\
                 if created_at else None
        if email_modifed_at is not APIHelper.SKIP:
            self.email_modifed_at =\
                 APIHelper.apply_datetime_converter(
                email_modifed_at, APIHelper.RFC3339DateTime)\
                 if email_modifed_at else None
        if email_verified_at is not APIHelper.SKIP:
            self.email_verified_at =\
                 APIHelper.apply_datetime_converter(
                email_verified_at, APIHelper.RFC3339DateTime)\
                 if email_verified_at else None
        if password_modified_at is not APIHelper.SKIP:
            self.password_modified_at =\
                 APIHelper.apply_datetime_converter(
                password_modified_at, APIHelper.RFC3339DateTime)\
                 if password_modified_at else None
        if password_history_type is not APIHelper.SKIP:
            self.password_history_type = password_history_type
        if purchases_past_day is not APIHelper.SKIP:
            self.purchases_past_day = purchases_past_day
        if purchases_past_year is not APIHelper.SKIP:
            self.purchases_past_year = purchases_past_year
        if purchases_total is not APIHelper.SKIP:
            self.purchases_total = purchases_total
        if refunds_total is not APIHelper.SKIP:
            self.refunds_total = refunds_total

        # 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
        created_at = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("createdAt")).datetime\
            if dictionary.get("createdAt") else APIHelper.SKIP
        email_modifed_at = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("emailModifedAt")).datetime\
            if dictionary.get("emailModifedAt") else APIHelper.SKIP
        email_verified_at = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("emailVerifiedAt")).datetime\
            if dictionary.get("emailVerifiedAt") else APIHelper.SKIP
        password_modified_at = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("passwordModifiedAt")).datetime\
            if dictionary.get("passwordModifiedAt") else APIHelper.SKIP
        password_history_type =\
            dictionary.get("passwordHistoryType")\
            if dictionary.get("passwordHistoryType")\
                else APIHelper.SKIP
        purchases_past_day =\
            dictionary.get("purchasesPastDay")\
            if dictionary.get("purchasesPastDay")\
                else APIHelper.SKIP
        purchases_past_year =\
            dictionary.get("purchasesPastYear")\
            if dictionary.get("purchasesPastYear")\
                else APIHelper.SKIP
        purchases_total =\
            dictionary.get("purchasesTotal")\
            if dictionary.get("purchasesTotal")\
                else APIHelper.SKIP
        refunds_total =\
            dictionary.get("refundsTotal")\
            if dictionary.get("refundsTotal")\
                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(created_at,
                   email_modifed_at,
                   email_verified_at,
                   password_modified_at,
                   password_history_type,
                   purchases_past_day,
                   purchases_past_year,
                   purchases_total,
                   refunds_total,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _created_at=(
            self.created_at
            if hasattr(self, "created_at")
            else None
        )
        _email_modifed_at=(
            self.email_modifed_at
            if hasattr(self, "email_modifed_at")
            else None
        )
        _email_verified_at=(
            self.email_verified_at
            if hasattr(self, "email_verified_at")
            else None
        )
        _password_modified_at=(
            self.password_modified_at
            if hasattr(self, "password_modified_at")
            else None
        )
        _password_history_type=(
            self.password_history_type
            if hasattr(self, "password_history_type")
            else None
        )
        _purchases_past_day=(
            self.purchases_past_day
            if hasattr(self, "purchases_past_day")
            else None
        )
        _purchases_past_year=(
            self.purchases_past_year
            if hasattr(self, "purchases_past_year")
            else None
        )
        _purchases_total=(
            self.purchases_total
            if hasattr(self, "purchases_total")
            else None
        )
        _refunds_total=(
            self.refunds_total
            if hasattr(self, "refunds_total")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"created_at={_created_at!r}, "
            f"email_modifed_at={_email_modifed_at!r}, "
            f"email_verified_at={_email_verified_at!r}, "
            f"password_modified_at={_password_modified_at!r}, "
            f"password_history_type={_password_history_type!r}, "
            f"purchases_past_day={_purchases_past_day!r}, "
            f"purchases_past_year={_purchases_past_year!r}, "
            f"purchases_total={_purchases_total!r}, "
            f"refunds_total={_refunds_total!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _created_at=(
            self.created_at
            if hasattr(self, "created_at")
            else None
        )
        _email_modifed_at=(
            self.email_modifed_at
            if hasattr(self, "email_modifed_at")
            else None
        )
        _email_verified_at=(
            self.email_verified_at
            if hasattr(self, "email_verified_at")
            else None
        )
        _password_modified_at=(
            self.password_modified_at
            if hasattr(self, "password_modified_at")
            else None
        )
        _password_history_type=(
            self.password_history_type
            if hasattr(self, "password_history_type")
            else None
        )
        _purchases_past_day=(
            self.purchases_past_day
            if hasattr(self, "purchases_past_day")
            else None
        )
        _purchases_past_year=(
            self.purchases_past_year
            if hasattr(self, "purchases_past_year")
            else None
        )
        _purchases_total=(
            self.purchases_total
            if hasattr(self, "purchases_total")
            else None
        )
        _refunds_total=(
            self.refunds_total
            if hasattr(self, "refunds_total")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"created_at={_created_at!s}, "
            f"email_modifed_at={_email_modifed_at!s}, "
            f"email_verified_at={_email_verified_at!s}, "
            f"password_modified_at={_password_modified_at!s}, "
            f"password_history_type={_password_history_type!s}, "
            f"purchases_past_day={_purchases_past_day!s}, "
            f"purchases_past_year={_purchases_past_year!s}, "
            f"purchases_total={_purchases_total!s}, "
            f"refunds_total={_refunds_total!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
