1 |
|
2 | type Actimo = { |
3 | apiKey: string |
4 | } |
5 |
|
6 | export async function main( |
7 | auth: Actimo, |
8 | body: { |
9 | client_id?: number |
10 | credentials?: { |
11 | encryptionKey?: string |
12 | md5?: string |
13 | password?: string |
14 | username?: string |
15 | } |
16 | key?: string |
17 | type?: string |
18 | } & { |
19 | active?: false | true |
20 | id?: number |
21 | name?: string |
22 | settings?: { |
23 | syncPeriodDays?: number |
24 | syncTime?: { hour?: string; minute?: string } |
25 | syncType?: string |
26 | } |
27 | }[] |
28 | ) { |
29 | const url = new URL(`https://actimo.com/api/v1/integration/`) |
30 |
|
31 | const response = await fetch(url, { |
32 | method: 'PUT', |
33 | headers: { |
34 | 'api-key': auth.apiKey, |
35 | 'Content-Type': 'application/json' |
36 | }, |
37 | body: JSON.stringify(body) |
38 | }) |
39 |
|
40 | if (!response.ok) { |
41 | const text = await response.text() |
42 | throw new Error(`${response.status} ${text}`) |
43 | } |
44 |
|
45 | return await response.json() |
46 | } |
47 |
|