"""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.checkout_payment_info import (
    CheckoutPaymentInfo,
)


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

    Attributes:
        test (bool): When `true`, allows you to test the request without affecting
            the database.  When `false`, the request is carried out and the database
            is affected.
        location_id (int): The ID of the location where the account credit is being
            sold.
        client_id (str): The ID of the location where the account credit is being
            sold.
        send_email_receipt (bool): When `true`, indicates that a purchase receipt
            email should be sent to the purchasing client, if all settings are
            correctly configured.<br />  When `false`, no email is sent to the
            purchaser.
        sales_rep_id (int): The ID of the staff member to be marked as the sales rep
            for this account credit sale.
        consumer_present (bool): When `true`, indicates that the consumer is present
            or otherwise able to successfully negotiate an SCA challenge.   It is not
            a good idea to have this always be false as that could very likely lead
            to a bank declining all transactions for the merchant. Defaults to false.
            Default: **false**
        payment_authentication_callback_url (str): The URL consumer is redirected to
            if the bank requests SCA. This field is only needed if ConsumerPresent is
            true.
        payment_info (CheckoutPaymentInfo): The model property of type
            CheckoutPaymentInfo.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "client_id": "ClientId",
        "test": "Test",
        "location_id": "LocationId",
        "send_email_receipt": "SendEmailReceipt",
        "sales_rep_id": "SalesRepId",
        "consumer_present": "ConsumerPresent",
        "payment_authentication_callback_url": "PaymentAuthenticationCallbackUrl",
        "payment_info": "PaymentInfo",
    }

    _optionals = [
        "test",
        "location_id",
        "send_email_receipt",
        "sales_rep_id",
        "consumer_present",
        "payment_authentication_callback_url",
        "payment_info",
    ]

    def __init__(
        self,
        client_id=None,
        test=APIHelper.SKIP,
        location_id=APIHelper.SKIP,
        send_email_receipt=APIHelper.SKIP,
        sales_rep_id=APIHelper.SKIP,
        consumer_present=APIHelper.SKIP,
        payment_authentication_callback_url=APIHelper.SKIP,
        payment_info=APIHelper.SKIP):
        """Initialize a PurchaseAccountCreditRequest instance."""
        # Initialize members of the class
        if test is not APIHelper.SKIP:
            self.test = test
        if location_id is not APIHelper.SKIP:
            self.location_id = location_id
        self.client_id = client_id
        if send_email_receipt is not APIHelper.SKIP:
            self.send_email_receipt = send_email_receipt
        if sales_rep_id is not APIHelper.SKIP:
            self.sales_rep_id = sales_rep_id
        if consumer_present is not APIHelper.SKIP:
            self.consumer_present = consumer_present
        if payment_authentication_callback_url is not APIHelper.SKIP:
            self.payment_authentication_callback_url =\
                 payment_authentication_callback_url
        if payment_info is not APIHelper.SKIP:
            self.payment_info = payment_info

    @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
        client_id =\
            dictionary.get("ClientId")\
            if dictionary.get("ClientId")\
                else None
        test =\
            dictionary.get("Test")\
            if "Test" in dictionary.keys()\
                else APIHelper.SKIP
        location_id =\
            dictionary.get("LocationId")\
            if dictionary.get("LocationId")\
                else APIHelper.SKIP
        send_email_receipt =\
            dictionary.get("SendEmailReceipt")\
            if "SendEmailReceipt" in dictionary.keys()\
                else APIHelper.SKIP
        sales_rep_id =\
            dictionary.get("SalesRepId")\
            if dictionary.get("SalesRepId")\
                else APIHelper.SKIP
        consumer_present =\
            dictionary.get("ConsumerPresent")\
            if "ConsumerPresent" in dictionary.keys()\
                else APIHelper.SKIP
        payment_authentication_callback_url =\
            dictionary.get("PaymentAuthenticationCallbackUrl")\
            if dictionary.get("PaymentAuthenticationCallbackUrl")\
                else APIHelper.SKIP
        payment_info =\
            CheckoutPaymentInfo.from_dictionary(
                dictionary.get("PaymentInfo"))\
                if "PaymentInfo" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(client_id,
                   test,
                   location_id,
                   send_email_receipt,
                   sales_rep_id,
                   consumer_present,
                   payment_authentication_callback_url,
                   payment_info)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _test=(
            self.test
            if hasattr(self, "test")
            else None
        )
        _location_id=(
            self.location_id
            if hasattr(self, "location_id")
            else None
        )
        _client_id=self.client_id
        _send_email_receipt=(
            self.send_email_receipt
            if hasattr(self, "send_email_receipt")
            else None
        )
        _sales_rep_id=(
            self.sales_rep_id
            if hasattr(self, "sales_rep_id")
            else None
        )
        _consumer_present=(
            self.consumer_present
            if hasattr(self, "consumer_present")
            else None
        )
        _payment_authentication_callback_url=(
            self.payment_authentication_callback_url
            if hasattr(self, "payment_authentication_callback_url")
            else None
        )
        _payment_info=(
            self.payment_info
            if hasattr(self, "payment_info")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"test={_test!r}, "
            f"location_id={_location_id!r}, "
            f"client_id={_client_id!r}, "
            f"send_email_receipt={_send_email_receipt!r}, "
            f"sales_rep_id={_sales_rep_id!r}, "
            f"consumer_present={_consumer_present!r}, "
            f"payment_authentication_callback_url={_payment_authentication_callback_url!r}, "
            f"payment_info={_payment_info!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _test=(
            self.test
            if hasattr(self, "test")
            else None
        )
        _location_id=(
            self.location_id
            if hasattr(self, "location_id")
            else None
        )
        _client_id=self.client_id
        _send_email_receipt=(
            self.send_email_receipt
            if hasattr(self, "send_email_receipt")
            else None
        )
        _sales_rep_id=(
            self.sales_rep_id
            if hasattr(self, "sales_rep_id")
            else None
        )
        _consumer_present=(
            self.consumer_present
            if hasattr(self, "consumer_present")
            else None
        )
        _payment_authentication_callback_url=(
            self.payment_authentication_callback_url
            if hasattr(self, "payment_authentication_callback_url")
            else None
        )
        _payment_info=(
            self.payment_info
            if hasattr(self, "payment_info")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"test={_test!s}, "
            f"location_id={_location_id!s}, "
            f"client_id={_client_id!s}, "
            f"send_email_receipt={_send_email_receipt!s}, "
            f"sales_rep_id={_sales_rep_id!s}, "
            f"consumer_present={_consumer_present!s}, "
            f"payment_authentication_callback_url={_payment_authentication_callback_url!s}, "
            f"payment_info={_payment_info!s}, "
            f")"
        )
