1 | |
2 | type Adhook = { |
3 | token: string |
4 | } |
5 |
|
6 | export async function main( |
7 | auth: Adhook, |
8 | Origin: string, |
9 | body: { |
10 | id?: string |
11 | userId?: string |
12 | tenantId?: string |
13 | subtenantId?: string |
14 | text?: string |
15 | color?: string |
16 | } |
17 | ) { |
18 | const url = new URL(`https://app.adhook.io/v1/tags`) |
19 |
|
20 | const response = await fetch(url, { |
21 | method: 'POST', |
22 | headers: { |
23 | Authorization: `Bearer ${auth.token}`, |
24 | Origin: Origin, |
25 | 'Content-Type': 'application/json' |
26 | }, |
27 | body: JSON.stringify(body) |
28 | }) |
29 |
|
30 | if (!response.ok) { |
31 | const text = await response.text() |
32 | throw new Error(`${response.status} ${text}`) |
33 | } |
34 |
|
35 | return await response.json() |
36 | } |
37 |
|