-
Notifications
You must be signed in to change notification settings - Fork 2
/
getSketch.ts
34 lines (31 loc) · 984 Bytes
/
getSketch.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import axios from 'axios';
import { OpenSenseMapID } from '../globalTypes';
/**
* @see https://docs.opensensemap.org/#api-Boxes-getSketch
*/
export async function getSketch(senseBoxId: OpenSenseMapID, authorization: string, options?: GetSketchOptions): Promise<GetSketchResult> {
return (
await axios.get(`https://api.opensensemap.org/boxes/${senseBoxId}/script`, {
headers: {
Authorization: `Bearer ${authorization}`
},
params: options
})
).data;
}
export type GetSketchOptions = {
serialPort?: 'Serial1' | 'Serial2';
soilDigitalPort?: 'A' | 'B' | 'C';
soundMeterPort?: 'A' | 'B' | 'C';
windSpeedPort?: 'A' | 'B' | 'C';
ssid?: string;
password?: string;
devEUI?: string;
appEUI?: string;
appKey?: string;
display_enabled?: boolean;
};
/**
* @linkcode https://github.com/sensebox/openSenseMap-API/blob/2e645bdc4c80e668720b5eaaf384a35d2909569e/packages/api/lib/controllers/boxesController.js#L469C21-L469C21
*/
export type GetSketchResult = string;