# Generated by ariadne-codegen
# Source: queries/central-data

from typing import Any, Dict, List, Optional, Union

from .base_client import BaseClient
from .base_model import UNSET, UnsetType
from .enums import OrderDirection, SeriesType
from .get_available_games import GetAvailableGames
from .get_available_players import GetAvailablePlayers
from .get_available_teams import GetAvailableTeams
from .get_available_tournaments import GetAvailableTournaments
from .get_games import GetGames
from .get_lol_teams_by_team_code import GetLolTeamsByTeamCode
from .get_series import GetSeries
from .get_series_ids_by_team import GetSeriesIdsByTeam
from .input_types import ProductServiceLevelFilter, SeriesLiveFilter


def gql(q: str) -> str:
    return q


class Client(BaseClient):
    def get_available_games(
        self,
        game_type: Union[Optional[SeriesType], UnsetType] = UNSET,
        num_of_games: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> GetAvailableGames:
        query = gql(
            """
            query GetAvailableGames($gameType: SeriesType, $numOfGames: Int) {
              allSeries(
                filter: {type: $gameType}
                first: $numOfGames
                after: null
                before: null
                orderDirection: DESC
              ) {
                edges {
                  node {
                    id
                  }
                }
                pageInfo {
                  endCursor
                  hasNextPage
                }
                totalCount
              }
            }
            """
        )
        variables: Dict[str, object] = {
            "gameType": game_type,
            "numOfGames": num_of_games,
        }
        response = self.execute(
            query=query,
            operation_name="GetAvailableGames",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return GetAvailableGames.model_validate(data)

    def get_available_players(
        self,
        after: Union[Optional[Any], UnsetType] = UNSET,
        first: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> GetAvailablePlayers:
        query = gql(
            """
            query GetAvailablePlayers($after: Cursor, $first: Int) {
              players(after: $after, first: $first) {
                edges {
                  node {
                    id
                    nickname
                    externalLinks {
                      dataProvider {
                        name
                      }
                      externalEntity {
                        id
                      }
                    }
                    team {
                      id
                    }
                  }
                }
                pageInfo {
                  endCursor
                  hasNextPage
                  hasPreviousPage
                  startCursor
                }
                totalCount
              }
            }
            """
        )
        variables: Dict[str, object] = {"after": after, "first": first}
        response = self.execute(
            query=query,
            operation_name="GetAvailablePlayers",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return GetAvailablePlayers.model_validate(data)

    def get_available_teams(
        self,
        after: Union[Optional[Any], UnsetType] = UNSET,
        first: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> GetAvailableTeams:
        query = gql(
            """
            query GetAvailableTeams($after: Cursor, $first: Int) {
              teams(after: $after, first: $first) {
                totalCount
                edges {
                  node {
                    id
                    colorPrimary
                    colorSecondary
                    logoUrl
                    name
                    nameShortened
                    externalLinks {
                      externalEntity {
                        id
                      }
                      dataProvider {
                        description
                        name
                      }
                    }
                  }
                }
                pageInfo {
                  endCursor
                  hasNextPage
                  hasPreviousPage
                  startCursor
                }
              }
            }
            """
        )
        variables: Dict[str, object] = {"after": after, "first": first}
        response = self.execute(
            query=query,
            operation_name="GetAvailableTeams",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return GetAvailableTeams.model_validate(data)

    def get_available_tournaments(
        self,
        after: Union[Optional[Any], UnsetType] = UNSET,
        first: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> GetAvailableTournaments:
        query = gql(
            """
            query GetAvailableTournaments($after: Cursor, $first: Int) {
              tournaments(
                after: $after
                first: $first
                filter: {hasChildren: {equals: false}}
              ) {
                totalCount
                edges {
                  node {
                    id
                    name
                    startDate
                    endDate
                    nameShortened
                    logoUrl
                    externalLinks {
                      dataProvider {
                        description
                        name
                      }
                      externalEntity {
                        id
                      }
                    }
                  }
                }
                pageInfo {
                  endCursor
                  hasNextPage
                  hasPreviousPage
                  startCursor
                }
              }
            }
            """
        )
        variables: Dict[str, object] = {"after": after, "first": first}
        response = self.execute(
            query=query,
            operation_name="GetAvailableTournaments",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return GetAvailableTournaments.model_validate(data)

    def get_games(
        self,
        game_type: Union[Optional[SeriesType], UnsetType] = UNSET,
        num_of_games: Union[Optional[int], UnsetType] = UNSET,
        after_cursor: Union[Optional[Any], UnsetType] = UNSET,
        teams: Union[Optional[List[str]], UnsetType] = UNSET,
        **kwargs: Any
    ) -> GetGames:
        query = gql(
            """
            query GetGames($gameType: SeriesType, $numOfGames: Int, $afterCursor: Cursor, $teams: [ID!]) {
              allSeries(
                filter: {type: $gameType, teamIds: {in: $teams}}
                first: $numOfGames
                after: $afterCursor
                orderDirection: DESC
              ) {
                edges {
                  node {
                    id
                  }
                }
                pageInfo {
                  endCursor
                  hasNextPage
                }
                totalCount
              }
            }
            """
        )
        variables: Dict[str, object] = {
            "gameType": game_type,
            "numOfGames": num_of_games,
            "afterCursor": after_cursor,
            "teams": teams,
        }
        response = self.execute(
            query=query, operation_name="GetGames", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return GetGames.model_validate(data)

    def get_lol_teams_by_team_code(
        self, team_code: Union[Optional[str], UnsetType] = UNSET, **kwargs: Any
    ) -> GetLolTeamsByTeamCode:
        query = gql(
            """
            query GetLolTeamsByTeamCode($teamCode: String) {
              teams(filter: {nameShortened: {contains: $teamCode}, titleId: "3"}) {
                totalCount
                edges {
                  cursor
                  node {
                    id
                    colorPrimary
                    colorSecondary
                    logoUrl
                    name
                    nameShortened
                    externalLinks {
                      externalEntity {
                        id
                      }
                      dataProvider {
                        description
                        name
                      }
                    }
                  }
                }
              }
            }
            """
        )
        variables: Dict[str, object] = {"teamCode": team_code}
        response = self.execute(
            query=query,
            operation_name="GetLolTeamsByTeamCode",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return GetLolTeamsByTeamCode.model_validate(data)

    def get_series(
        self,
        order: OrderDirection,
        teams: Union[Optional[List[str]], UnsetType] = UNSET,
        game_types: Union[Optional[List[SeriesType]], UnsetType] = UNSET,
        tournaments: Union[Optional[List[str]], UnsetType] = UNSET,
        after: Union[Optional[Any], UnsetType] = UNSET,
        gte: Union[Optional[str], UnsetType] = UNSET,
        lte: Union[Optional[str], UnsetType] = UNSET,
        live: Union[Optional[SeriesLiveFilter], UnsetType] = UNSET,
        live_player_ids: Union[Optional[List[str]], UnsetType] = UNSET,
        private: Union[Optional[bool], UnsetType] = UNSET,
        product_service_levels: Union[
            Optional[ProductServiceLevelFilter], UnsetType
        ] = UNSET,
        title_ids: Union[Optional[List[str]], UnsetType] = UNSET,
        **kwargs: Any
    ) -> GetSeries:
        query = gql(
            """
            query GetSeries($teams: [ID!], $gameTypes: [SeriesType!], $tournaments: [ID!], $after: Cursor, $order: OrderDirection!, $gte: String, $lte: String, $live: SeriesLiveFilter, $livePlayerIds: [ID!], $private: Boolean, $productServiceLevels: ProductServiceLevelFilter, $titleIds: [ID!]) {
              allSeries(
                filter: {teamIds: {in: $teams}, types: $gameTypes, tournamentIds: {in: $tournaments}, startTimeScheduled: {gte: $gte, lte: $lte}, live: $live, livePlayerIds: {in: $livePlayerIds}, private: {equals: $private}, productServiceLevels: $productServiceLevels, titleIds: {in: $titleIds}}
                orderBy: StartTimeScheduled
                orderDirection: $order
                after: $after
              ) {
                totalCount
                edges {
                  node {
                    id
                    type
                    format {
                      id
                      name
                      nameShortened
                    }
                    externalLinks {
                      dataProvider {
                        description
                        name
                      }
                      externalEntity {
                        id
                      }
                    }
                    tournament {
                      id
                      endDate
                      logoUrl
                      name
                      nameShortened
                      startDate
                      externalLinks {
                        dataProvider {
                          description
                          name
                        }
                        externalEntity {
                          id
                        }
                      }
                    }
                    teams {
                      baseInfo {
                        id
                        colorPrimary
                        colorSecondary
                        externalLinks {
                          dataProvider {
                            description
                            name
                          }
                          externalEntity {
                            id
                          }
                        }
                        logoUrl
                        nameShortened
                        name
                      }
                    }
                    startTimeScheduled
                  }
                }
                pageInfo {
                  endCursor
                  hasNextPage
                  hasPreviousPage
                  startCursor
                }
              }
            }
            """
        )
        variables: Dict[str, object] = {
            "teams": teams,
            "gameTypes": game_types,
            "tournaments": tournaments,
            "after": after,
            "order": order,
            "gte": gte,
            "lte": lte,
            "live": live,
            "livePlayerIds": live_player_ids,
            "private": private,
            "productServiceLevels": product_service_levels,
            "titleIds": title_ids,
        }
        response = self.execute(
            query=query, operation_name="GetSeries", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return GetSeries.model_validate(data)

    def get_series_ids_by_team(
        self,
        gte: str,
        teams: Union[Optional[List[str]], UnsetType] = UNSET,
        game_types: Union[Optional[List[SeriesType]], UnsetType] = UNSET,
        tournaments: Union[Optional[List[str]], UnsetType] = UNSET,
        after: Union[Optional[Any], UnsetType] = UNSET,
        order: Union[Optional[OrderDirection], UnsetType] = UNSET,
        **kwargs: Any
    ) -> GetSeriesIdsByTeam:
        query = gql(
            """
            query GetSeriesIdsByTeam($teams: [ID!], $gameTypes: [SeriesType!], $tournaments: [ID!], $after: Cursor, $order: OrderDirection, $gte: String!) {
              allSeries(
                filter: {teamIds: {in: $teams}, types: $gameTypes, tournamentIds: {in: $tournaments}, startTimeScheduled: {gte: $gte}}
                orderBy: StartTimeScheduled
                orderDirection: $order
                after: $after
              ) {
                totalCount
                edges {
                  node {
                    id
                    type
                    tournament {
                      id
                      endDate
                      logoUrl
                      name
                      nameShortened
                      startDate
                    }
                    teams {
                      baseInfo {
                        id
                        name
                        nameShortened
                      }
                    }
                    startTimeScheduled
                  }
                }
                pageInfo {
                  endCursor
                  hasNextPage
                  hasPreviousPage
                  startCursor
                }
              }
            }
            """
        )
        variables: Dict[str, object] = {
            "teams": teams,
            "gameTypes": game_types,
            "tournaments": tournaments,
            "after": after,
            "order": order,
            "gte": gte,
        }
        response = self.execute(
            query=query,
            operation_name="GetSeriesIdsByTeam",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return GetSeriesIdsByTeam.model_validate(data)
