# 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


class TeamsService(BaseService):

    @cast_models
    def get_team_information(self, lang: str) -> dict:
        """Retrieve list of all teams.

        :param lang: Language code
        :type lang: str
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Successful response
        :rtype: dict
        """

        Validator(str).validate(lang)

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

        response = self.send_request(serialized_request)

        return response

    @cast_models
    def get_team_stats(
        self,
        report: str,
        lang: str,
        is_aggregate: bool = None,
        is_game: bool = None,
        fact_cayenne_exp: str = None,
        include: str = None,
        exclude: str = None,
        cayenne_exp: str = None,
        sort: str = None,
        dir: str = None,
        start: int = None,
        limit: int = None,
    ) -> dict:
        """Retrieve team stats for a specific report.

        :param report: Team report
        :type report: str
        :param lang: Language code
        :type lang: str
        :param is_aggregate: Optional, defaults to None
        :type is_aggregate: bool, optional
        :param is_game: Optional, defaults to None
        :type is_game: bool, optional
        :param fact_cayenne_exp: Optional, defaults to None
        :type fact_cayenne_exp: str, optional
        :param include: Optional, defaults to None
        :type include: str, optional
        :param exclude: Optional, defaults to None
        :type exclude: str, optional
        :param cayenne_exp: Optional, defaults to None
        :type cayenne_exp: str, optional
        :param sort: Optional, defaults to None
        :type sort: str, optional
        :param dir: Optional, defaults to None
        :type dir: str, optional
        :param start: Optional, defaults to None
        :type start: int, optional
        :param limit: Optional (Note: a limit of -1 will return all results), defaults to None
        :type limit: int, optional
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Successful response
        :rtype: dict
        """

        Validator(str).validate(report)
        Validator(str).validate(lang)
        Validator(bool).is_optional().validate(is_aggregate)
        Validator(bool).is_optional().validate(is_game)
        Validator(str).is_optional().validate(fact_cayenne_exp)
        Validator(str).is_optional().validate(include)
        Validator(str).is_optional().validate(exclude)
        Validator(str).is_optional().validate(cayenne_exp)
        Validator(str).is_optional().validate(sort)
        Validator(str).is_optional().validate(dir)
        Validator(int).is_optional().validate(start)
        Validator(int).is_optional().validate(limit)

        serialized_request = (
            Serializer(
                f"{self.base_url}/{{lang}}/team/{{report}}", self.get_default_headers()
            )
            .add_path("report", report)
            .add_path("lang", lang)
            .add_query("isAggregate", is_aggregate)
            .add_query("isGame", is_game)
            .add_query("factCayenneExp", fact_cayenne_exp)
            .add_query("include", include)
            .add_query("exclude", exclude)
            .add_query("cayenneExp", cayenne_exp)
            .add_query("sort", sort)
            .add_query("dir", dir)
            .add_query("start", start)
            .add_query("limit", limit)
            .serialize()
            .set_method("GET")
        )

        response = self.send_request(serialized_request)

        return response

    @cast_models
    def get_franchise_information(self, lang: str) -> dict:
        """Retrieve list of all franchises.

        :param lang: Language code
        :type lang: str
        ...
        :raises RequestError: Raised when a request fails, with optional HTTP status code and details.
        ...
        :return: Successful response
        :rtype: dict
        """

        Validator(str).validate(lang)

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

        response = self.send_request(serialized_request)

        return response
