export type Operation = {path?: (string | null) | undefined, op?: (string | null) | undefined, from?: (string | null) | undefined, value: unknown}; export type PatchApiJobsIdArgs = {id: string, body: Array}; export type PatchApiJobsIdOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Patches a Job record referenced by ID using JsonPatch. See https://jsonpatch.com/ for details. * * PATCH /jobs/{id} */ export const patchApiJobsId = async (args: PatchApiJobsIdArgs, options?: PatchApiJobsIdOptions) => { const {baseUrl = "https://api.iris.co.uk/hr/v2", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/jobs/${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 };