export type Operation = {op?: string | undefined, value?: Record | undefined, path?: string | undefined}; export type JsonPatchDocument = Array; export type PatchApiSchedulesIdArgs = {id: string, body: JsonPatchDocument}; export type PatchApiSchedulesIdOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Patch a schedule. Patch allows partial updates by targeting specific properties of the schedule. * Uses the JSON Patch syntax (http://jsonpatch.com) * * PATCH /schedules/{id} * * Also accepts auth: ApiKeyInHeader, ApiKeyInQuery */ export const patchApiSchedulesId = async (args: PatchApiSchedulesIdArgs, options?: PatchApiSchedulesIdOptions) => { const {baseUrl = "https://api.reveldigital.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json-patch+json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/schedules/${encodeURIComponent(String(args.id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", 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 };