"""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.credit_card_info import (
    CreditCardInfo,
)
from mindbodypublicapi.models.stored_card_info import (
    StoredCardInfo,
)


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

    Attributes:
        test (bool): When `true`, the Public API validates input information, but
            does not commit it, so no client data is affected.<br />  When `false` or
            omitted, the transaction is committed, and client data is affected.<br />
            Default: **false**
        location_id (int): The ID of the location where the client is purchasing the
            contract; used for AutoPays.
        client_id (str): The ID of the client. Note that this is not the same as the
            client’s unique ID.
        unique_client_id (int): The unique ID of the client.  Note: you need to
            provide the 'UniqueClientId' OR the 'ClientId'. If both are provided, the
            'UniqueClientId' takes precedence.
        contract_id (int): The ID of the contract being purchased.
        start_date (datetime): The date that the contract starts.<br />  Default:
            **today’s date**
        first_payment_occurs (str): The date on which the first payment is to occur.
            Possible values:  * Instant  * `StartDate`
        client_signature (str): A representation of the client’s signature. This
            value can take the form of Base64-encoded byte array. The file type
            should be PNG. The picture of the client’s signature is uploaded and
            viewable from the Client Documents page in the Core Business Mode
            software. The title of the document is:<br />
            clientContractSignature-{uniquePurchasedClientContractID}-{contractName}-{
            contractStartDate}.{fileType}
        promotion_code (str): A promotion code, if one applies. Promotion codes are
            applied to items that are both marked as pay now in a contract and are
            discounted by the promotion code. If a pay now item is an autopay item,
            its autopay price is the price at the time of checkout, so, if a
            promotion code was applied, all autopays are scheduled using that
            discounted price.
        promotion_codes (List[str]): Promotion codes, if they apply. Promotion codes
            are applied to items that are both marked as pay now in a contract and
            are discounted by the promotion code. If a pay now item is an autopay
            item, its autopay price is the price at the time of checkout, so, if a
            promotion code was applied, all autopays are scheduled using that
            discounted price.
        credit_card_info (CreditCardInfo): Information about an individual credit card
        stored_card_info (StoredCardInfo): The model property of type StoredCardInfo.
        send_notifications (bool): When `true`, indicates that email and SMS
            notifications should be sent to the client after purchase.<br />
            Default: **true**
        sales_rep_id (int): The ID of the staff member to be marked as the sales rep
            for this contract sale.
        use_direct_debit (bool): When `true`, indicates that the direct debit
            information stored on the client's account is to be used to pay for the
            contract.<br />  This is only required if both `CreditCardInfo` and
            `StoredCardInfo` are not passed and `UseAccountCredit` is false.<br />
            Default: **false**
        use_account_credit (bool): When `true`, indicates that the account credit of
            the client's account is to be used to pay for the contract.<br />  This
            is only required if both `CreditCardInfo` and `StoredCardInfo` are not
            passed and `UseDirectDebit` is false. <br />  Default: **false**
        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**.
        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.
        prorate_date (datetime): Optional, date to prorate contract

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "contract_id": "ContractId",
        "test": "Test",
        "location_id": "LocationId",
        "client_id": "ClientId",
        "unique_client_id": "UniqueClientId",
        "start_date": "StartDate",
        "first_payment_occurs": "FirstPaymentOccurs",
        "client_signature": "ClientSignature",
        "promotion_code": "PromotionCode",
        "promotion_codes": "PromotionCodes",
        "credit_card_info": "CreditCardInfo",
        "stored_card_info": "StoredCardInfo",
        "send_notifications": "SendNotifications",
        "sales_rep_id": "SalesRepId",
        "use_direct_debit": "UseDirectDebit",
        "use_account_credit": "UseAccountCredit",
        "consumer_present": "ConsumerPresent",
        "payment_authentication_callback_url": "PaymentAuthenticationCallbackUrl",
        "prorate_date": "ProrateDate",
    }

    _optionals = [
        "test",
        "location_id",
        "client_id",
        "unique_client_id",
        "start_date",
        "first_payment_occurs",
        "client_signature",
        "promotion_code",
        "promotion_codes",
        "credit_card_info",
        "stored_card_info",
        "send_notifications",
        "sales_rep_id",
        "use_direct_debit",
        "use_account_credit",
        "consumer_present",
        "payment_authentication_callback_url",
        "prorate_date",
    ]

    def __init__(
        self,
        contract_id=None,
        test=APIHelper.SKIP,
        location_id=APIHelper.SKIP,
        client_id=APIHelper.SKIP,
        unique_client_id=APIHelper.SKIP,
        start_date=APIHelper.SKIP,
        first_payment_occurs=APIHelper.SKIP,
        client_signature=APIHelper.SKIP,
        promotion_code=APIHelper.SKIP,
        promotion_codes=APIHelper.SKIP,
        credit_card_info=APIHelper.SKIP,
        stored_card_info=APIHelper.SKIP,
        send_notifications=APIHelper.SKIP,
        sales_rep_id=APIHelper.SKIP,
        use_direct_debit=APIHelper.SKIP,
        use_account_credit=APIHelper.SKIP,
        consumer_present=APIHelper.SKIP,
        payment_authentication_callback_url=APIHelper.SKIP,
        prorate_date=APIHelper.SKIP):
        """Initialize a PurchaseContractRequest 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
        if client_id is not APIHelper.SKIP:
            self.client_id = client_id
        if unique_client_id is not APIHelper.SKIP:
            self.unique_client_id = unique_client_id
        self.contract_id = contract_id
        if start_date is not APIHelper.SKIP:
            self.start_date =\
                 APIHelper.apply_datetime_converter(
                start_date, APIHelper.RFC3339DateTime)\
                 if start_date else None
        if first_payment_occurs is not APIHelper.SKIP:
            self.first_payment_occurs = first_payment_occurs
        if client_signature is not APIHelper.SKIP:
            self.client_signature = client_signature
        if promotion_code is not APIHelper.SKIP:
            self.promotion_code = promotion_code
        if promotion_codes is not APIHelper.SKIP:
            self.promotion_codes = promotion_codes
        if credit_card_info is not APIHelper.SKIP:
            self.credit_card_info = credit_card_info
        if stored_card_info is not APIHelper.SKIP:
            self.stored_card_info = stored_card_info
        if send_notifications is not APIHelper.SKIP:
            self.send_notifications = send_notifications
        if sales_rep_id is not APIHelper.SKIP:
            self.sales_rep_id = sales_rep_id
        if use_direct_debit is not APIHelper.SKIP:
            self.use_direct_debit = use_direct_debit
        if use_account_credit is not APIHelper.SKIP:
            self.use_account_credit = use_account_credit
        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 prorate_date is not APIHelper.SKIP:
            self.prorate_date =\
                 APIHelper.apply_datetime_converter(
                prorate_date, APIHelper.RFC3339DateTime)\
                 if prorate_date else None

    @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
        contract_id =\
            dictionary.get("ContractId")\
            if dictionary.get("ContractId")\
                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
        client_id =\
            dictionary.get("ClientId")\
            if dictionary.get("ClientId")\
                else APIHelper.SKIP
        unique_client_id =\
            dictionary.get("UniqueClientId")\
            if dictionary.get("UniqueClientId")\
                else APIHelper.SKIP
        start_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("StartDate")).datetime\
            if dictionary.get("StartDate") else APIHelper.SKIP
        first_payment_occurs =\
            dictionary.get("FirstPaymentOccurs")\
            if dictionary.get("FirstPaymentOccurs")\
                else APIHelper.SKIP
        client_signature =\
            dictionary.get("ClientSignature")\
            if dictionary.get("ClientSignature")\
                else APIHelper.SKIP
        promotion_code =\
            dictionary.get("PromotionCode")\
            if dictionary.get("PromotionCode")\
                else APIHelper.SKIP
        promotion_codes =\
            dictionary.get("PromotionCodes")\
            if dictionary.get("PromotionCodes")\
                else APIHelper.SKIP
        credit_card_info =\
            CreditCardInfo.from_dictionary(
                dictionary.get("CreditCardInfo"))\
                if "CreditCardInfo" in dictionary.keys()\
                else APIHelper.SKIP
        stored_card_info =\
            StoredCardInfo.from_dictionary(
                dictionary.get("StoredCardInfo"))\
                if "StoredCardInfo" in dictionary.keys()\
                else APIHelper.SKIP
        send_notifications =\
            dictionary.get("SendNotifications")\
            if "SendNotifications" in dictionary.keys()\
                else APIHelper.SKIP
        sales_rep_id =\
            dictionary.get("SalesRepId")\
            if dictionary.get("SalesRepId")\
                else APIHelper.SKIP
        use_direct_debit =\
            dictionary.get("UseDirectDebit")\
            if "UseDirectDebit" in dictionary.keys()\
                else APIHelper.SKIP
        use_account_credit =\
            dictionary.get("UseAccountCredit")\
            if "UseAccountCredit" in dictionary.keys()\
                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
        prorate_date = APIHelper.RFC3339DateTime.from_value(
            dictionary.get("ProrateDate")).datetime\
            if dictionary.get("ProrateDate") else APIHelper.SKIP

        # Return an object of this model
        return cls(contract_id,
                   test,
                   location_id,
                   client_id,
                   unique_client_id,
                   start_date,
                   first_payment_occurs,
                   client_signature,
                   promotion_code,
                   promotion_codes,
                   credit_card_info,
                   stored_card_info,
                   send_notifications,
                   sales_rep_id,
                   use_direct_debit,
                   use_account_credit,
                   consumer_present,
                   payment_authentication_callback_url,
                   prorate_date)

    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
            if hasattr(self, "client_id")
            else None
        )
        _unique_client_id=(
            self.unique_client_id
            if hasattr(self, "unique_client_id")
            else None
        )
        _contract_id=self.contract_id
        _start_date=(
            self.start_date
            if hasattr(self, "start_date")
            else None
        )
        _first_payment_occurs=(
            self.first_payment_occurs
            if hasattr(self, "first_payment_occurs")
            else None
        )
        _client_signature=(
            self.client_signature
            if hasattr(self, "client_signature")
            else None
        )
        _promotion_code=(
            self.promotion_code
            if hasattr(self, "promotion_code")
            else None
        )
        _promotion_codes=(
            self.promotion_codes
            if hasattr(self, "promotion_codes")
            else None
        )
        _credit_card_info=(
            self.credit_card_info
            if hasattr(self, "credit_card_info")
            else None
        )
        _stored_card_info=(
            self.stored_card_info
            if hasattr(self, "stored_card_info")
            else None
        )
        _send_notifications=(
            self.send_notifications
            if hasattr(self, "send_notifications")
            else None
        )
        _sales_rep_id=(
            self.sales_rep_id
            if hasattr(self, "sales_rep_id")
            else None
        )
        _use_direct_debit=(
            self.use_direct_debit
            if hasattr(self, "use_direct_debit")
            else None
        )
        _use_account_credit=(
            self.use_account_credit
            if hasattr(self, "use_account_credit")
            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
        )
        _prorate_date=(
            self.prorate_date
            if hasattr(self, "prorate_date")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"test={_test!r}, "
            f"location_id={_location_id!r}, "
            f"client_id={_client_id!r}, "
            f"unique_client_id={_unique_client_id!r}, "
            f"contract_id={_contract_id!r}, "
            f"start_date={_start_date!r}, "
            f"first_payment_occurs={_first_payment_occurs!r}, "
            f"client_signature={_client_signature!r}, "
            f"promotion_code={_promotion_code!r}, "
            f"promotion_codes={_promotion_codes!r}, "
            f"credit_card_info={_credit_card_info!r}, "
            f"stored_card_info={_stored_card_info!r}, "
            f"send_notifications={_send_notifications!r}, "
            f"sales_rep_id={_sales_rep_id!r}, "
            f"use_direct_debit={_use_direct_debit!r}, "
            f"use_account_credit={_use_account_credit!r}, "
            f"consumer_present={_consumer_present!r}, "
            f"payment_authentication_callback_url={_payment_authentication_callback_url!r}, "
            f"prorate_date={_prorate_date!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
            if hasattr(self, "client_id")
            else None
        )
        _unique_client_id=(
            self.unique_client_id
            if hasattr(self, "unique_client_id")
            else None
        )
        _contract_id=self.contract_id
        _start_date=(
            self.start_date
            if hasattr(self, "start_date")
            else None
        )
        _first_payment_occurs=(
            self.first_payment_occurs
            if hasattr(self, "first_payment_occurs")
            else None
        )
        _client_signature=(
            self.client_signature
            if hasattr(self, "client_signature")
            else None
        )
        _promotion_code=(
            self.promotion_code
            if hasattr(self, "promotion_code")
            else None
        )
        _promotion_codes=(
            self.promotion_codes
            if hasattr(self, "promotion_codes")
            else None
        )
        _credit_card_info=(
            self.credit_card_info
            if hasattr(self, "credit_card_info")
            else None
        )
        _stored_card_info=(
            self.stored_card_info
            if hasattr(self, "stored_card_info")
            else None
        )
        _send_notifications=(
            self.send_notifications
            if hasattr(self, "send_notifications")
            else None
        )
        _sales_rep_id=(
            self.sales_rep_id
            if hasattr(self, "sales_rep_id")
            else None
        )
        _use_direct_debit=(
            self.use_direct_debit
            if hasattr(self, "use_direct_debit")
            else None
        )
        _use_account_credit=(
            self.use_account_credit
            if hasattr(self, "use_account_credit")
            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
        )
        _prorate_date=(
            self.prorate_date
            if hasattr(self, "prorate_date")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"test={_test!s}, "
            f"location_id={_location_id!s}, "
            f"client_id={_client_id!s}, "
            f"unique_client_id={_unique_client_id!s}, "
            f"contract_id={_contract_id!s}, "
            f"start_date={_start_date!s}, "
            f"first_payment_occurs={_first_payment_occurs!s}, "
            f"client_signature={_client_signature!s}, "
            f"promotion_code={_promotion_code!s}, "
            f"promotion_codes={_promotion_codes!s}, "
            f"credit_card_info={_credit_card_info!s}, "
            f"stored_card_info={_stored_card_info!s}, "
            f"send_notifications={_send_notifications!s}, "
            f"sales_rep_id={_sales_rep_id!s}, "
            f"use_direct_debit={_use_direct_debit!s}, "
            f"use_account_credit={_use_account_credit!s}, "
            f"consumer_present={_consumer_present!s}, "
            f"payment_authentication_callback_url={_payment_authentication_callback_url!s}, "
            f"prorate_date={_prorate_date!s}, "
            f")"
        )
