# 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.create_admin_user_response_container import (
    CreateAdminUserResponseContainer,
)
from ..models.admin_users_container import AdminUsersContainer
from ..models.admin_user_create_container import AdminUserCreateContainer


class ManagersService(BaseService):

    @cast_models
    def get_managers(
        self, limit: str = None, offset: str = None
    ) -> AdminUsersContainer:
        """List all organization managers.

        :param limit: Maximum number of records to return., defaults to None
        :type limit: str, optional
        :param offset: Offset/index of record for the next page of records to return., defaults to None
        :type offset: str, optional
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Basic information of the new admin user.
        :rtype: AdminUsersContainer
        """

        Validator(str).is_optional().validate(limit)
        Validator(str).is_optional().validate(offset)

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

        response = self.send_request(serialized_request)

        return AdminUsersContainer._unmap(response)

    @cast_models
    def create_manager(
        self, request_body: AdminUserCreateContainer
    ) -> CreateAdminUserResponseContainer:
        """Create a new organization manager.

        :param request_body: The request body.
        :type request_body: AdminUserCreateContainer
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Basic information of the new admin user.
        :rtype: CreateAdminUserResponseContainer
        """

        Validator(AdminUserCreateContainer).validate(request_body)

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

        response = self.send_request(serialized_request)

        return CreateAdminUserResponseContainer._unmap(response)
