export type Id = number; export type PatchApiFaultsIdArgs = {id: string, body: {vehicle_id?: Id | undefined, code?: string | undefined, count?: number | undefined, description?: string | undefined, external_id?: string | undefined, last_occurred_at?: string | undefined, name?: string | undefined, status?: ('open' | 'resolved' | 'ignored') | undefined, source?: string | undefined}}; export type PatchApiFaultsIdOptions = {baseUrl?: string | undefined, apiKey?: string | undefined, accountToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Fault * * PATCH /faults/{id} */ export const patchApiFaultsId = async (args: PatchApiFaultsIdArgs, options?: PatchApiFaultsIdOptions) => { const {baseUrl = "https://secure.fleetio.com/api", fetch: fetchFn = fetch, apiKey, accountToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (apiKey !== undefined) headers.set("Authorization", apiKey) if (accountToken !== undefined) headers.set("Account-Token", accountToken) const url = `${baseUrl.replace(/\/+$/, '')}/faults/${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 };