import qs from 'querystringify' import {Base, NevoboResponse, Pagination} from "../base"; import {Poule, PouleIndeling} from "./types"; export class Poules extends Base { getPoule(poule: string): Promise> { if (poule === "") { return this.getArgumentErrorPromise("Poule cannot be empty. If you want all poules, use getAllPoules() instead.") } return this.request(`competitie/poules/${poule}`); } /** * @param team if team is not valid, this request returns the first page of getAllPoules() */ getPoulesForTeam(team: string): Promise> { if (team === "") { return this.getArgumentErrorPromise("Teams cannot be empty. If you want all poules, use getAllPoules() instead.") } return this.request(`competitie/poules/?team=${team}`, true); } /** * Poules requires pagination, the limit per page is 1000 * @param pagination */ getAllPoules(pagination: Pagination): Promise> { const endpoint = `competitie/poules/` + qs.stringify(pagination, '?'); return this.request(endpoint, true); } /** * Get the standings of all teams in a Poule. * I don't know why they named it like this. * @param poule */ getPouleIndelingen(poule: string): Promise> { if (poule === "") { return this.getArgumentErrorPromise("Poule cannot be empty.") } const endpoint = `competitie/pouleindelingen/?poule=${poule}`; return this.request(endpoint, true); } }