import qs from 'querystringify' import {Base, NevoboResponse, Pagination} from "../base"; import {Team} from "./types"; export class Teams extends Base { /** * @param team */ getTeam(team: string): Promise> { if (team === "") { return this.getArgumentErrorPromise("Team cannot be empty. If you want all teams, use getAllTeams() instead.") } return this.request(`competitie/teams/${team}`); } /** * Get all teams belonging to a Vereniging. If vereniging is not valid, this request returns the first page of getAllTeams() * @param vereniging */ getTeamsForVereniging(vereniging: string): Promise> { if (vereniging === "") { return this.getArgumentErrorPromise("Vereniging cannot be empty. If you want all teams, use getAllTeams() instead.") } const endpoint = `competitie/teams/?vereniging=${vereniging}`; return this.request(endpoint, true); } /** * Teams requires pagination, the limit per page is 1000 * @param pagination */ getAllTeams(pagination: Pagination): Promise> { const endpoint = `competitie/teams/` + qs.stringify(pagination, '?'); return this.request(endpoint, true); } }