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 | ) { |
20 | const url = new URL(`https://actimo.com/api/v1/integration/test`) |
21 |
|
22 | const response = await fetch(url, { |
23 | method: 'PUT', |
24 | headers: { |
25 | 'api-key': auth.apiKey, |
26 | 'Content-Type': 'application/json' |
27 | }, |
28 | body: JSON.stringify(body) |
29 | }) |
30 |
|
31 | if (!response.ok) { |
32 | const text = await response.text() |
33 | throw new Error(`${response.status} ${text}`) |
34 | } |
35 |
|
36 | return await response.json() |
37 | } |
38 |
|