# This file was generated by liblab | https://liblab.com/

from .utils.validator import Validator
from .utils.base_service import BaseService
from ..net.transport.serializer import Serializer
from ..models.utils.cast_models import cast_models
from ..models.timeoff_type_list_container import TimeoffTypeListContainer
from ..models.seniority_list_container import SeniorityListContainer
from ..models.job_title_list_container import JobTitleListContainer
from ..models.currency_list_container import CurrencyListContainer
from ..models.country_list_container import CountryListContainer


class LookupsService(BaseService):

    @cast_models
    def get_countries(self) -> CountryListContainer:
        """Retrieve a list of countries supported by Deel.

        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Successful operation.
        :rtype: CountryListContainer
        """

        serialized_request = (
            Serializer(f"{self.base_url}/lookups/countries", self.get_default_headers())
            .serialize()
            .set_method("GET")
        )

        response = self.send_request(serialized_request)

        return CountryListContainer._unmap(response)

    @cast_models
    def get_currencies(self) -> CurrencyListContainer:
        """Retrieve the list of currencies used by Deel.

        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Successful operation.
        :rtype: CurrencyListContainer
        """

        serialized_request = (
            Serializer(
                f"{self.base_url}/lookups/currencies", self.get_default_headers()
            )
            .serialize()
            .set_method("GET")
        )

        response = self.send_request(serialized_request)

        return CurrencyListContainer._unmap(response)

    @cast_models
    def get_job_title_list(
        self, limit: float = None, after_cursor: str = None
    ) -> JobTitleListContainer:
        """Retrieve a list of pre-defined job titles in Deel platform.

        :param limit: Return a page of results with given number of records; NOTE: technically ALL query parameters are strings or array of strings, defaults to None
        :type limit: float, optional
        :param after_cursor: Return next page of results after given cursor, defaults to None
        :type after_cursor: str, optional
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Successful operation.
        :rtype: JobTitleListContainer
        """

        Validator(float).is_optional().min(20).max(99).validate(limit)
        Validator(str).is_optional().validate(after_cursor)

        serialized_request = (
            Serializer(
                f"{self.base_url}/lookups/job-titles", self.get_default_headers()
            )
            .add_query("limit", limit)
            .add_query("after_cursor", after_cursor)
            .serialize()
            .set_method("GET")
        )

        response = self.send_request(serialized_request)

        return JobTitleListContainer._unmap(response)

    @cast_models
    def get_seniority_list(self, limit: float = None) -> SeniorityListContainer:
        """Retrieve a list of pre-defined seniority level for roles in Deel platform.

        :param limit: Return a page of results with given number of records; NOTE: technically ALL query parameters are strings or array of strings, defaults to None
        :type limit: float, optional
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Successful operation.
        :rtype: SeniorityListContainer
        """

        Validator(float).is_optional().min(20).max(99).validate(limit)

        serialized_request = (
            Serializer(
                f"{self.base_url}/lookups/seniorities", self.get_default_headers()
            )
            .add_query("limit", limit)
            .serialize()
            .set_method("GET")
        )

        response = self.send_request(serialized_request)

        return SeniorityListContainer._unmap(response)

    @cast_models
    def get_timeoff_type_list(self) -> TimeoffTypeListContainer:
        """Retrieve a list of pre-defined time off types to register in Deel platform.

        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Successful operation.
        :rtype: TimeoffTypeListContainer
        """

        serialized_request = (
            Serializer(
                f"{self.base_url}/lookups/time-off-types", self.get_default_headers()
            )
            .serialize()
            .set_method("GET")
        )

        response = self.send_request(serialized_request)

        return TimeoffTypeListContainer._unmap(response)
