export type DeviceIntegrationProfileKey = {id?: string | undefined, majorVersion?: number | undefined}; export type ProvisioningState = 'PROVISIONED' | 'TYPED' | 'DRIVER_SWITCH' | 'NONFUNCTIONAL'; export type EdgeDeviceUpdateRequest = {driverId: string, deviceIntegrationProfileKey?: DeviceIntegrationProfileKey | undefined, provisioningState?: ProvisioningState | undefined}; export type PatchApiHubdevicesHubDeviceIdChilddeviceDeviceIdArgs = {Authorization: unknown, hubDeviceId: unknown, deviceId: string, forceUpdate?: boolean | undefined, body: EdgeDeviceUpdateRequest}; export type PatchApiHubdevicesHubDeviceIdChilddeviceDeviceIdOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update Device Record For Hub Device * * PATCH /hubdevices/{hubDeviceId}/childdevice/{deviceId} */ export const patchApiHubdevicesHubDeviceIdChilddeviceDeviceId = async (args: PatchApiHubdevicesHubDeviceIdChilddeviceDeviceIdArgs, options?: PatchApiHubdevicesHubDeviceIdChilddeviceDeviceIdOptions) => { const {baseUrl = "https://api.smartthings.com/v1", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args.forceUpdate != null) query.append("forceUpdate", String(args.forceUpdate)) if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/hubdevices/${encodeURIComponent(String(args.hubDeviceId))}/childdevice/${encodeURIComponent(String(args.deviceId))}${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 };