"""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.create_reservation_response import (
    CreateReservationResponse,
)
from mindbodypublicapi.models.get_pick_a_spot_class_response import (
    GetPickASpotClassResponse,
)
from mindbodypublicapi.models.get_reservation_response import (
    GetReservationResponse,
)
from mindbodypublicapi.models.http_content import (
    HttpContent,
)
from mindbodypublicapi.models.update_reservation_response import (
    UpdateReservationResponse,
)


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

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

    def get_class_list(self,
                       version,
                       site_id,
                       authorization=None):
        """Perform a GET request to /public/v{version}/pickaspot/v1/class.

        This endpoint supports pagination. See Pagination object for a description.

        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:
            GetPickASpotClassResponse: 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}/pickaspot/v1/class")
            .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)
            .deserialize_into(GetPickASpotClassResponse.from_dictionary),
        ).execute()

    def get_class(self,
                  version,
                  class_id,
                  site_id,
                  authorization=None):
        """Perform a GET request to
        /public/v{version}/pickaspot/v1/class/{classId}.

        Get a class filtered by classId.

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

        Returns:
            GetPickASpotClassResponse: 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}/pickaspot/v1/class/{classId}")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .template_param(Parameter()
                .key("classId")
                .value(class_id)
                .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)
            .deserialize_into(GetPickASpotClassResponse.from_dictionary),
        ).execute()

    def get_reservation(self,
                        version,
                        path_info,
                        site_id,
                        authorization=None):
        """Perform a GET request to
        /public/v{version}/pickaspot/v1/reservation/{pathInfo}.

        Retrieves reservation for Pick a Spot.

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

        Returns:
            GetReservationResponse: 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}/pickaspot/v1/reservation/{pathInfo}")
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .template_param(Parameter()
                .key("pathInfo")
                .value(path_info)
                .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)
            .deserialize_into(GetReservationResponse.from_dictionary),
        ).execute()

    def update_reservation(self,
                           version,
                           path_info,
                           site_id,
                           authorization=None):
        """Perform a PUT request to
        /public/v{version}/pickaspot/v1/reservation/{pathInfo}.

        A user token is required for this endpoint.
        This endpoint updates a single reservation.

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

        Returns:
            UpdateReservationResponse: 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}/pickaspot/v1/reservation/{pathInfo}")
            .http_method(HttpMethodEnum.PUT)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .template_param(Parameter()
                .key("pathInfo")
                .value(path_info)
                .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)
            .deserialize_into(UpdateReservationResponse.from_dictionary),
        ).execute()

    def create_reservation(self,
                           version,
                           path_info,
                           site_id,
                           authorization=None):
        """Perform a POST request to
        /public/v{version}/pickaspot/v1/reservation/{pathInfo}.

        Creates a spot reservation for a given pick-a-spot class. The actual class
        visit must be created prior to calling this endpoint.
        A user token is required for this endpoint.

        Sample request:

            POST /pickaspot/v1/reservation
            {
                "SiteId": -1147483363,
                "LocationId": 1,
                "ClassId": "64b14ac8c20ae8f0afd2d409",
                "ReservationExternalId": "44724", // this is a Visit.Id and should be
        linked to a specific class visit
                "MemberExternalId": "100000136", // this is Client's UniqueId
                "SpotNumber": "5",
                "ReservationDisplayName": "ReservationDisplayName", // optional
                "ReservationType": "Member", // optional. Can be Member, Guest,
        Instructor, FamilyMember,
                "AutoConfirm": false, // optional. Default: false
                "AutoAssignSpot": false // optional. It will override the
        "SpotNumber" passed and auto assign one. Default: false
            }

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

        Returns:
            CreateReservationResponse: 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}/pickaspot/v1/reservation/{pathInfo}")
            .http_method(HttpMethodEnum.POST)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .template_param(Parameter()
                .key("pathInfo")
                .value(path_info)
                .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)
            .deserialize_into(CreateReservationResponse.from_dictionary),
        ).execute()

    def delete_reservation(self,
                           version,
                           path_info,
                           site_id,
                           authorization=None):
        """Perform a DELETE request to
        /public/v{version}/pickaspot/v1/reservation/{pathInfo}.

        A user token is required for this endpoint.
        This endpoint deletes a single reservation.

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

        Returns:
            HttpContent: 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}/pickaspot/v1/reservation/{pathInfo}")
            .http_method(HttpMethodEnum.DELETE)
            .template_param(Parameter()
                .key("version")
                .value(version)
                .should_encode(True))
            .template_param(Parameter()
                .key("pathInfo")
                .value(path_info)
                .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)
            .deserialize_into(HttpContent.from_dictionary),
        ).execute()
