# 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.division import Division
from ..models.conferences import Conferences


class ConferencesService(BaseService):

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

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

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

        response = self.send_request(serialized_request)

        return Conferences._unmap(response)

    @cast_models
    def get_conference(self, id_: float) -> Division:
        """You can use this to also retrieve inactive conferences. For example, the ID for the World Cup of Hockey is `7`.

        :param id_: The ID of the conference.
        :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}/conferences/{{id}}", self.get_default_headers()
            )
            .add_path("id", id_)
            .serialize()
            .set_method("GET")
        )

        response = self.send_request(serialized_request)

        return Division._unmap(response)
