/
SDB.ts
49 lines (45 loc) · 1.52 KB
/
SDB.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import TagoIOModule, { GenericModuleParams } from "../../common/TagoIOModule";
class SDB extends TagoIOModule<GenericModuleParams> {
/**
* Retrieves a custom parameter of a Run user.
* The Run user is identified by the token in the constructor.
* @param tagoRunURL TagoIO Run url without http
* @param key Identifier of the parameter
*/
public async getItem(tagoRunURL: string, key: string): Promise<any> {
const result = await this.doRequest<any>({
path: `/run/${tagoRunURL}/sdb/${key}`,
method: "GET",
});
return result;
}
/**
* Creates or updates a custom parameter of a Run user.
* The Run user is identified by the token in the constructor.
* @param tagoRunURL TagoIO Run url without http
* @param key Identifier of the parameter
* @param value Value of the parameter
*/
public async setItem(tagoRunURL: string, key: string, value: string): Promise<any> {
const result = await this.doRequest<any>({
path: `/run/${tagoRunURL}/sdb/${key}`,
method: "POST",
body: value,
});
return result;
}
/**
* Delete a custom parameter of a Run user.
* The Run user is identified by the token in the constructor.
* @param tagoRunURL TagoIO Run url without http
* @param key Identifier of the parameter
*/
public async removeItem(tagoRunURL: string, key: string): Promise<any> {
const result = await this.doRequest<any>({
path: `/run/${tagoRunURL}/sdb/${key}`,
method: "DELETE",
});
return result;
}
}
export default SDB;