"""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.get_commissions_response import (
    GetCommissionsResponse,
)
from mindbodypublicapi.models.get_scheduled_service_earnings_response import (
    GetScheduledServiceEarningsResponse,
)
from mindbodypublicapi.models.get_time_cards_response import (
    GetTimeCardsResponse,
)
from mindbodypublicapi.models.get_tips_response import (
    GetTipsResponse,
)


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

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

    def get_commissions(self,
                        version,
                        site_id,
                        authorization=None,
                        request_end_date_time=None,
                        request_limit=None,
                        request_location_id=None,
                        request_offset=None,
                        request_staff_id=None,
                        request_start_date_time=None):
        """Perform a GET request to /public/v{version}/payroll/commissions.

        A staff authorization token is not required for this endpoint, but if one is
        passed, its permissions are honored. Depending on the access permissions
        configured for the staff member whose token is passed,
        the endpoint returns either only the payroll information for that staff
        member or it returns the payroll information for all staff members.

        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_date_time (datetime, optional): The end of the date range for
                the payroll information to be returned. The maximum allowed date
                range is 14 days.<br />  Default: **Today’s date**  * If you do not
                supply an `EndDateTime`, the data returns for the period from the
                `StartDateTime` that you supply to today’s date.  * If you do not
                supply an `EndDateTime` or a `StartDateTime`, data returns for the
                seven days prior to today’s date.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_id (int, optional): A LocationId that you want to
                retrieve payroll information for. If you do not supply a
                `LocationId`, data from all locations is returned.
            request_offset (int, optional): Page offset, defaults to 0.
            request_staff_id (int, optional): A list of staff IDs that you want to
                retrieve payroll information for. If you do not supply a `StaffId`,
                all active staff members return, ordered by staff ID.
            request_start_date_time (datetime, optional): The beginning of the date
                range for the payroll information to be returned. The maximum allowed
                date range is 14 days.  * If you do not supply a `StartDateTime`,
                data returns for the seven days prior to the `EndDateTime` that you
                supply.  * If you do not supply either a `StartDateTime` or an
                `EndDateTime`, the data returns for seven days prior to today’s date.

        Returns:
            GetCommissionsResponse: 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}/payroll/commissions")
            .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.endDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_end_date_time)))
            .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.staffId")
                .value(request_staff_id))
            .query_param(Parameter()
                .key("request.startDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_start_date_time)))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetCommissionsResponse.from_dictionary),
        ).execute()

    def get_scheduled_service_earnings(self,
                                       version,
                                       site_id,
                                       authorization=None,
                                       request_end_date_time=None,
                                       request_limit=None,
                                       request_location_id=None,
                                       request_offset=None,
                                       request_scheduled_service_id=None,
                                       request_scheduled_service_type=None,
                                       request_staff_id=None,
                                       request_start_date_time=None):
        """Perform a GET request to
        /public/v{version}/payroll/scheduledserviceearnings.

        A staff authorization token is not required for this endpoint, but if one is
        passed, its permissions are honored. Depending on the access permissions
        configured for the staff member whose token is passed, the endpoint returns
        either only the payroll information for that staff member or it returns the
        payroll information for all staff members.
        Note that if a staff member is not paid for a class, earnings of zero are
        returned by this endpoint.
        Note that this endpoint calculates both bonus and no-reg rates for
        assistants.These rates are not supported by the Payroll report in the web
        interface.
        Note that this endpoint returns both the teacher’s adjusted rate and the
        assistant’s pay rate when the assistant is paid by the teacher.The Payroll
        report in the web interface only returns the teacher’s adjusted rate.

        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_date_time (datetime, optional): The end of the date range for
                the payroll information to be returned. The maximum allowed date
                range is 14 days.<br />  Default: **Today’s date**  * If you do not
                supply an `EndDateTime`, the data returns for the period from the
                `StartDateTime` that you supply to today’s date.  * If you do not
                supply an `EndDateTime` or a `StartDateTime`, data returns for the
                seven days prior to today’s date.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_id (int, optional): A LocationId that you want to
                retrieve payroll information for. If you do not supply a
                `LocationId`, data from all locations is returned.
            request_offset (int, optional): Page offset, defaults to 0.
            request_scheduled_service_id (int, optional): Filters the results to a
                single scheduled service. This parameter must be used with a single
                ScheduledServiceType.
            request_scheduled_service_type (str, optional): Filters the results to
                schedule service earnings for specific types of services. Possible
                values:  * Class  * Appointment
            request_staff_id (int, optional): A list of staff IDs that you want to
                retrieve payroll information for. If you do not supply a `StaffId`,
                all active staff members return, ordered by staff ID.
            request_start_date_time (datetime, optional): The beginning of the date
                range for the payroll information to be returned. The maximum allowed
                date range is 14 days.  * If you do not supply a `StartDateTime`,
                data returns for the seven days prior to the `EndDateTime` that you
                supply.  * If you do not supply either a `StartDateTime` or an
                `EndDateTime`, the data returns for seven days prior to today’s date.

        Returns:
            GetScheduledServiceEarningsResponse: 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}/payroll/scheduledserviceearnings")
            .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.endDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_end_date_time)))
            .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.scheduledServiceId")
                .value(request_scheduled_service_id))
            .query_param(Parameter()
                .key("request.scheduledServiceType")
                .value(request_scheduled_service_type))
            .query_param(Parameter()
                .key("request.staffId")
                .value(request_staff_id))
            .query_param(Parameter()
                .key("request.startDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_start_date_time)))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetScheduledServiceEarningsResponse.from_dictionary),
        ).execute()

    def get_time_cards(self,
                       version,
                       site_id,
                       authorization=None,
                       request_end_date_time=None,
                       request_limit=None,
                       request_location_id=None,
                       request_offset=None,
                       request_staff_id=None,
                       request_start_date_time=None):
        """Perform a GET request to /public/v{version}/payroll/timecards.

        This endpoint returns information for all locations. The **View reports for
        all locations permission **is not supported for staff auth tokens.

        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_date_time (datetime, optional): The end of the date range for
                the payroll information to be returned. The maximum allowed date
                range is 14 days.<br />  Default: **Today’s date**  * If you do not
                supply an `EndDateTime`, the data returns for the period from the
                `StartDateTime` that you supply to today’s date.  * If you do not
                supply an `EndDateTime` or a `StartDateTime`, data returns for the
                seven days prior to today’s date.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_id (int, optional): A LocationId that you want to
                retrieve payroll information for. If you do not supply a
                `LocationId`, data from all locations is returned.
            request_offset (int, optional): Page offset, defaults to 0.
            request_staff_id (int, optional): A list of staff IDs that you want to
                retrieve payroll information for. If you do not supply a `StaffId`,
                all active staff members return, ordered by staff ID.
            request_start_date_time (datetime, optional): The beginning of the date
                range for the payroll information to be returned. The maximum allowed
                date range is 14 days.  * If you do not supply a `StartDateTime`,
                data returns for the seven days prior to the `EndDateTime` that you
                supply.  * If you do not supply either a `StartDateTime` or an
                `EndDateTime`, the data returns for seven days prior to today’s date.

        Returns:
            GetTimeCardsResponse: 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}/payroll/timecards")
            .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.endDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_end_date_time)))
            .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.staffId")
                .value(request_staff_id))
            .query_param(Parameter()
                .key("request.startDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_start_date_time)))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetTimeCardsResponse.from_dictionary),
        ).execute()

    def get_tips(self,
                 version,
                 site_id,
                 authorization=None,
                 request_end_date_time=None,
                 request_limit=None,
                 request_location_id=None,
                 request_offset=None,
                 request_staff_id=None,
                 request_start_date_time=None):
        """Perform a GET request to /public/v{version}/payroll/tips.

        A staff authorization token is not required for this endpoint, but if one is
        passed, its permissions are honored. Depending on the access permissions
        configured for the staff member whose token is passed,
        the endpoint returns either only the payroll information for that staff
        member or it returns the payroll information for all staff members.
        This endpoint returns information for all locations.The** View reports for
        all locations **permission is not supported for staff auth tokens.

        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_date_time (datetime, optional): The end of the date range for
                the payroll information to be returned. The maximum allowed date
                range is 14 days.<br />  Default: **Today’s date**  * If you do not
                supply an `EndDateTime`, the data returns for the period from the
                `StartDateTime` that you supply to today’s date.  * If you do not
                supply an `EndDateTime` or a `StartDateTime`, data returns for the
                seven days prior to today’s date.
            request_limit (int, optional): Number of results to include, defaults to
                100
            request_location_id (int, optional): A LocationId that you want to
                retrieve payroll information for. If you do not supply a
                `LocationId`, data from all locations is returned.
            request_offset (int, optional): Page offset, defaults to 0.
            request_staff_id (int, optional): A list of staff IDs that you want to
                retrieve payroll information for. If you do not supply a `StaffId`,
                all active staff members return, ordered by staff ID.
            request_start_date_time (datetime, optional): The beginning of the date
                range for the payroll information to be returned. The maximum allowed
                date range is 14 days.  * If you do not supply a `StartDateTime`,
                data returns for the seven days prior to the `EndDateTime` that you
                supply.  * If you do not supply either a `StartDateTime` or an
                `EndDateTime`, the data returns for seven days prior to today’s date.

        Returns:
            GetTipsResponse: 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}/payroll/tips")
            .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.endDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_end_date_time)))
            .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.staffId")
                .value(request_staff_id))
            .query_param(Parameter()
                .key("request.startDateTime")
                .value(APIHelper.when_defined(APIHelper.RFC3339DateTime,
                    request_start_date_time)))
            .header_param(Parameter()
                .key("accept")
                .value("application/json"))
            .auth(Single("API-Key")),
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetTipsResponse.from_dictionary),
        ).execute()
