export type LeagueStoreRequest = {name?: (string | null) | undefined, short_name?: (string | null) | undefined, currency?: (string | null) | undefined, logo_url?: (string | null) | undefined, website_url?: (string | null) | undefined, sport_id?: (number | null) | undefined, owner_id?: (number | null) | undefined, scouting_priority?: (number | null) | undefined, platforms_scouted?: (number | null) | undefined, times_scouted_per_year?: (number | null) | undefined, genre_id?: (number | null) | undefined, subgenre_id?: (number | null) | undefined, release_date?: (string | null) | undefined, start_date?: (string | null) | undefined, end_date?: (string | null) | undefined, social_start_date?: (string | null) | undefined, social_end_date?: (string | null) | undefined, notes?: (string | null) | undefined, assistants?: Array | undefined, is_continuous?: boolean | undefined, separator_text?: (string | null) | undefined}; export type CreateApiApiLeagueArgs = {body: LeagueStoreRequest}; export type CreateApiApiLeagueOptions = {baseUrl: string, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create a league. * * POST /api/league */ export const createApiApiLeague = async (args: CreateApiApiLeagueArgs, options: CreateApiApiLeagueOptions) => { const {baseUrl, fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/league${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };