"""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 PurchaseGiftCardResponse(object):
    """Implementation of the 'PurchaseGiftCardResponse' model.

    Attributes:
        barcode_id (str): The barcode ID assigned to the purchased gift card.
        value (float): The monetary value of the gift card.
        amount_paid (float): The amount paid for the gift card by the purchaser.
        from_name (str): The name of the purchaser.
        layout_id (int): The ID of the layout used for this gift card.
        email_receipt (bool): Whether or not an email receipt was sent to the
            purchaser. If true, a receipt was sent.
        purchaser_client_id (str): The client ID of the purchaser.
        purchaser_email (str): The purchaser’s email address.
        recipient_email (str): The recipient’s email address.
        sale_id (int): The sale ID of the gift card.
        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 = {
        "barcode_id": "BarcodeId",
        "value": "Value",
        "amount_paid": "AmountPaid",
        "from_name": "FromName",
        "layout_id": "LayoutId",
        "email_receipt": "EmailReceipt",
        "purchaser_client_id": "PurchaserClientId",
        "purchaser_email": "PurchaserEmail",
        "recipient_email": "RecipientEmail",
        "sale_id": "SaleId",
        "payment_processing_failures": "PaymentProcessingFailures",
    }

    _optionals = [
        "barcode_id",
        "value",
        "amount_paid",
        "from_name",
        "layout_id",
        "email_receipt",
        "purchaser_client_id",
        "purchaser_email",
        "recipient_email",
        "sale_id",
        "payment_processing_failures",
    ]

    def __init__(
        self,
        barcode_id=APIHelper.SKIP,
        value=APIHelper.SKIP,
        amount_paid=APIHelper.SKIP,
        from_name=APIHelper.SKIP,
        layout_id=APIHelper.SKIP,
        email_receipt=APIHelper.SKIP,
        purchaser_client_id=APIHelper.SKIP,
        purchaser_email=APIHelper.SKIP,
        recipient_email=APIHelper.SKIP,
        sale_id=APIHelper.SKIP,
        payment_processing_failures=APIHelper.SKIP):
        """Initialize a PurchaseGiftCardResponse instance."""
        # Initialize members of the class
        if barcode_id is not APIHelper.SKIP:
            self.barcode_id = barcode_id
        if value is not APIHelper.SKIP:
            self.value = value
        if amount_paid is not APIHelper.SKIP:
            self.amount_paid = amount_paid
        if from_name is not APIHelper.SKIP:
            self.from_name = from_name
        if layout_id is not APIHelper.SKIP:
            self.layout_id = layout_id
        if email_receipt is not APIHelper.SKIP:
            self.email_receipt = email_receipt
        if purchaser_client_id is not APIHelper.SKIP:
            self.purchaser_client_id = purchaser_client_id
        if purchaser_email is not APIHelper.SKIP:
            self.purchaser_email = purchaser_email
        if recipient_email is not APIHelper.SKIP:
            self.recipient_email = recipient_email
        if sale_id is not APIHelper.SKIP:
            self.sale_id = sale_id
        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
        barcode_id =\
            dictionary.get("BarcodeId")\
            if dictionary.get("BarcodeId")\
                else APIHelper.SKIP
        value =\
            dictionary.get("Value")\
            if dictionary.get("Value")\
                else APIHelper.SKIP
        amount_paid =\
            dictionary.get("AmountPaid")\
            if dictionary.get("AmountPaid")\
                else APIHelper.SKIP
        from_name =\
            dictionary.get("FromName")\
            if dictionary.get("FromName")\
                else APIHelper.SKIP
        layout_id =\
            dictionary.get("LayoutId")\
            if dictionary.get("LayoutId")\
                else APIHelper.SKIP
        email_receipt =\
            dictionary.get("EmailReceipt")\
            if "EmailReceipt" in dictionary.keys()\
                else APIHelper.SKIP
        purchaser_client_id =\
            dictionary.get("PurchaserClientId")\
            if dictionary.get("PurchaserClientId")\
                else APIHelper.SKIP
        purchaser_email =\
            dictionary.get("PurchaserEmail")\
            if dictionary.get("PurchaserEmail")\
                else APIHelper.SKIP
        recipient_email =\
            dictionary.get("RecipientEmail")\
            if dictionary.get("RecipientEmail")\
                else APIHelper.SKIP
        sale_id =\
            dictionary.get("SaleId")\
            if dictionary.get("SaleId")\
                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(barcode_id,
                   value,
                   amount_paid,
                   from_name,
                   layout_id,
                   email_receipt,
                   purchaser_client_id,
                   purchaser_email,
                   recipient_email,
                   sale_id,
                   payment_processing_failures)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _barcode_id=(
            self.barcode_id
            if hasattr(self, "barcode_id")
            else None
        )
        _value=(
            self.value
            if hasattr(self, "value")
            else None
        )
        _amount_paid=(
            self.amount_paid
            if hasattr(self, "amount_paid")
            else None
        )
        _from_name=(
            self.from_name
            if hasattr(self, "from_name")
            else None
        )
        _layout_id=(
            self.layout_id
            if hasattr(self, "layout_id")
            else None
        )
        _email_receipt=(
            self.email_receipt
            if hasattr(self, "email_receipt")
            else None
        )
        _purchaser_client_id=(
            self.purchaser_client_id
            if hasattr(self, "purchaser_client_id")
            else None
        )
        _purchaser_email=(
            self.purchaser_email
            if hasattr(self, "purchaser_email")
            else None
        )
        _recipient_email=(
            self.recipient_email
            if hasattr(self, "recipient_email")
            else None
        )
        _sale_id=(
            self.sale_id
            if hasattr(self, "sale_id")
            else None
        )
        _payment_processing_failures=(
            self.payment_processing_failures
            if hasattr(self, "payment_processing_failures")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"barcode_id={_barcode_id!r}, "
            f"value={_value!r}, "
            f"amount_paid={_amount_paid!r}, "
            f"from_name={_from_name!r}, "
            f"layout_id={_layout_id!r}, "
            f"email_receipt={_email_receipt!r}, "
            f"purchaser_client_id={_purchaser_client_id!r}, "
            f"purchaser_email={_purchaser_email!r}, "
            f"recipient_email={_recipient_email!r}, "
            f"sale_id={_sale_id!r}, "
            f"payment_processing_failures={_payment_processing_failures!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _barcode_id=(
            self.barcode_id
            if hasattr(self, "barcode_id")
            else None
        )
        _value=(
            self.value
            if hasattr(self, "value")
            else None
        )
        _amount_paid=(
            self.amount_paid
            if hasattr(self, "amount_paid")
            else None
        )
        _from_name=(
            self.from_name
            if hasattr(self, "from_name")
            else None
        )
        _layout_id=(
            self.layout_id
            if hasattr(self, "layout_id")
            else None
        )
        _email_receipt=(
            self.email_receipt
            if hasattr(self, "email_receipt")
            else None
        )
        _purchaser_client_id=(
            self.purchaser_client_id
            if hasattr(self, "purchaser_client_id")
            else None
        )
        _purchaser_email=(
            self.purchaser_email
            if hasattr(self, "purchaser_email")
            else None
        )
        _recipient_email=(
            self.recipient_email
            if hasattr(self, "recipient_email")
            else None
        )
        _sale_id=(
            self.sale_id
            if hasattr(self, "sale_id")
            else None
        )
        _payment_processing_failures=(
            self.payment_processing_failures
            if hasattr(self, "payment_processing_failures")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"barcode_id={_barcode_id!s}, "
            f"value={_value!s}, "
            f"amount_paid={_amount_paid!s}, "
            f"from_name={_from_name!s}, "
            f"layout_id={_layout_id!s}, "
            f"email_receipt={_email_receipt!s}, "
            f"purchaser_client_id={_purchaser_client_id!s}, "
            f"purchaser_email={_purchaser_email!s}, "
            f"recipient_email={_recipient_email!s}, "
            f"sale_id={_sale_id!s}, "
            f"payment_processing_failures={_payment_processing_failures!s}, "
            f")"
        )
