1 | type Github = { |
2 | token: string; |
3 | }; |
4 | |
5 | * Update a repository invitation |
6 | * |
7 | */ |
8 | export async function main( |
9 | auth: Github, |
10 | owner: string, |
11 | repo: string, |
12 | invitation_id: string, |
13 | body: { |
14 | permissions?: "read" | "write" | "maintain" | "triage" | "admin"; |
15 | [k: string]: unknown; |
16 | } |
17 | ) { |
18 | const url = new URL( |
19 | `https://api.github.com/repos/${owner}/${repo}/invitations/${invitation_id}` |
20 | ); |
21 |
|
22 | const response = await fetch(url, { |
23 | method: "PATCH", |
24 | headers: { |
25 | "Content-Type": "application/json", |
26 | Authorization: "Bearer " + auth.token, |
27 | }, |
28 | body: JSON.stringify(body), |
29 | }); |
30 | if (!response.ok) { |
31 | const text = await response.text(); |
32 | throw new Error(`${response.status} ${text}`); |
33 | } |
34 | return await response.json(); |
35 | } |
36 |
|