export type LabelDto = {name: string, color: string}; export type DeviceDetails = {deviceID?: (string | null) | undefined, deviceName: string, modelId: string, modelName?: (string | null) | undefined, image?: (string | null) | undefined, isConnected?: boolean | undefined, isEnabled?: boolean | undefined, statusUpdatedTime?: string | undefined, lastActivityTime?: string | undefined, tags?: ({[key: string]: string | null} | null) | undefined, isLoraWan?: boolean | undefined, labels?: (Array | null) | undefined, layerId?: (string | null) | undefined}; export type UpdateApiApiDevicesArgs = {body: DeviceDetails}; export type UpdateApiApiDevicesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Updates the device. * * PUT /api/devices */ export const updateApiApiDevices = async (args: UpdateApiApiDevicesArgs, options: UpdateApiApiDevicesOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/api/devices${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };