"""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_item_wrapper import (
    CheckoutItemWrapper,
)
from mindbodypublicapi.models.checkout_payment_info import (
    CheckoutPaymentInfo,
)


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

    Attributes:
        cart_id (str): The unique ID of the shopping cart to be processed. You can
            use this value to maintain a persistent cart. If you do not specify a
            cart ID, the MINDBODY software generates one.
        client_id (str): The RSSID of the client making the purchase. A 'ClientId' OR
            'UniqueClientId' must be specified to complete a sale.
        unique_client_id (int): The UniqueId of the client making the purchase. A
            'ClientId' OR 'UniqueClientId' must be specified to complete a sale.
            Note: you need to provide the 'UniqueClientId' OR the 'ClientId'. If both
            are provided, the 'UniqueClientId' takes precedence.
        payer_client_id (str): The RSSID of the client paying for the purchase. This
            client needs to have a relationship of type "Pays for" with the client
            specified in the 'ClientId' or 'UniqueClientId' fields.
        unique_payer_client_id (int): The UniqueId of the client paying for the
            purchase. This client needs to have a relationship of type "Pays for"
            with the client specified in the 'ClientId' or 'UniqueClientId' field.
            Note: you need to provide the 'UniquePayerClientId' OR the
            'PayerClientId'. If both are provided, the 'UniquePayerClientId' takes
            precedence.
        test (bool): When `true`, indicates that the contents of the cart are
            validated, but the transaction does not take place. You should use this
            parameter during testing and when checking the calculated totals of the
            items in the cart.<br />  When `false`, the transaction takes place and
            the database is affected.<br />  Default: **false**
        items (List[CheckoutItemWrapper]): A list of the items in the cart.
        in_store (bool): When `true`, indicates that the cart is to be completed by a
            staff member and is to take place at one of the business’ physical
            locations.<br />  When `false`, indicates that the cart is to be
            completed by a client from the business’ online store.<br />  Default:
            **false**
        calculate_tax (bool): When `true`, indicates that the tax should be
            calculated.  When `false`, indicates that the tax should not be
            calculated.  Default: **true**
        promotion_code (str): Promotion code to be applied to the cart.
        payments (List[CheckoutPaymentInfo]): A list of payment information objects
            to be applied to payment against the items in the cart.
        send_email (bool): When `true`, sends a purchase receipt email to the client.
            Note that all appropriate permissions and settings must be enabled for
            the client to receive an email.<br />  Default: **false**
        location_id (int): The location ID to be used for pulling business mode
            prices and taxes. If no location ID is supplied, it defaults to the
            online store, represented by a null value.   Default: **null** (the
            online store)
        image (str): The byte array data of the signature image.
        image_file_name (str): The name of the signature image being uploaded.
        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`
        transaction_ids (List[int]): The list of TransactionIds provided with initial
            response containing SCA Challenge URLs for ConsumerPresent transactions
        is_billing_postal_code_required (bool): the flag to check billing post code
            is required or not.
        enforce_location_restrictions (bool): When `true`, enforces "sell at"
            location restrictions on the cart items.  When `false`, "sell at"
            location restrictions are not enforced.  Default: **false**

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "items": "Items",
        "payments": "Payments",
        "cart_id": "CartId",
        "client_id": "ClientId",
        "unique_client_id": "UniqueClientId",
        "payer_client_id": "PayerClientId",
        "unique_payer_client_id": "UniquePayerClientId",
        "test": "Test",
        "in_store": "InStore",
        "calculate_tax": "CalculateTax",
        "promotion_code": "PromotionCode",
        "send_email": "SendEmail",
        "location_id": "LocationId",
        "image": "Image",
        "image_file_name": "ImageFileName",
        "consumer_present": "ConsumerPresent",
        "payment_authentication_callback_url": "PaymentAuthenticationCallbackUrl",
        "transaction_ids": "TransactionIds",
        "is_billing_postal_code_required": "IsBillingPostalCodeRequired",
        "enforce_location_restrictions": "EnforceLocationRestrictions",
    }

    _optionals = [
        "cart_id",
        "client_id",
        "unique_client_id",
        "payer_client_id",
        "unique_payer_client_id",
        "test",
        "in_store",
        "calculate_tax",
        "promotion_code",
        "send_email",
        "location_id",
        "image",
        "image_file_name",
        "consumer_present",
        "payment_authentication_callback_url",
        "transaction_ids",
        "is_billing_postal_code_required",
        "enforce_location_restrictions",
    ]

    def __init__(
        self,
        items=None,
        payments=None,
        cart_id=APIHelper.SKIP,
        client_id=APIHelper.SKIP,
        unique_client_id=APIHelper.SKIP,
        payer_client_id=APIHelper.SKIP,
        unique_payer_client_id=APIHelper.SKIP,
        test=APIHelper.SKIP,
        in_store=APIHelper.SKIP,
        calculate_tax=APIHelper.SKIP,
        promotion_code=APIHelper.SKIP,
        send_email=APIHelper.SKIP,
        location_id=APIHelper.SKIP,
        image=APIHelper.SKIP,
        image_file_name=APIHelper.SKIP,
        consumer_present=APIHelper.SKIP,
        payment_authentication_callback_url=APIHelper.SKIP,
        transaction_ids=APIHelper.SKIP,
        is_billing_postal_code_required=APIHelper.SKIP,
        enforce_location_restrictions=APIHelper.SKIP):
        """Initialize a CheckoutShoppingCartRequest instance."""
        # Initialize members of the class
        if cart_id is not APIHelper.SKIP:
            self.cart_id = cart_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
        if payer_client_id is not APIHelper.SKIP:
            self.payer_client_id = payer_client_id
        if unique_payer_client_id is not APIHelper.SKIP:
            self.unique_payer_client_id = unique_payer_client_id
        if test is not APIHelper.SKIP:
            self.test = test
        self.items = items
        if in_store is not APIHelper.SKIP:
            self.in_store = in_store
        if calculate_tax is not APIHelper.SKIP:
            self.calculate_tax = calculate_tax
        if promotion_code is not APIHelper.SKIP:
            self.promotion_code = promotion_code
        self.payments = payments
        if send_email is not APIHelper.SKIP:
            self.send_email = send_email
        if location_id is not APIHelper.SKIP:
            self.location_id = location_id
        if image is not APIHelper.SKIP:
            self.image = image
        if image_file_name is not APIHelper.SKIP:
            self.image_file_name = image_file_name
        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 transaction_ids is not APIHelper.SKIP:
            self.transaction_ids = transaction_ids
        if is_billing_postal_code_required is not APIHelper.SKIP:
            self.is_billing_postal_code_required = is_billing_postal_code_required
        if enforce_location_restrictions is not APIHelper.SKIP:
            self.enforce_location_restrictions = enforce_location_restrictions

    @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
        items = None
        if dictionary.get("Items") is not None:
            items = [
                CheckoutItemWrapper.from_dictionary(x)
                    for x in dictionary.get("Items")
            ]
        payments = None
        if dictionary.get("Payments") is not None:
            payments = [
                CheckoutPaymentInfo.from_dictionary(x)
                    for x in dictionary.get("Payments")
            ]
        cart_id =\
            dictionary.get("CartId")\
            if dictionary.get("CartId")\
                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
        payer_client_id =\
            dictionary.get("PayerClientId")\
            if dictionary.get("PayerClientId")\
                else APIHelper.SKIP
        unique_payer_client_id =\
            dictionary.get("UniquePayerClientId")\
            if dictionary.get("UniquePayerClientId")\
                else APIHelper.SKIP
        test =\
            dictionary.get("Test")\
            if "Test" in dictionary.keys()\
                else APIHelper.SKIP
        in_store =\
            dictionary.get("InStore")\
            if "InStore" in dictionary.keys()\
                else APIHelper.SKIP
        calculate_tax =\
            dictionary.get("CalculateTax")\
            if "CalculateTax" in dictionary.keys()\
                else APIHelper.SKIP
        promotion_code =\
            dictionary.get("PromotionCode")\
            if dictionary.get("PromotionCode")\
                else APIHelper.SKIP
        send_email =\
            dictionary.get("SendEmail")\
            if "SendEmail" in dictionary.keys()\
                else APIHelper.SKIP
        location_id =\
            dictionary.get("LocationId")\
            if dictionary.get("LocationId")\
                else APIHelper.SKIP
        image =\
            dictionary.get("Image")\
            if dictionary.get("Image")\
                else APIHelper.SKIP
        image_file_name =\
            dictionary.get("ImageFileName")\
            if dictionary.get("ImageFileName")\
                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
        transaction_ids =\
            dictionary.get("TransactionIds")\
            if dictionary.get("TransactionIds")\
                else APIHelper.SKIP
        is_billing_postal_code_required =\
            dictionary.get("IsBillingPostalCodeRequired")\
            if "IsBillingPostalCodeRequired" in dictionary.keys()\
                else APIHelper.SKIP
        enforce_location_restrictions =\
            dictionary.get("EnforceLocationRestrictions")\
            if "EnforceLocationRestrictions" in dictionary.keys()\
                else APIHelper.SKIP

        # Return an object of this model
        return cls(items,
                   payments,
                   cart_id,
                   client_id,
                   unique_client_id,
                   payer_client_id,
                   unique_payer_client_id,
                   test,
                   in_store,
                   calculate_tax,
                   promotion_code,
                   send_email,
                   location_id,
                   image,
                   image_file_name,
                   consumer_present,
                   payment_authentication_callback_url,
                   transaction_ids,
                   is_billing_postal_code_required,
                   enforce_location_restrictions)

    def __repr__(self):
        """Return a unambiguous string representation."""
        _cart_id=(
            self.cart_id
            if hasattr(self, "cart_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
        )
        _payer_client_id=(
            self.payer_client_id
            if hasattr(self, "payer_client_id")
            else None
        )
        _unique_payer_client_id=(
            self.unique_payer_client_id
            if hasattr(self, "unique_payer_client_id")
            else None
        )
        _test=(
            self.test
            if hasattr(self, "test")
            else None
        )
        _items=self.items
        _in_store=(
            self.in_store
            if hasattr(self, "in_store")
            else None
        )
        _calculate_tax=(
            self.calculate_tax
            if hasattr(self, "calculate_tax")
            else None
        )
        _promotion_code=(
            self.promotion_code
            if hasattr(self, "promotion_code")
            else None
        )
        _payments=self.payments
        _send_email=(
            self.send_email
            if hasattr(self, "send_email")
            else None
        )
        _location_id=(
            self.location_id
            if hasattr(self, "location_id")
            else None
        )
        _image=(
            self.image
            if hasattr(self, "image")
            else None
        )
        _image_file_name=(
            self.image_file_name
            if hasattr(self, "image_file_name")
            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
        )
        _transaction_ids=(
            self.transaction_ids
            if hasattr(self, "transaction_ids")
            else None
        )
        _is_billing_postal_code_required=(
            self.is_billing_postal_code_required
            if hasattr(self, "is_billing_postal_code_required")
            else None
        )
        _enforce_location_restrictions=(
            self.enforce_location_restrictions
            if hasattr(self, "enforce_location_restrictions")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"cart_id={_cart_id!r}, "
            f"client_id={_client_id!r}, "
            f"unique_client_id={_unique_client_id!r}, "
            f"payer_client_id={_payer_client_id!r}, "
            f"unique_payer_client_id={_unique_payer_client_id!r}, "
            f"test={_test!r}, "
            f"items={_items!r}, "
            f"in_store={_in_store!r}, "
            f"calculate_tax={_calculate_tax!r}, "
            f"promotion_code={_promotion_code!r}, "
            f"payments={_payments!r}, "
            f"send_email={_send_email!r}, "
            f"location_id={_location_id!r}, "
            f"image={_image!r}, "
            f"image_file_name={_image_file_name!r}, "
            f"consumer_present={_consumer_present!r}, "
            f"payment_authentication_callback_url={_payment_authentication_callback_url!r}, "
            f"transaction_ids={_transaction_ids!r}, "
            f"is_billing_postal_code_required={_is_billing_postal_code_required!r}, "
            f"enforce_location_restrictions={_enforce_location_restrictions!r}, "
            f")"
        )

    def __str__(self):
        """Return a human-readable string representation."""
        _cart_id=(
            self.cart_id
            if hasattr(self, "cart_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
        )
        _payer_client_id=(
            self.payer_client_id
            if hasattr(self, "payer_client_id")
            else None
        )
        _unique_payer_client_id=(
            self.unique_payer_client_id
            if hasattr(self, "unique_payer_client_id")
            else None
        )
        _test=(
            self.test
            if hasattr(self, "test")
            else None
        )
        _items=self.items
        _in_store=(
            self.in_store
            if hasattr(self, "in_store")
            else None
        )
        _calculate_tax=(
            self.calculate_tax
            if hasattr(self, "calculate_tax")
            else None
        )
        _promotion_code=(
            self.promotion_code
            if hasattr(self, "promotion_code")
            else None
        )
        _payments=self.payments
        _send_email=(
            self.send_email
            if hasattr(self, "send_email")
            else None
        )
        _location_id=(
            self.location_id
            if hasattr(self, "location_id")
            else None
        )
        _image=(
            self.image
            if hasattr(self, "image")
            else None
        )
        _image_file_name=(
            self.image_file_name
            if hasattr(self, "image_file_name")
            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
        )
        _transaction_ids=(
            self.transaction_ids
            if hasattr(self, "transaction_ids")
            else None
        )
        _is_billing_postal_code_required=(
            self.is_billing_postal_code_required
            if hasattr(self, "is_billing_postal_code_required")
            else None
        )
        _enforce_location_restrictions=(
            self.enforce_location_restrictions
            if hasattr(self, "enforce_location_restrictions")
            else None
        )
        return (
            f"{self.__class__.__name__}("
            f"cart_id={_cart_id!s}, "
            f"client_id={_client_id!s}, "
            f"unique_client_id={_unique_client_id!s}, "
            f"payer_client_id={_payer_client_id!s}, "
            f"unique_payer_client_id={_unique_payer_client_id!s}, "
            f"test={_test!s}, "
            f"items={_items!s}, "
            f"in_store={_in_store!s}, "
            f"calculate_tax={_calculate_tax!s}, "
            f"promotion_code={_promotion_code!s}, "
            f"payments={_payments!s}, "
            f"send_email={_send_email!s}, "
            f"location_id={_location_id!s}, "
            f"image={_image!s}, "
            f"image_file_name={_image_file_name!s}, "
            f"consumer_present={_consumer_present!s}, "
            f"payment_authentication_callback_url={_payment_authentication_callback_url!s}, "
            f"transaction_ids={_transaction_ids!s}, "
            f"is_billing_postal_code_required={_is_billing_postal_code_required!s}, "
            f"enforce_location_restrictions={_enforce_location_restrictions!s}, "
            f")"
        )
