export type GetApiApiLeagueLeagueIdOrganizationsArgs = {league_id: number, order_by?: ('organization' | 'types' | 'contract_statuses') | undefined, order_direction?: ('asc' | 'desc') | undefined, types?: Array | undefined, contract_statuses?: Array | undefined, page?: number | undefined, per_page?: number | undefined}; export type GetApiApiLeagueLeagueIdOrganizationsOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * List a league's organizations. * * GET /api/league/{league_id}/organizations */ export const getApiApiLeagueLeagueIdOrganizations = async (args: GetApiApiLeagueLeagueIdOrganizationsArgs, options: GetApiApiLeagueLeagueIdOrganizationsOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.order_by != null) query.append("order_by", String(args.order_by)) if (args.order_direction != null) query.append("order_direction", String(args.order_direction)) if (args.types != null) query.append("types", args.types.join(',')) if (args.contract_statuses != null) query.append("contract_statuses", args.contract_statuses.join(',')) if (args.page != null) query.append("page", String(args.page)) if (args.per_page != null) query.append("per_page", String(args.per_page)) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/league/${encodeURIComponent(String(args.league_id))}/organizations${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 };