# 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.hris_position_to_change_container import HrisPositionToChangeContainer
from ..models.get_hris_position_container import GetHrisPositionContainer


class PositionsService(BaseService):

    @cast_models
    def get_positions(self, hris_profile_id: str) -> GetHrisPositionContainer:
        """HRIS Positions from a HrisProfile.

        :param hris_profile_id: HRIS Profile ID.
        :type hris_profile_id: str
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Successful response.
        :rtype: GetHrisPositionContainer
        """

        Validator(str).validate(hris_profile_id)

        serialized_request = (
            Serializer(
                f"{self.base_url}/hris/positions/profile/{{hrisProfile_id}}",
                self.get_default_headers(),
            )
            .add_path("hrisProfile_id", hris_profile_id)
            .serialize()
            .set_method("GET")
        )

        response = self.send_request(serialized_request)

        return GetHrisPositionContainer._unmap(response)

    @cast_models
    def apply_changes_positions(self, request_body: HrisPositionToChangeContainer):
        """Apply add, edit, and delete operations to profiles.

        :param request_body: The request body.
        :type request_body: HrisPositionToChangeContainer
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        """

        Validator(HrisPositionToChangeContainer).validate(request_body)

        serialized_request = (
            Serializer(
                f"{self.base_url}/hris/positions/apply_changes",
                self.get_default_headers(),
            )
            .serialize()
            .set_method("POST")
            .set_body(request_body)
        )

        response = self.send_request(serialized_request)

        return response
