export type CustomFieldWriteModel = {definitionId: number, value?: (string | null) | undefined}; export type JobAssistantModel = {resourceId?: number | undefined}; export type UpdateJobModel = {plannedDuration?: number | undefined, description?: string | undefined, reference?: (string | null) | undefined, personId?: (string | null) | undefined, orderNumber?: (string | null) | undefined, jobGroupId?: (number | null) | undefined, categoryId?: (number | null) | undefined, isFinanciallyComplete?: boolean | undefined, isActioned?: boolean | undefined, officeNotes?: (string | null) | undefined, customFields?: Array | undefined, assistants?: Array | undefined, siteContactId?: (number | null) | undefined}; export type PatchApiV1JobsJobIdArgs = {'Customer-Id': number, jobId: number, body: UpdateJobModel}; export type PatchApiV1JobsJobIdOptions = {baseUrl?: string | undefined, bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a job * * PATCH /v1/jobs/{jobId} */ export const patchApiV1JobsJobId = async (args: PatchApiV1JobsJobIdArgs, options?: PatchApiV1JobsJobIdOptions) => { const {baseUrl = "https://api.bigchange.com", fetch: fetchFn = fetch, bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Customer-Id'] != null) headers.set("Customer-Id", String(args['Customer-Id'])) if (bearer !== undefined) headers.set('authorization', `Bearer ${bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/jobs/${encodeURIComponent(String(args.jobId))}${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 };