1 |
|
2 | type Actimo = { |
3 | apiKey: string |
4 | } |
5 |
|
6 | export async function main(auth: Actimo, id: string, force: string | undefined) { |
7 | const url = new URL(`https://actimo.com/api/v1/decisiongraphs/${id}`) |
8 | for (const [k, v] of [['force', force]]) { |
9 | if (v !== undefined && v !== '' && k !== undefined) { |
10 | url.searchParams.append(k, v) |
11 | } |
12 | } |
13 | const response = await fetch(url, { |
14 | method: 'DELETE', |
15 | headers: { |
16 | 'api-key': auth.apiKey |
17 | }, |
18 | body: undefined |
19 | }) |
20 |
|
21 | if (!response.ok) { |
22 | const text = await response.text() |
23 | throw new Error(`${response.status} ${text}`) |
24 | } |
25 |
|
26 | return await response.json() |
27 | } |
28 |
|