export type LabelDto = {name: string, color: string}; export type LoRaDeviceModelDto = {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, modelId?: (string | null) | undefined, image?: (string | null) | undefined, name: string, description?: (string | null) | undefined, isBuiltin?: boolean | undefined, supportLoRaFeatures?: boolean | undefined, useOTAA?: boolean | undefined, downlink?: (boolean | null) | undefined, labels?: (Array | null) | undefined}; export type CreateApiApiLorawanModelsArgs = {body: LoRaDeviceModelDto}; export type CreateApiApiLorawanModelsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Creates the specified device model. * * POST /api/lorawan/models */ export const createApiApiLorawanModels = async (args: CreateApiApiLorawanModelsArgs, options: CreateApiApiLorawanModelsOptions) => { 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/models${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 };