export type UpdateApiApiV3LoadsIdRunArgs = {id: number, body: {date_from?: string | undefined, date_to?: string | undefined}}; export type UpdateApiApiV3LoadsIdRunOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Run a load * * PUT /api/v3/loads/{id}/run */ export const updateApiApiV3LoadsIdRun = async (args: UpdateApiApiV3LoadsIdRunArgs, options?: UpdateApiApiV3LoadsIdRunOptions) => { const {baseUrl = "https://embedded.improvado.io", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/v3/loads/${encodeURIComponent(String(args.id))}/run${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };