export type PatchApiV2DeviceIdArgs = {id: number, body: {displayName?: string | undefined, userData?: {[key: string]: unknown} | undefined, nodeRoleId?: number | undefined, policyId?: number | undefined, organizationId?: number | undefined, locationId?: number | undefined, warranty?: ({startDate?: number | undefined, endDate?: number | undefined, manufacturerFulfillmentDate?: number | undefined}) | undefined}}; export type PatchApiV2DeviceIdOptions = {baseUrl: string, oauth2?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update device information * * PATCH /v2/device/{id} */ export const patchApiV2DeviceId = async (args: PatchApiV2DeviceIdArgs, options: PatchApiV2DeviceIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, oauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") if (oauth2 !== undefined) headers.set('authorization', `Bearer ${oauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/v2/device/${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 res.blob() };