1 | |
2 | type Gitbook = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update an organization invite |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Gitbook, |
11 | organizationId: string, |
12 | inviteId: string, |
13 | body: |
14 | | { role: "admin" | "create" | "edit" | "review" | "comment" | "read" } |
15 | | { level: "admin" | "create" | "edit" | "review" | "comment" | "read" }, |
16 | ) { |
17 | const url = new URL( |
18 | `https://api.gitbook.com/v1/orgs/${organizationId}/link-invites/${inviteId}`, |
19 | ); |
20 |
|
21 | const response = await fetch(url, { |
22 | method: "PATCH", |
23 | headers: { |
24 | "Content-Type": "application/json", |
25 | Authorization: "Bearer " + auth.token, |
26 | }, |
27 | body: JSON.stringify(body), |
28 | }); |
29 | if (!response.ok) { |
30 | const text = await response.text(); |
31 | throw new Error(`${response.status} ${text}`); |
32 | } |
33 | return await response.json(); |
34 | } |
35 |
|