"""mindbodypublicapi.

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

# ruff: noqa: E501
from mindbodypublicapi.api_helper import APIHelper
from mindbodypublicapi.models.payment_processing_failure import (
    PaymentProcessingFailure,
)


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

    Attributes:
        amount_paid (float): The amount paid for the gift card by the purchaser.
        client_id (str): The client ID of the purchaser.
        sale_id (int): The sale ID of the gift card.
        email_receipt (bool): Whether or not an email receipt was sent to the
            purchaser. If true, a receipt was sent.
        payment_processing_failures (List[PaymentProcessingFailure]): Any cart
            processing failures, for example when SCA challenged, the cart is in
            PaymentAuthenticationRequired state and at least one of the failures
            listed will provide an authentication Url.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "amount_paid": "AmountPaid",
        "client_id": "ClientId",
        "sale_id": "SaleId",
        "email_receipt": "EmailReceipt",
        "payment_processing_failures": "PaymentProcessingFailures",
    }

    _optionals = [
        "amount_paid",
        "client_id",
        "sale_id",
        "email_receipt",
        "payment_processing_failures",
    ]

    def __init__(
        self,
        amount_paid=APIHelper.SKIP,
        client_id=APIHelper.SKIP,
        sale_id=APIHelper.SKIP,
        email_receipt=APIHelper.SKIP,
        payment_processing_failures=APIHelper.SKIP):
        """Initialize a PurchaseAccountCreditResponse instance."""
        # Initialize members of the class
        if amount_paid is not APIHelper.SKIP:
            self.amount_paid = amount_paid
        if client_id is not APIHelper.SKIP:
            self.client_id = client_id
        if sale_id is not APIHelper.SKIP:
            self.sale_id = sale_id
        if email_receipt is not APIHelper.SKIP:
            self.email_receipt = email_receipt
        if payment_processing_failures is not APIHelper.SKIP:
            self.payment_processing_failures = payment_processing_failures

    @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
        amount_paid =\
            dictionary.get("AmountPaid")\
            if dictionary.get("AmountPaid")\
                else APIHelper.SKIP
        client_id =\
            dictionary.get("ClientId")\
            if dictionary.get("ClientId")\
                else APIHelper.SKIP
        sale_id =\
            dictionary.get("SaleId")\
            if dictionary.get("SaleId")\
                else APIHelper.SKIP
        email_receipt =\
            dictionary.get("EmailReceipt")\
            if "EmailReceipt" in dictionary.keys()\
                else APIHelper.SKIP
        payment_processing_failures = None
        if dictionary.get("PaymentProcessingFailures") is not None:
            payment_processing_failures = [
                PaymentProcessingFailure.from_dictionary(x)
                    for x in dictionary.get("PaymentProcessingFailures")
            ]
        else:
            payment_processing_failures = APIHelper.SKIP

        # Return an object of this model
        return cls(amount_paid,
                   client_id,
                   sale_id,
                   email_receipt,
                   payment_processing_failures)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _amount_paid=(
            self.amount_paid
            if hasattr(self, "amount_paid")
            else None
        )
        _client_id=(
            self.client_id
            if hasattr(self, "client_id")
            else None
        )
        _sale_id=(
            self.sale_id
            if hasattr(self, "sale_id")
            else None
        )
        _email_receipt=(
            self.email_receipt
            if hasattr(self, "email_receipt")
            else None
        )
        _payment_processing_failures=(
            self.payment_processing_failures
            if hasattr(self, "payment_processing_failures")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"amount_paid={_amount_paid!r}, "
            f"client_id={_client_id!r}, "
            f"sale_id={_sale_id!r}, "
            f"email_receipt={_email_receipt!r}, "
            f"payment_processing_failures={_payment_processing_failures!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _amount_paid=(
            self.amount_paid
            if hasattr(self, "amount_paid")
            else None
        )
        _client_id=(
            self.client_id
            if hasattr(self, "client_id")
            else None
        )
        _sale_id=(
            self.sale_id
            if hasattr(self, "sale_id")
            else None
        )
        _email_receipt=(
            self.email_receipt
            if hasattr(self, "email_receipt")
            else None
        )
        _payment_processing_failures=(
            self.payment_processing_failures
            if hasattr(self, "payment_processing_failures")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"amount_paid={_amount_paid!s}, "
            f"client_id={_client_id!s}, "
            f"sale_id={_sale_id!s}, "
            f"email_receipt={_email_receipt!s}, "
            f"payment_processing_failures={_payment_processing_failures!s}, "
            f")"
        )
