"""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.class_schedule import (
    ClassSchedule,
)
from mindbodypublicapi.models.get_enrollments_response import (
    GetEnrollmentsResponse,
)
from mindbodypublicapi.models.written_class_schedules_info import (
    WrittenClassSchedulesInfo,
)


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

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

    def get_enrollments(self,
                        version,
                        site_id,
                        authorization=None,
                        request_class_schedule_ids=None,
                        request_end_date=None,
                        request_limit=None,
                        request_location_ids=None,
                        request_offset=None,
                        request_program_ids=None,
                        request_session_type_ids=None,
                        request_staff_ids=None,
                        request_start_date=None):
        """Perform a GET request to /public/v{version}/enrollment/enrollments.

        Returns a list of enrollments. An enrollment is a service, such as a workshop
        or an event, that a staff member offers to multiple students, who commit to
        coming to all or most of the scheduled sessions. Enrollments typically run
        for a limited time only.

        When a user token is not passed with the request or the passed user token has
        insufficient viewing permissions, only the following staff data is returned
        in the response:

        * FirstName
        * LastName
        * Id
        * Bio
        * DisplayName
        * ImageUrl

        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_schedule_ids (List[int], optional): A list of the requested
                class schedule IDs. If omitted, all class schedule IDs return.
            request_end_date (datetime, optional): The end of the date range. The
                response returns any active enrollments that occur on or before this
                day.<br />  Default: **StartDate**
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_ids (List[int], optional): List of the IDs for the
                requested locations. If omitted, all location IDs return.
            request_offset (int, optional): Page offset, defaults to 0.
            request_program_ids (List[int], optional): List of the IDs for the
                requested programs. If omitted, all program IDs return.
            request_session_type_ids (List[int], optional): List of the IDs for the
                requested session types. If omitted, all session types IDs return.
            request_staff_ids (List[int], optional): List of the IDs for the
                requested staff IDs. If omitted, all staff IDs return.
            request_start_date (datetime, optional): The start of the date range. The
                response returns any active enrollments that occur on or after this
                day.<br />  Default: **today’s date**

        Returns:
            GetEnrollmentsResponse: 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}/enrollment/enrollments")
            .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.classScheduleIds")
                .value(request_class_schedule_ids))
            .query_param(Parameter()
                .key("request.endDate")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_end_date)))
            .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.programIds")
                .value(request_program_ids))
            .query_param(Parameter()
                .key("request.sessionTypeIds")
                .value(request_session_type_ids))
            .query_param(Parameter()
                .key("request.staffIds")
                .value(request_staff_ids))
            .query_param(Parameter()
                .key("request.startDate")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_start_date)))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetEnrollmentsResponse.from_dictionary),
        ).execute()

    def add_client_to_enrollment(self,
                                 version,
                                 request,
                                 site_id,
                                 authorization=None):
        """Perform a POST request to
        /public/v{version}/enrollment/addclienttoenrollment.

        Book a client into an enrollment.

        Args:
            version (str): version of the api.
            request (AddClientToEnrollmentRequest): 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:
            ClassSchedule: 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}/enrollment/addclienttoenrollment")
            .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(ClassSchedule.from_dictionary),
        ).execute()

    def add_enrollment_schedule(self,
                                version,
                                request,
                                site_id,
                                authorization=None):
        """Perform a POST request to
        /public/v{version}/enrollment/addenrollmentschedule.

        This endpoint adds a enrollment schedule. You can require clients to sign up
        for the entire enrollment schedule or allow them to pick specific sessions
        using the AllowOpenEnrollment parameter.

        Args:
            version (str): version of the api.
            request (AddClassEnrollmentScheduleRequest): 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:
            WrittenClassSchedulesInfo: 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}/enrollment/addenrollmentschedule")
            .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(WrittenClassSchedulesInfo.from_dictionary),
        ).execute()

    def update_enrollment_schedule(self,
                                   version,
                                   request,
                                   site_id,
                                   authorization=None):
        """Perform a POST request to
        /public/v{version}/enrollment/updateenrollmentschedule.

        This endpoint update a enrollment schedule.

        Args:
            version (str): version of the api.
            request (UpdateClassEnrollmentScheduleRequest): 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:
            WrittenClassSchedulesInfo: 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}/enrollment/updateenrollmentschedule")
            .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(WrittenClassSchedulesInfo.from_dictionary),
        ).execute()
