export type LabelDto = {name: string, color: string}; export type LoRaDeviceDetails = {classType?: ('A' | 'C') | undefined, preferredWindow?: number | undefined, deduplication?: ('None' | 'Drop' | 'Mark') | undefined, rX1DROffset?: (number | null) | undefined, rX2DataRate?: (number | null) | undefined, rxDelay?: (number | null) | undefined, abpRelaxMode?: (boolean | null) | undefined, fCntUpStart?: (number | null) | undefined, fCntDownStart?: (number | null) | undefined, fCntResetCounter?: (number | null) | undefined, supports32BitFCnt?: (boolean | null) | undefined, keepAliveTimeout?: (number | null) | undefined, sensorDecoder?: (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, deviceID: string, useOTAA?: boolean | undefined, appKey?: (string | null) | undefined, appEUI?: (string | null) | undefined, appSKey?: (string | null) | undefined, nwkSKey?: (string | null) | undefined, devAddr?: (string | null) | undefined, alreadyLoggedInOnce?: boolean | undefined, dataRate?: (string | null) | undefined, txPower?: (string | null) | undefined, nbRep?: (string | null) | undefined, reportedRX2DataRate?: (string | null) | undefined, reportedRX1DROffset?: (string | null) | undefined, reportedRXDelay?: (string | null) | undefined, gatewayID?: (string | null) | undefined, layerId?: (string | null) | undefined, downlink?: (boolean | null) | undefined, labels?: (Array | null) | undefined}; export type CreateApiApiLorawanDevicesArgs = {body: LoRaDeviceDetails}; export type CreateApiApiLorawanDevicesOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Creates the device. * * POST /api/lorawan/devices */ export const createApiApiLorawanDevices = async (args: CreateApiApiLorawanDevicesArgs, options: CreateApiApiLorawanDevicesOptions) => { 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/lorawan/devices${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };