"""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.account_history import (
    AccountHistory,
)
from visaacceptancemergedspec.models.customer_account import (
    CustomerAccount,
)


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

    Attributes:
        customer_account (CustomerAccount): The model property of type
            CustomerAccount.
        account_history (AccountHistory): The model property of type AccountHistory.
        account_purchases (int): Number of purchases with this cardholder account
            during the previous six months. Recommended for Discover ProtectBuy.
        add_card_attempts (int): Number of add card attempts in the last 24 hours.
            Recommended for Discover ProtectBuy.
        prior_suspicious_activity (bool): Indicates whether the merchant experienced
            suspicious activity (including previous fraud) on the account.
            Recommended for Discover ProtectBuy.
        payment_account_history (str): This only applies for NEW_ACCOUNT and
            EXISTING_ACCOUNT in creationHistory. Possible values are: -
            PAYMENT_ACCOUNT_EXISTS - PAYMENT_ACCOUNT_ADDED_NOW
        payment_account_date (int): Date applicable only for PAYMENT_ACCOUNT_EXISTS
            in paymentAccountHistory
        transaction_count_day (int): Number of transaction (successful or abandoned)
            for this cardholder account within the last 24 hours. Recommended for
            Discover ProtectBuy.
        transaction_count_year (int): Number of transaction (successful or abandoned)
            for this cardholder account within the last year. Recommended for
            Discover ProtectBuy.
        additional_properties (Dict[str, Any]): The additional properties for the
            model.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "customer_account": "customerAccount",
        "account_history": "accountHistory",
        "account_purchases": "accountPurchases",
        "add_card_attempts": "addCardAttempts",
        "prior_suspicious_activity": "priorSuspiciousActivity",
        "payment_account_history": "paymentAccountHistory",
        "payment_account_date": "paymentAccountDate",
        "transaction_count_day": "transactionCountDay",
        "transaction_count_year": "transactionCountYear",
    }

    _optionals = [
        "customer_account",
        "account_history",
        "account_purchases",
        "add_card_attempts",
        "prior_suspicious_activity",
        "payment_account_history",
        "payment_account_date",
        "transaction_count_day",
        "transaction_count_year",
    ]

    def __init__(
        self,
        customer_account=APIHelper.SKIP,
        account_history=APIHelper.SKIP,
        account_purchases=APIHelper.SKIP,
        add_card_attempts=APIHelper.SKIP,
        prior_suspicious_activity=APIHelper.SKIP,
        payment_account_history=APIHelper.SKIP,
        payment_account_date=APIHelper.SKIP,
        transaction_count_day=APIHelper.SKIP,
        transaction_count_year=APIHelper.SKIP,
        additional_properties=None):
        """Initialize a BuyerHistory instance."""
        # Initialize members of the class
        if customer_account is not APIHelper.SKIP:
            self.customer_account = customer_account
        if account_history is not APIHelper.SKIP:
            self.account_history = account_history
        if account_purchases is not APIHelper.SKIP:
            self.account_purchases = account_purchases
        if add_card_attempts is not APIHelper.SKIP:
            self.add_card_attempts = add_card_attempts
        if prior_suspicious_activity is not APIHelper.SKIP:
            self.prior_suspicious_activity = prior_suspicious_activity
        if payment_account_history is not APIHelper.SKIP:
            self.payment_account_history = payment_account_history
        if payment_account_date is not APIHelper.SKIP:
            self.payment_account_date = payment_account_date
        if transaction_count_day is not APIHelper.SKIP:
            self.transaction_count_day = transaction_count_day
        if transaction_count_year is not APIHelper.SKIP:
            self.transaction_count_year = transaction_count_year

        # 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
        customer_account =\
            CustomerAccount.from_dictionary(
                dictionary.get("customerAccount"))\
                if "customerAccount" in dictionary.keys()\
                else APIHelper.SKIP
        account_history =\
            AccountHistory.from_dictionary(
                dictionary.get("accountHistory"))\
                if "accountHistory" in dictionary.keys()\
                else APIHelper.SKIP
        account_purchases =\
            dictionary.get("accountPurchases")\
            if dictionary.get("accountPurchases")\
                else APIHelper.SKIP
        add_card_attempts =\
            dictionary.get("addCardAttempts")\
            if dictionary.get("addCardAttempts")\
                else APIHelper.SKIP
        prior_suspicious_activity =\
            dictionary.get("priorSuspiciousActivity")\
            if "priorSuspiciousActivity" in dictionary.keys()\
                else APIHelper.SKIP
        payment_account_history =\
            dictionary.get("paymentAccountHistory")\
            if dictionary.get("paymentAccountHistory")\
                else APIHelper.SKIP
        payment_account_date =\
            dictionary.get("paymentAccountDate")\
            if dictionary.get("paymentAccountDate")\
                else APIHelper.SKIP
        transaction_count_day =\
            dictionary.get("transactionCountDay")\
            if dictionary.get("transactionCountDay")\
                else APIHelper.SKIP
        transaction_count_year =\
            dictionary.get("transactionCountYear")\
            if dictionary.get("transactionCountYear")\
                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(customer_account,
                   account_history,
                   account_purchases,
                   add_card_attempts,
                   prior_suspicious_activity,
                   payment_account_history,
                   payment_account_date,
                   transaction_count_day,
                   transaction_count_year,
                   additional_properties)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _customer_account=(
            self.customer_account
            if hasattr(self, "customer_account")
            else None
        )
        _account_history=(
            self.account_history
            if hasattr(self, "account_history")
            else None
        )
        _account_purchases=(
            self.account_purchases
            if hasattr(self, "account_purchases")
            else None
        )
        _add_card_attempts=(
            self.add_card_attempts
            if hasattr(self, "add_card_attempts")
            else None
        )
        _prior_suspicious_activity=(
            self.prior_suspicious_activity
            if hasattr(self, "prior_suspicious_activity")
            else None
        )
        _payment_account_history=(
            self.payment_account_history
            if hasattr(self, "payment_account_history")
            else None
        )
        _payment_account_date=(
            self.payment_account_date
            if hasattr(self, "payment_account_date")
            else None
        )
        _transaction_count_day=(
            self.transaction_count_day
            if hasattr(self, "transaction_count_day")
            else None
        )
        _transaction_count_year=(
            self.transaction_count_year
            if hasattr(self, "transaction_count_year")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"customer_account={_customer_account!r}, "
            f"account_history={_account_history!r}, "
            f"account_purchases={_account_purchases!r}, "
            f"add_card_attempts={_add_card_attempts!r}, "
            f"prior_suspicious_activity={_prior_suspicious_activity!r}, "
            f"payment_account_history={_payment_account_history!r}, "
            f"payment_account_date={_payment_account_date!r}, "
            f"transaction_count_day={_transaction_count_day!r}, "
            f"transaction_count_year={_transaction_count_year!r}, "
            f"additional_properties={_additional_properties!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _customer_account=(
            self.customer_account
            if hasattr(self, "customer_account")
            else None
        )
        _account_history=(
            self.account_history
            if hasattr(self, "account_history")
            else None
        )
        _account_purchases=(
            self.account_purchases
            if hasattr(self, "account_purchases")
            else None
        )
        _add_card_attempts=(
            self.add_card_attempts
            if hasattr(self, "add_card_attempts")
            else None
        )
        _prior_suspicious_activity=(
            self.prior_suspicious_activity
            if hasattr(self, "prior_suspicious_activity")
            else None
        )
        _payment_account_history=(
            self.payment_account_history
            if hasattr(self, "payment_account_history")
            else None
        )
        _payment_account_date=(
            self.payment_account_date
            if hasattr(self, "payment_account_date")
            else None
        )
        _transaction_count_day=(
            self.transaction_count_day
            if hasattr(self, "transaction_count_day")
            else None
        )
        _transaction_count_year=(
            self.transaction_count_year
            if hasattr(self, "transaction_count_year")
            else None
        )
        _additional_properties=self.additional_properties
        return (
            f"{self.__class__.__name__}("
            f"customer_account={_customer_account!s}, "
            f"account_history={_account_history!s}, "
            f"account_purchases={_account_purchases!s}, "
            f"add_card_attempts={_add_card_attempts!s}, "
            f"prior_suspicious_activity={_prior_suspicious_activity!s}, "
            f"payment_account_history={_payment_account_history!s}, "
            f"payment_account_date={_payment_account_date!s}, "
            f"transaction_count_day={_transaction_count_day!s}, "
            f"transaction_count_year={_transaction_count_year!s}, "
            f"additional_properties={_additional_properties!s}, "
            f")"
        )
