# 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.divisions import Divisions
from ..models.division import Division


class DivisionsService(BaseService):

    @cast_models
    def get_divisions(self) -> Divisions:
        """This only retrieves active divisions. For inactive divisions, use `/divisions/{id}`.

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

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

        response = self.send_request(serialized_request)

        return Divisions._unmap(response)

    @cast_models
    def get_division(self, id_: float) -> Division:
        """You can use this to also retrieve inactive divisions. For example, the ID for the old Patrick division is `13`.

        :param id_: The ID of the division.
        :type id_: float
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: OK
        :rtype: Division
        """

        Validator(float).validate(id_)

        serialized_request = (
            Serializer(f"{self.base_url}/divisions/{{id}}", self.get_default_headers())
            .add_path("id", id_)
            .serialize()
            .set_method("GET")
        )

        response = self.send_request(serialized_request)

        return Division._unmap(response)
