1 | |
2 | type Netlify = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update account |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Netlify, |
11 | account_id: string, |
12 | body: { |
13 | name?: string; |
14 | slug?: string; |
15 | type_id?: string; |
16 | extra_seats_block?: number; |
17 | billing_name?: string; |
18 | billing_email?: string; |
19 | billing_details?: string; |
20 | }, |
21 | ) { |
22 | const url = new URL(`https://api.netlify.com/api/v1/accounts/${account_id}`); |
23 |
|
24 | const response = await fetch(url, { |
25 | method: "PUT", |
26 | headers: { |
27 | "Content-Type": "application/json", |
28 | Authorization: "Bearer " + auth.token, |
29 | }, |
30 | body: JSON.stringify(body), |
31 | }); |
32 | if (!response.ok) { |
33 | const text = await response.text(); |
34 | throw new Error(`${response.status} ${text}`); |
35 | } |
36 | return await response.json(); |
37 | } |
38 |
|