1 | |
2 | type Gitbook = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update glossary entries |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Gitbook, |
11 | organizationId: string, |
12 | body: { |
13 | operations: |
14 | | { type: "insert"; translations: {} } |
15 | | { type: "update"; id: string; translations: {} } |
16 | | { type: "delete"; id: string }[]; |
17 | }, |
18 | ) { |
19 | const url = new URL( |
20 | `https://api.gitbook.com/v1/orgs/${organizationId}/translations-glossary`, |
21 | ); |
22 |
|
23 | const response = await fetch(url, { |
24 | method: "PUT", |
25 | headers: { |
26 | "Content-Type": "application/json", |
27 | Authorization: "Bearer " + auth.token, |
28 | }, |
29 | body: JSON.stringify(body), |
30 | }); |
31 | if (!response.ok) { |
32 | const text = await response.text(); |
33 | throw new Error(`${response.status} ${text}`); |
34 | } |
35 | return await response.text(); |
36 | } |
37 |
|