export type GetApiApiLeagueArgs = {name?: string | undefined, genre?: Array | undefined, subgenre?: Array | undefined, owner?: Array | undefined, withRelationships?: Array | undefined, order_by?: string | undefined, order?: string | undefined, paginated?: boolean | undefined, per_page?: number | undefined, page?: number | undefined, download?: boolean | undefined}; export type GetApiApiLeagueOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List leagues. * * GET /api/league */ export const getApiApiLeague = async (args: GetApiApiLeagueArgs, options: GetApiApiLeagueOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.name != null) query.append("name", String(args.name)) if (args.genre != null) query.append("genre", args.genre.join(',')) if (args.subgenre != null) query.append("subgenre", args.subgenre.join(',')) if (args.owner != null) query.append("owner", args.owner.join(',')) if (args.withRelationships != null) query.append("withRelationships", args.withRelationships.join(',')) if (args.order_by != null) query.append("order_by", String(args.order_by)) if (args.order != null) query.append("order", String(args.order)) if (args.paginated != null) query.append("paginated", String(args.paginated)) if (args.per_page != null) query.append("per_page", String(args.per_page)) if (args.page != null) query.append("page", String(args.page)) if (args.download != null) query.append("download", String(args.download)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/league${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };