1 | |
2 | type Enode = { |
3 | token: string |
4 | } |
5 |
|
6 | export async function main( |
7 | auth: Enode, |
8 | locationId: string, |
9 | body: { |
10 | name?: string |
11 | latitude?: number |
12 | longitude?: number |
13 | timezoneName?: string |
14 | } & {} |
15 | ) { |
16 | const url = new URL(`https://enode-api.production.enode.io/locations/${locationId}`) |
17 |
|
18 | const response = await fetch(url, { |
19 | method: 'PUT', |
20 | headers: { |
21 | 'Content-Type': 'application/json', |
22 | Authorization: 'Bearer ' + auth.token |
23 | }, |
24 | body: JSON.stringify(body) |
25 | }) |
26 |
|
27 | if (!response.ok) { |
28 | const text = await response.text() |
29 | throw new Error(`${response.status} ${text}`) |
30 | } |
31 |
|
32 | return await response.json() |
33 | } |
34 |
|