export type ScheduleDto = {id?: (string | null) | undefined, start?: (string | null) | undefined, end?: (string | null) | undefined, commandId?: (string | null) | undefined, planningId?: (string | null) | undefined}; export type CreateApiApiScheduleArgs = {body: ScheduleDto}; export type CreateApiApiScheduleOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Creates the schedule. * * POST /api/schedule */ export const createApiApiSchedule = async (args: CreateApiApiScheduleArgs, options: CreateApiApiScheduleOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/schedule${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 };