1 | |
2 | type Intercom = { |
3 | apiVersion: string |
4 | token: string |
5 | } |
6 | |
7 | * Create a collection |
8 | * You can create a new collection by making a POST request to `https://api.intercom.io/help_center/collections.` |
9 | */ |
10 | export async function main( |
11 | auth: Intercom, |
12 | body: { |
13 | name: string |
14 | description?: string |
15 | translated_content?: { |
16 | type?: 'group_translated_content' |
17 | ar?: { type?: 'group_content'; name?: string; description?: string } |
18 | bg?: { type?: 'group_content'; name?: string; description?: string } |
19 | bs?: { type?: 'group_content'; name?: string; description?: string } |
20 | ca?: { type?: 'group_content'; name?: string; description?: string } |
21 | cs?: { type?: 'group_content'; name?: string; description?: string } |
22 | da?: { type?: 'group_content'; name?: string; description?: string } |
23 | de?: { type?: 'group_content'; name?: string; description?: string } |
24 | el?: { type?: 'group_content'; name?: string; description?: string } |
25 | en?: { type?: 'group_content'; name?: string; description?: string } |
26 | es?: { type?: 'group_content'; name?: string; description?: string } |
27 | et?: { type?: 'group_content'; name?: string; description?: string } |
28 | fi?: { type?: 'group_content'; name?: string; description?: string } |
29 | fr?: { type?: 'group_content'; name?: string; description?: string } |
30 | he?: { type?: 'group_content'; name?: string; description?: string } |
31 | hr?: { type?: 'group_content'; name?: string; description?: string } |
32 | hu?: { type?: 'group_content'; name?: string; description?: string } |
33 | id?: { type?: 'group_content'; name?: string; description?: string } |
34 | it?: { type?: 'group_content'; name?: string; description?: string } |
35 | ja?: { type?: 'group_content'; name?: string; description?: string } |
36 | ko?: { type?: 'group_content'; name?: string; description?: string } |
37 | lt?: { type?: 'group_content'; name?: string; description?: string } |
38 | lv?: { type?: 'group_content'; name?: string; description?: string } |
39 | mn?: { type?: 'group_content'; name?: string; description?: string } |
40 | nb?: { type?: 'group_content'; name?: string; description?: string } |
41 | nl?: { type?: 'group_content'; name?: string; description?: string } |
42 | pl?: { type?: 'group_content'; name?: string; description?: string } |
43 | pt?: { type?: 'group_content'; name?: string; description?: string } |
44 | ro?: { type?: 'group_content'; name?: string; description?: string } |
45 | ru?: { type?: 'group_content'; name?: string; description?: string } |
46 | sl?: { type?: 'group_content'; name?: string; description?: string } |
47 | sr?: { type?: 'group_content'; name?: string; description?: string } |
48 | sv?: { type?: 'group_content'; name?: string; description?: string } |
49 | tr?: { type?: 'group_content'; name?: string; description?: string } |
50 | vi?: { type?: 'group_content'; name?: string; description?: string } |
51 | 'pt-BR'?: { type?: 'group_content'; name?: string; description?: string } |
52 | 'zh-CN'?: { type?: 'group_content'; name?: string; description?: string } |
53 | 'zh-TW'?: { type?: 'group_content'; name?: string; description?: string } |
54 | } |
55 | parent_id?: string |
56 | help_center_id?: number |
57 | } |
58 | ) { |
59 | const url = new URL(`https://api.intercom.io/help_center/collections`) |
60 |
|
61 | const response = await fetch(url, { |
62 | method: 'POST', |
63 | headers: { |
64 | 'Intercom-Version': auth.apiVersion, |
65 | 'Content-Type': 'application/json', |
66 | Authorization: 'Bearer ' + auth.token |
67 | }, |
68 | body: JSON.stringify(body) |
69 | }) |
70 | if (!response.ok) { |
71 | const text = await response.text() |
72 | throw new Error(`${response.status} ${text}`) |
73 | } |
74 | return await response.json() |
75 | } |
76 |
|