"""mindbodypublicapi.

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

# ruff: noqa: D410, E501, E101, D206
from apimatic_core.authentication.multiple.single_auth import (
    Single,
)
from apimatic_core.request_builder import RequestBuilder
from apimatic_core.response_handler import ResponseHandler
from apimatic_core.types.parameter import Parameter

from mindbodypublicapi.api_helper import APIHelper
from mindbodypublicapi.configuration import (
    Server,
)
from mindbodypublicapi.controllers.base_controller import (
    BaseController,
)
from mindbodypublicapi.http.http_method_enum import (
    HttpMethodEnum,
)
from mindbodypublicapi.models.checkout_shopping_cart_response import (
    CheckoutShoppingCartResponse,
)
from mindbodypublicapi.models.get_alternative_payment_methods_response import (
    GetAlternativePaymentMethodsResponse,
)
from mindbodypublicapi.models.get_contracts_response import (
    GetContractsResponse,
)
from mindbodypublicapi.models.get_custom_payment_methods_response import (
    GetCustomPaymentMethodsResponse,
)
from mindbodypublicapi.models.get_gift_card_balance_response import (
    GetGiftCardBalanceResponse,
)
from mindbodypublicapi.models.get_gift_card_response import (
    GetGiftCardResponse,
)
from mindbodypublicapi.models.get_packages_response import (
    GetPackagesResponse,
)
from mindbodypublicapi.models.get_products_inventory_response import (
    GetProductsInventoryResponse,
)
from mindbodypublicapi.models.get_products_response import (
    GetProductsResponse,
)
from mindbodypublicapi.models.get_sales_response import (
    GetSalesResponse,
)
from mindbodypublicapi.models.get_services_response import (
    GetServicesResponse,
)
from mindbodypublicapi.models.get_transactions_response import (
    GetTransactionsResponse,
)
from mindbodypublicapi.models.purchase_account_credit_response import (
    PurchaseAccountCreditResponse,
)
from mindbodypublicapi.models.purchase_contract_response import (
    PurchaseContractResponse,
)
from mindbodypublicapi.models.purchase_gift_card_response import (
    PurchaseGiftCardResponse,
)
from mindbodypublicapi.models.return_sale_response import (
    ReturnSaleResponse,
)
from mindbodypublicapi.models.update_product_price_response import (
    UpdateProductPriceResponse,
)
from mindbodypublicapi.models.update_sale_date_response import (
    UpdateSaleDateResponse,
)
from mindbodypublicapi.models.update_service_response import (
    UpdateServiceResponse,
)


class SaleController(BaseController):
    """A Controller to access Endpoints in the mindbodypublicapi API."""

    def __init__(self, config):
        """Initialize SaleController object."""
        super(SaleController, self).__init__(config)

    def get_accepted_card_types(self,
                                version,
                                site_id,
                                authorization=None):
        """Perform a GET request to /public/v{version}/sale/acceptedcardtypes.

        Gets a list of card types that the site accepts. You can also use `GET Sites`
        to return the Site object, which contains individual accepted card types for
        requested sites.
        This endpoint has no query parameters.The response returns a list of strings.
        Possible values are:
        * Visa
        * MasterCard
        * Discover
        * AMEX

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            List[str]: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/acceptedcardtypes")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize),
        ).execute()

    def get_alternative_payment_methods(self,
                                        version,
                                        site_id,
                                        authorization=None,
                                        request_client_id=None,
                                        request_location_id=None):
        """Perform a GET request to
        /public/v{version}/sale/alternativepaymentmethods.

        Get alternative and local payment methods that are allowed for a site.
        These payment methods can later be used in `Initiate Checkout Shopping Cart
        Using Alternative Payments`
        and `Initiate Purchase Contract Using Alternative Payments` to make the
        payment.

        The currently supported alternative payments are:
        - iDEAL
        - Apple Pay
        **Notes:**
        - This endpoint is only available for Studios on MBPS (Mindbody Payments)
        with Stripe payment processor.
        - This endpoint only supports the online store location (LocationId = 98). If
        LocationId is not provided, it will default to 98.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            request_client_id (str, optional): The client ID
            request_location_id (int, optional): The location ID  Default: **null**
                (Online store location)

        Returns:
            GetAlternativePaymentMethodsResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/alternativepaymentmethods")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("request.clientId")
                .value(request_client_id))
            .query_param(Parameter()
                .key("request.locationId")
                .value(request_location_id))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetAlternativePaymentMethodsResponse.from_dictionary),
        ).execute()

    def get_contracts(self,
                      version,
                      request_location_id,
                      site_id,
                      authorization=None,
                      request_contract_ids=None,
                      request_limit=None,
                      request_offset=None,
                      request_promo_code=None,
                      request_sold_online=None,
                      request_unique_client_id=None):
        """Perform a GET request to /public/v{version}/sale/contracts.

        Returns the contracts and autopay options that are available on a
        location-by-location basis. Depending on the configurations established by
        the site, this endpoint returns options that can be used to sign up clients
        for recurring payments for services offered by the business.

        Args:
            version (str): version of the api.
            request_location_id (int): The ID of the location that has the requested
                contracts and AutoPay options.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            request_contract_ids (List[int], optional): When included, the response
                only contains details about the specified contract IDs.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_offset (int, optional): Page offset, defaults to 0.
            request_promo_code (str, optional): PromoCode to apply
            request_sold_online (bool, optional): When `true`, the response only
                contains details about contracts and AutoPay options that can be sold
                online.   When `false`, all contracts are returned.  Default:
                **false**
            request_unique_client_id (int, optional): The ID of the client.

        Returns:
            GetContractsResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/contracts")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .query_param(Parameter()
                .key("request.locationId")
                .value(request_location_id))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("request.contractIds")
                .value(request_contract_ids))
            .query_param(Parameter()
                .key("request.limit")
                .value(request_limit))
            .query_param(Parameter()
                .key("request.offset")
                .value(request_offset))
            .query_param(Parameter()
                .key("request.promoCode")
                .value(request_promo_code))
            .query_param(Parameter()
                .key("request.soldOnline")
                .value(request_sold_online))
            .query_param(Parameter()
                .key("request.uniqueClientId")
                .value(request_unique_client_id))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetContractsResponse.from_dictionary),
        ).execute()

    def get_custom_payment_methods(self,
                                   version,
                                   site_id,
                                   authorization=None,
                                   request_limit=None,
                                   request_offset=None):
        """Perform a GET request to
        /public/v{version}/sale/custompaymentmethods.

        Get payment methods that can be used to pay for sales at a site.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_offset (int, optional): Page offset, defaults to 0.

        Returns:
            GetCustomPaymentMethodsResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/custompaymentmethods")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("request.limit")
                .value(request_limit))
            .query_param(Parameter()
                .key("request.offset")
                .value(request_offset))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetCustomPaymentMethodsResponse.from_dictionary),
        ).execute()

    def get_gift_card_balance(self,
                              version,
                              site_id,
                              authorization=None,
                              barcode_id=None):
        """Perform a GET request to /public/v{version}/sale/giftcardbalance.

        Returns a gift card’s remaining balance.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            barcode_id (str, optional): The barcode ID of the gift card for which you
                want the balance.

        Returns:
            GetGiftCardBalanceResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/giftcardbalance")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("barcodeId")
                .value(barcode_id))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetGiftCardBalanceResponse.from_dictionary),
        ).execute()

    def get_gift_cards(self,
                       version,
                       site_id,
                       authorization=None,
                       request_ids=None,
                       request_include_custom_layouts=None,
                       request_limit=None,
                       request_location_id=None,
                       request_offset=None,
                       request_sold_online=None):
        """Perform a GET request to /public/v{version}/sale/giftcards.

        Returns information about gift cards that can be purchased.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            request_ids (List[int], optional): Filters the results to the requested
                gift card IDs.<br />  Default: **all** gift cards.
            request_include_custom_layouts (bool, optional): When `true`, includes
                custom gift card layouts.<br />  When `false`, includes only system
                layouts.  Default: **false**
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_id (int, optional): When included, returns gift cards
                that are sold at the provided location ID.
            request_offset (int, optional): Page offset, defaults to 0.
            request_sold_online (bool, optional): When `true`, only returns gift
                cards that are sold online.<br />  Default: **false**

        Returns:
            GetGiftCardResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/giftcards")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("request.ids")
                .value(request_ids))
            .query_param(Parameter()
                .key("request.includeCustomLayouts")
                .value(request_include_custom_layouts))
            .query_param(Parameter()
                .key("request.limit")
                .value(request_limit))
            .query_param(Parameter()
                .key("request.locationId")
                .value(request_location_id))
            .query_param(Parameter()
                .key("request.offset")
                .value(request_offset))
            .query_param(Parameter()
                .key("request.soldOnline")
                .value(request_sold_online))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetGiftCardResponse.from_dictionary),
        ).execute()

    def get_packages(self,
                     version,
                     site_id,
                     authorization=None,
                     request_limit=None,
                     request_location_id=None,
                     request_offset=None,
                     request_package_ids=None,
                     request_sell_online=None):
        """Perform a GET request to /public/v{version}/sale/packages.

        A package is typically used to combine multiple services and/or products into
        a single offering. Staff members can check out multiple appointments while
        selling the package, and can discount the items included. For example, a spa
        might bundle a massage, a pedicure, a manicure, a facial, and a few selected
        beauty products into a package.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_id (int, optional): The location ID to use to determine
                the tax for the products that this request returns.<br />  Default:
                **online store**
            request_offset (int, optional): Page offset, defaults to 0.
            request_package_ids (List[int], optional): A list of the packages IDs to
                filter by.
            request_sell_online (bool, optional): When `true`, only returns products
                that can be sold online.<br />  When `false`, all products are
                returned.<br />  Default: **false**

        Returns:
            GetPackagesResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/packages")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("request.limit")
                .value(request_limit))
            .query_param(Parameter()
                .key("request.locationId")
                .value(request_location_id))
            .query_param(Parameter()
                .key("request.offset")
                .value(request_offset))
            .query_param(Parameter()
                .key("request.packageIds")
                .value(request_package_ids))
            .query_param(Parameter()
                .key("request.sellOnline")
                .value(request_sell_online))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetPackagesResponse.from_dictionary),
        ).execute()

    def get_products(self,
                     version,
                     site_id,
                     authorization=None,
                     request_category_ids=None,
                     request_limit=None,
                     request_location_id=None,
                     request_offset=None,
                     request_product_ids=None,
                     request_search_text=None,
                     request_secondary_category_ids=None,
                     request_sell_online=None,
                     request_sub_category_ids=None):
        """Perform a GET request to /public/v{version}/sale/products.

        Get retail products available for purchase at a site.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            request_category_ids (List[int], optional): A list of revenue category
                IDs to filter by. Use this ID when calling the GET Categories
                endpoint.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_id (int, optional): The location ID to use to determine
                the tax for the products that this request returns.<br />  Default:
                **online store**
            request_offset (int, optional): Page offset, defaults to 0.
            request_product_ids (List[str], optional): The barcode number of the
                product to be filter by.
            request_search_text (str, optional): A search filter, used for searching
                by term.
            request_secondary_category_ids (List[int], optional): A list of secondary
                categories to filter by. Use this ID when calling the GET Categories
                endpoint.
            request_sell_online (bool, optional): When `true`, only products that can
                be sold online are returned.<br />  When `false`, all products are
                returned.<br />  Default: **false**
            request_sub_category_ids (List[int], optional): A list of subcategory IDs
                to filter by. Use this ID when calling the GET Categories endpoint.

        Returns:
            GetProductsResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/products")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("request.categoryIds")
                .value(request_category_ids))
            .query_param(Parameter()
                .key("request.limit")
                .value(request_limit))
            .query_param(Parameter()
                .key("request.locationId")
                .value(request_location_id))
            .query_param(Parameter()
                .key("request.offset")
                .value(request_offset))
            .query_param(Parameter()
                .key("request.productIds")
                .value(request_product_ids))
            .query_param(Parameter()
                .key("request.searchText")
                .value(request_search_text))
            .query_param(Parameter()
                .key("request.secondaryCategoryIds")
                .value(request_secondary_category_ids))
            .query_param(Parameter()
                .key("request.sellOnline")
                .value(request_sell_online))
            .query_param(Parameter()
                .key("request.subCategoryIds")
                .value(request_sub_category_ids))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetProductsResponse.from_dictionary),
        ).execute()

    def update_products(self,
                        version,
                        site_id,
                        update_products_requests,
                        authorization=None):
        """Perform a PUT request to /public/v{version}/sale/products.

        Update retail products available for purchase at a site.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            update_products_requests (List[UpdateProductRequest]): The request body
                parameter.
            authorization (str, optional): A staff user authorization token.

        Returns:
            GetProductsResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/products")
            .http_method(HttpMethodEnum.PUT)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .body_param(Parameter()
                .value(update_products_requests))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetProductsResponse.from_dictionary),
        ).execute()

    def get_products_inventory(self,
                               version,
                               site_id,
                               authorization=None,
                               request_barcode_ids=None,
                               request_limit=None,
                               request_location_ids=None,
                               request_offset=None,
                               request_product_ids=None):
        """Perform a GET request to /public/v{version}/sale/productsinventory.

        Get retail products inventory data available at a site.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            request_barcode_ids (List[str], optional): When included, the response
                only contains details about the specified Barcode Ids.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_ids (List[int], optional): When included, the response
                only contains details about the specified location Ids.
            request_offset (int, optional): Page offset, defaults to 0.
            request_product_ids (List[str], optional): When included, the response
                only contains details about the specified product Ids.

        Returns:
            GetProductsInventoryResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/productsinventory")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("request.barcodeIds")
                .value(request_barcode_ids))
            .query_param(Parameter()
                .key("request.limit")
                .value(request_limit))
            .query_param(Parameter()
                .key("request.locationIds")
                .value(request_location_ids))
            .query_param(Parameter()
                .key("request.offset")
                .value(request_offset))
            .query_param(Parameter()
                .key("request.productIds")
                .value(request_product_ids))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetProductsInventoryResponse.from_dictionary),
        ).execute()

    def get_purchase_contract_status(self,
                                     version,
                                     access_token,
                                     site_id,
                                     authorization=None):
        """Perform a GET request to
        /public/v{version}/sale/purchasecontractstatus.

        Fetches the status of an initiate purchase contract given accessToken.
        This endpoint complements the `Initiate Purchase Contract Using Alternative
        Payments` endpoint. `Initiate Purchase Contract Using Alternative Payments`
        endpoint will capture the intent to purchase a contract, and return a
        redirect URL for the end user to make the payment. Once the payment
        concludes, the end user will be redirected back to the
        PaymentAuthenticationCallbackUrl, which was provided while invoking the
        `Initiate Purchase Contract Using Alternative Payments` endpoint. You can
        then invoke this endpoint to obtain the `PurchaseContractResponse`.

        **For a comprehensive guide, follow this tutorial:** [Purchase a
        Contract](https://developers.mindbodyonline.com/ui/documentation/public-api#/h
        ttp/tutorials/purchase-a-contract)

        The currently supported alternative payments are:
        - iDEAL
        - Apple Pay

        Args:
            version (str): version of the api.
            access_token (str): The request query parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            PurchaseContractResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/purchasecontractstatus")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .query_param(Parameter()
                .key("accessToken")
                .value(access_token))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(PurchaseContractResponse.from_dictionary),
        ).execute()

    def get_sales(self,
                  version,
                  site_id,
                  authorization=None,
                  request_end_sale_date_time=None,
                  request_limit=None,
                  request_offset=None,
                  request_payment_method_id=None,
                  request_sale_id=None,
                  request_start_sale_date_time=None):
        """Perform a GET request to /public/v{version}/sale/sales.

        Get sales completed at a site.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            request_end_sale_date_time (datetime, optional): Filters results to sales
                that happened before this date and time.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_offset (int, optional): Page offset, defaults to 0.
            request_payment_method_id (int, optional): Filters results to sales paid
                for by the given payment method ID which indicates payment method(s)
                (i.e. cash, VISA, AMEX, Check, etc.).
            request_sale_id (int, optional): The sale ID associated with the
                particular item. It Filters results to the requested sale ID.
            request_start_sale_date_time (datetime, optional): Filters results to
                sales that happened after this date and time.

        Returns:
            GetSalesResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/sales")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("request.endSaleDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_end_sale_date_time)))
            .query_param(Parameter()
                .key("request.limit")
                .value(request_limit))
            .query_param(Parameter()
                .key("request.offset")
                .value(request_offset))
            .query_param(Parameter()
                .key("request.paymentMethodId")
                .value(request_payment_method_id))
            .query_param(Parameter()
                .key("request.saleId")
                .value(request_sale_id))
            .query_param(Parameter()
                .key("request.startSaleDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_start_sale_date_time)))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetSalesResponse.from_dictionary),
        ).execute()

    def get_services(self,
                     version,
                     site_id,
                     authorization=None,
                     request_class_id=None,
                     request_class_schedule_id=None,
                     request_hide_related_programs=None,
                     request_include_discontinued=None,
                     request_include_sale_in_contract_only=None,
                     request_limit=None,
                     request_location_id=None,
                     request_offset=None,
                     request_program_ids=None,
                     request_sell_online=None,
                     request_service_ids=None,
                     request_session_type_ids=None,
                     request_staff_id=None):
        """Perform a GET request to /public/v{version}/sale/services.

        Get pricing options available for purchase at a site

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            request_class_id (int, optional): Filters to the pricing options for the
                specified class ID.
            request_class_schedule_id (int, optional): Filters to the pricing options
                for the specified class schedule ID.
            request_hide_related_programs (bool, optional): When `true`, indicates
                that pricing options of related programs are omitted from the
                response.<br />  Default: **false**
            request_include_discontinued (bool, optional): When `true`, indicates
                that the filtered pricing option list includes discontinued pricing
                options.<br />  Default: **false**
            request_include_sale_in_contract_only (bool, optional): When `true`,
                indicates that the filtered pricing option list includes sale in
                contract only pricing options.<br />  Default: **false**
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_id (int, optional): When specified, for each returned
                pricing option, `TaxRate` and `TaxIncluded` are calculated according
                to the specified location. Note that this does not filter results to
                only services provided at the given location, and for locations where
                Value-Added Tax (VAT) rules apply, the `TaxRate` is set to zero.
            request_offset (int, optional): Page offset, defaults to 0.
            request_program_ids (List[int], optional): Filters to pricing options
                with the specified program IDs.
            request_sell_online (bool, optional): When `true`, filters the pricing
                options to display only those available for online purchase.  This
                parameter is only applicable in Business Mode (when a staff
                authentication header is included) and ignored in Consumer Mode (when
                no authentication header is passed).  <br />Default: `false` (for
                staff users)  <br />Business Mode: This parameter controls the
                filtering behavior. Staff users can set this to `true`  to show only
                pricing options that can be sold online, or `false` to show all
                available pricing options.  <br />Consumer Mode: This value is
                automatically set to `true` and cannot be overridden,  ensuring
                consumers only see pricing options available for online purchase.
            request_service_ids (List[str], optional): Filters to the pricing options
                with the specified IDs. In this context, service and pricing option
                are used interchangeably. These are the `PurchasedItems[].Id`
                returned from GET Sales.
            request_session_type_ids (List[int], optional): Filters to the pricing
                options with the specified session types IDs.
            request_staff_id (int, optional): Sets `Price` and `OnlinePrice` to the
                particular pricing of a specific staff member, if allowed by the
                business.

        Returns:
            GetServicesResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/services")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("request.classId")
                .value(request_class_id))
            .query_param(Parameter()
                .key("request.classScheduleId")
                .value(request_class_schedule_id))
            .query_param(Parameter()
                .key("request.hideRelatedPrograms")
                .value(request_hide_related_programs))
            .query_param(Parameter()
                .key("request.includeDiscontinued")
                .value(request_include_discontinued))
            .query_param(Parameter()
                .key("request.includeSaleInContractOnly")
                .value(request_include_sale_in_contract_only))
            .query_param(Parameter()
                .key("request.limit")
                .value(request_limit))
            .query_param(Parameter()
                .key("request.locationId")
                .value(request_location_id))
            .query_param(Parameter()
                .key("request.offset")
                .value(request_offset))
            .query_param(Parameter()
                .key("request.programIds")
                .value(request_program_ids))
            .query_param(Parameter()
                .key("request.sellOnline")
                .value(request_sell_online))
            .query_param(Parameter()
                .key("request.serviceIds")
                .value(request_service_ids))
            .query_param(Parameter()
                .key("request.sessionTypeIds")
                .value(request_session_type_ids))
            .query_param(Parameter()
                .key("request.staffId")
                .value(request_staff_id))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetServicesResponse.from_dictionary),
        ).execute()

    def update_services(self,
                        version,
                        site_id,
                        update_services_request,
                        authorization=None):
        """Perform a PUT request to /public/v{version}/sale/services.

        Update unit price and online price of provided services.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            update_services_request (List[UpdateServiceRequest]): The request body
                parameter.
            authorization (str, optional): A staff user authorization token.

        Returns:
            UpdateServiceResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/services")
            .http_method(HttpMethodEnum.PUT)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .body_param(Parameter()
                .value(update_services_request))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(UpdateServiceResponse.from_dictionary),
        ).execute()

    def get_transactions(self,
                         version,
                         site_id,
                         authorization=None,
                         request_client_id=None,
                         request_limit=None,
                         request_location_id=None,
                         request_offset=None,
                         request_sale_id=None,
                         request_status=None,
                         request_transaction_end_date_time=None,
                         request_transaction_id=None,
                         request_transaction_start_date_time=None):
        """Perform a GET request to /public/v{version}/sale/transactions.

        This endpoint returns a list of transaction details of processed sales.

        Args:
            version (str): version of the api.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.
            request_client_id (int, optional): Filters results to the requested
                client ID.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_id (int, optional): Filters the transaction results with
                the ID number associated with the location of the sale.
            request_offset (int, optional): Page offset, defaults to 0.
            request_sale_id (int, optional): Filters the transaction results with the
                ID number associated with the sale.
            request_status (str, optional): Filters the transaction results by the
                estimated transaction status.
            request_transaction_end_date_time (datetime, optional): Filters the
                transaction results that happpened before this date and time.
                Default: **today’s date**
            request_transaction_id (int, optional): Filters the transaction results
                with the ID number generated when the sale is processed.
            request_transaction_start_date_time (datetime, optional): Filters the
                transaction results that happpened after this date and time.
                Default: **today’s date**

        Returns:
            GetTransactionsResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/transactions")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .query_param(Parameter()
                .key("request.clientId")
                .value(request_client_id))
            .query_param(Parameter()
                .key("request.limit")
                .value(request_limit))
            .query_param(Parameter()
                .key("request.locationId")
                .value(request_location_id))
            .query_param(Parameter()
                .key("request.offset")
                .value(request_offset))
            .query_param(Parameter()
                .key("request.saleId")
                .value(request_sale_id))
            .query_param(Parameter()
                .key("request.status")
                .value(request_status))
            .query_param(Parameter()
                .key("request.transactionEndDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_transaction_end_date_time)))
            .query_param(Parameter()
                .key("request.transactionId")
                .value(request_transaction_id))
            .query_param(Parameter()
                .key("request.transactionStartDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_transaction_start_date_time)))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetTransactionsResponse.from_dictionary),
        ).execute()

    def checkout_shopping_cart(self,
                               version,
                               request,
                               site_id,
                               authorization=None):
        """Perform a POST request to
        /public/v{version}/sale/checkoutshoppingcart.

        This endpoint provides a wide range of functionality. For example, you can
        use it when a client purchases new pricing options, retail products,
        packages, and tips. You can also combine purchasing a new pricing option and
        many other functions, such as booking a client into a class, booking a new
        appointment for a client, enrolling a client into an enrollment or course, or
        reconciling an unpaid, already booked appointment or class. Use this call
        when a client purchases:
        * a pricing option, after calling `GET Services` and choosing a specific
        pricing option’s ID
        * a retail product, after calling `GET Products` and choosing a specific
        retail product’s ID
        * a package, after calling `GET Packages` and choosing a specific package’s ID
        * a tip to give to a staff member, after calling `GET Staff` and choosing a
        specific staff member ID, and the amount that the client wants to tip
        The documentation provides explanations of the request body and response, as
        well as the cart item metadata, payment item metadata, and purchased cart
        items.
        This endpoint had been updated to support Strong Customer Authentication
        (SCA).
        **Note :**
        Protect yourself from processor fees and credit card fraud.Remember to always
        protect your web forms that leverage POST CheckoutShoppingCart, POST
        PurchaseContract or POST PurchaseGiftCard with a CAPTCHA!

        Args:
            version (str): version of the api.
            request (CheckoutShoppingCartRequest): The request body parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            CheckoutShoppingCartResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/checkoutshoppingcart")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .body_param(Parameter()
                .value(request))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(CheckoutShoppingCartResponse.from_dictionary),
        ).execute()

    def complete_checkout_shopping_cart_using_alternative_payments(self,
                                                                   version,
                                                                   request,
                                                                   site_id,
                                                                   authorization=None):
        """Perform a POST request to
        /public/v{version}/sale/completecheckoutshoppingcart.

        This endpoint complements the InitiateCheckoutShoppintCart endpoint. Please
        visit its documentation to understand further.
        The currently supported alternative payments are:
        - iDEAL
        - Apple Pay
        **How to use :**
        InitiateCheckoutShoppingCart and CompleteCheckoutShoppingCart endpoints work
        together. InitiateCheckoutShoppingCart endpoint will capture the intent to
        perform a checkout, and return a redirect URL for the end user to make the
        payment. Once the payment concludes, the end user will be redirected back to
        the PaymentAuthenticationCallbackUrl, which was provided while invoking the
        InitiateCheckoutShoppingCart endpoint. You can then invoke the
        CompleteCheckoutShoppingCart endpoint to complete the remaining checkout
        activities and obtain the CheckoutShoppingCartResponse.
        **For a comprehensive guide, follow this tutorial:** [Checkout Shopping Cart
        Using Alternative
        Payments](https://developers.mindbodyonline.com/ui/documentation/public-api#/h
        ttp/tutorials/checkout-shopping-cart-using-alternative-payments)
        **Notes:**
        - This endpoint is only available for Studios on MBPS (Mindbody Payments)
        with Stripe payment processor.
        - Protect yourself from processor fees. Remember to always protect your web
        forms that leverage POST InitiateCheckoutShoppingCart or POST
        CompleteCheckoutShoppingCart with a CAPTCHA!

        Args:
            version (str): version of the api.
            request (CompleteCheckoutShoppingCartUsingAlternativePaymentsRequest):
                The request body parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            CheckoutShoppingCartResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/completecheckoutshoppingcart")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .body_param(Parameter()
                .value(request))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(CheckoutShoppingCartResponse.from_dictionary),
        ).execute()

    def initiate_checkout_shopping_cart_using_alternative_payments(self,
                                                                   version,
                                                                   request,
                                                                   site_id,
                                                                   authorization=None):
        """Perform a POST request to
        /public/v{version}/sale/initiatecheckoutshoppingcart.

        This endpoint provides a wide range of functionality. For example, you can
        use it when a client purchases new pricing options, retail products,
        packages, and tips. You can also combine purchasing a new pricing option and
        many other functions, such as booking a client into a class, booking a new
        appointment for a client, enrolling a client into an enrollment or course, or
        reconciling an unpaid, already booked appointment or class. Use this call
        when a client purchases:
        * a pricing option, after calling `GET Services` and choosing a specific
        pricing option’s ID
        * a retail product, after calling `GET Products` and choosing a specific
        retail product’s ID
        * a package, after calling `GET Packages` and choosing a specific package’s ID
        * a tip to give to a staff member, after calling `GET Staff` and choosing a
        specific staff member ID, and the amount that the client wants to tip
        The documentation provides explanations of the request body and response, as
        well as the cart item metadata, payment item metadata, and purchased cart
        items.
        The currently supported alternative payments are:
        - iDEAL
        - Apple Pay

        **How to use :**
        InitiateCheckoutShoppingCart and CompleteCheckoutShoppingCart endpoints work
        together. InitiateCheckoutShoppingCart endpoint will capture the intent to
        perform a checkout, and return a redirect URL for the end user to make the
        payment. Once the payment concludes, the end user will be redirected back to
        the PaymentAuthenticationCallbackUrl, which was provided while invoking the
        InitiateCheckoutShoppingCart endpoint. You can then invoke the
        CompleteCheckoutShoppingCart endpoint to complete the remaining checkout
        activities and obtain the CheckoutShoppingCartResponse.
        **For a comprehensive guide, follow this tutorial:** [Checkout Shopping Cart
        Using Alternative
        Payments](https://developers.mindbodyonline.com/ui/documentation/public-api#/h
        ttp/tutorials/checkout-shopping-cart-using-alternative-payments)
        **Notes:**
        - This endpoint is only available for Studios on MBPS (Mindbody Payments)
        with Stripe payment processor.
        - This endpoint only supports the online store location (LocationId = 98). If
        LocationId is not provided, it will default to 98.
        - Product purchases are currently not supported on the online store location.
        - This endpoint only supports those payment methods as obtained from the
        GetAlternativePaymentMethods endpoint.
        - Protect yourself from processor fees. Remember to always protect your web
        forms that leverage POST InitiateCheckoutShoppingCart or POST
        CompleteCheckoutShoppingCart with a CAPTCHA!

        Args:
            version (str): version of the api.
            request (InitiateCheckoutShoppingCartUsingAlternativePaymentsRequest):
                The request body parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            Any: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/initiatecheckoutshoppingcart")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .body_param(Parameter()
                .value(request))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize),
        ).execute()

    def initiate_purchase_contract_using_alternative_payments(self,
                                                              version,
                                                              request,
                                                              site_id,
                                                              authorization=None):
        """Perform a POST request to
        /public/v{version}/sale/initiatepurchasecontract.

        Allows a client to sign up for a contract or autopay using the information
        returned from the `GET Contracts` endpoint. The client can pay with allowed
        alternative and local payment methods returned from `Get Alternative Payment
        Method`. The client must exist at the site specified before this call is made.

        The currently supported alternative payments are:
        - iDEAL
        - Apple Pay

        **For a comprehensive guide, follow this tutorial:** [Purchase a
        Contract](https://developers.mindbodyonline.com/ui/documentation/public-api#/h
        ttp/tutorials/purchase-a-contract)

        **Notes:**
        - This endpoint is only available for Studios on MBPS (Mindbody Payments)
        with Stripe payment processor.
        - This endpoint only supports the online store location (LocationId = 98). If
        LocationId is not provided, it will default to 98.
        - This endpoint only supports those payment methods as obtained from the
        GetAlternativePaymentMethods endpoint.
        - Protect yourself from processor fees and credit card fraud. Remember to
        always protect your web forms that leverage POST CheckoutShoppingCart, POST
        PurchaseContract or POST PurchaseGiftCard with a CAPTCHA!

        Args:
            version (str): version of the api.
            request (InitiatePurchaseContractRequest): The request body parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            Any: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/initiatepurchasecontract")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .body_param(Parameter()
                .value(request))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize),
        ).execute()

    def purchase_account_credit(self,
                                version,
                                request,
                                site_id,
                                authorization=None):
        """Perform a POST request to
        /public/v{version}/sale/purchaseaccountcredit.

        Allows a client to purchase account credit from a business.

        Args:
            version (str): version of the api.
            request (PurchaseAccountCreditRequest): The request body parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            PurchaseAccountCreditResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/purchaseaccountcredit")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .body_param(Parameter()
                .value(request))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(PurchaseAccountCreditResponse.from_dictionary),
        ).execute()

    def purchase_contract(self,
                          version,
                          request,
                          site_id,
                          authorization=None):
        """Perform a POST request to /public/v{version}/sale/purchasecontract.

        Allows a client to sign up for a contract or autopay using the information
        returned from the `GET Contracts` endpoint. The client can pay with a new
        credit card or with a stored credit card. The client must exist at the site
        specified before this call is made.
        This endpoint allows a developer to specify whether a client pays now or pays
        on the `StartDate`. If you are building a client-facing experience, you
        should talk with the business owner to understand the owner’s policies before
        you give clients a choice of the two payment types.
        This endpoint also allows a developer to specify a `ProrateDate`. If the date
        is passed, the Totals returned will always include the pro-rate amount for
        instant payment, like:
        - `FirstPaymentOccurs` = `Instant` =&gt; returns instant payment total for
        the contract + pro-rate amount.
        - `FirstPaymentOccurs` = `StartDate` =&gt; returns pro-rate amount + contract
        amount requiring instant payment. The rest of the contract will be due on
        `StartDate`.
        - Pro-rate amount payment on `StartDate` is not supported by this endpoint.
        This endpoint has been updated to support Strong Customer Authentication
        (SCA).
        **Note:**
        Protect yourself from processor fees and credit card fraud. Remember to
        always protect your web forms that leverage POST CheckoutShoppingCart, POST
        PurchaseContract or POST PurchaseGiftCard with a CAPTCHA!

        Args:
            version (str): version of the api.
            request (PurchaseContractRequest): The request body parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            PurchaseContractResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/purchasecontract")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .body_param(Parameter()
                .value(request))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(PurchaseContractResponse.from_dictionary),
        ).execute()

    def purchase_gift_card(self,
                           version,
                           request,
                           site_id,
                           authorization=None):
        """Perform a POST request to /public/v{version}/sale/purchasegiftcard.

         Allows a client to purchase a gift card from a business in a variety of
        designs. The card can be emailed to the recipient on a specific day, and a
        card title and a personal message can be added.
         **Note**
        Protect yourself from processor fees and credit card fraud.Remember to always
        protect your web forms that leverage POST CheckoutShoppingCart, POST
        PurchaseContract or POST PurchaseGiftCard with a CAPTCHA!

        Args:
            version (str): version of the api.
            request (PurchaseGiftCardRequest): The request body parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            PurchaseGiftCardResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/purchasegiftcard")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .body_param(Parameter()
                .value(request))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(PurchaseGiftCardResponse.from_dictionary),
        ).execute()

    def return_sale(self,
                    version,
                    return_sale_request,
                    site_id,
                    authorization=None):
        """Perform a POST request to /public/v{version}/sale/returnsale.

        Return a comped sale for a specified sale ID in business mode. The sale is
        returnable only if it is a sale of a service, product or gift card and it has
        not been used. Currently, only the comp payment method is supported.

        Args:
            version (str): version of the api.
            return_sale_request (ReturnSaleRequest): The request body parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            ReturnSaleResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/returnsale")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .body_param(Parameter()
                .value(return_sale_request))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(ReturnSaleResponse.from_dictionary),
        ).execute()

    def update_product_price(self,
                             version,
                             request,
                             site_id,
                             authorization=None):
        """Perform a POST request to
        /public/v{version}/sale/updateproductprice.

        This endpoint updates the retail price and an online price for a product.
        Passing at least one of them is mandatory.

        Args:
            version (str): version of the api.
            request (UpdateProductPriceRequest): The request body parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            UpdateProductPriceResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/updateproductprice")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .body_param(Parameter()
                .value(request))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(UpdateProductPriceResponse.from_dictionary),
        ).execute()

    def update_sale_date(self,
                         version,
                         request,
                         site_id,
                         authorization=None):
        """Perform a PUT request to /public/v{version}/sale/updatesaledate.

        This endpoint updates the SaleDate and returns the details of the sale.

        Args:
            version (str): version of the api.
            request (UpdateSaleDateRequest): The request body parameter.
            site_id (str): ID of the site from which to pull data.
            authorization (str, optional): A staff user authorization token.

        Returns:
            UpdateSaleDateResponse: Response from the API. OK

        Raises:
            APIException: When an error occurs while fetching the data from the
                remote API. This exception includes the HTTP Response code, an error
                message, and the HTTP body that was received in the request.

        """
        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path("/public/v{version}/sale/updatesaledate")
            .http_method(HttpMethodEnum.PUT)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .body_param(Parameter()
                .value(request))
            .header_param(Parameter()
                .key("siteId")
                .value(site_id))
            .header_param(Parameter()
                .key("Content-Type")
                .value("application/json"))
            .header_param(Parameter()
                .key("authorization")
                .value(authorization))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .body_serializer(APIHelper.json_serialize)
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(UpdateSaleDateResponse.from_dictionary),
        ).execute()
