1 | |
2 | type Holded = { |
3 | apiKey: string; |
4 | }; |
5 | |
6 | * Update Warehouse |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Holded, |
11 | warehouseId: string, |
12 | body: { |
13 | id?: string; |
14 | userId?: string; |
15 | name?: string; |
16 | email?: string; |
17 | phone?: string; |
18 | mobile?: string; |
19 | address?: { |
20 | address?: string; |
21 | city?: string; |
22 | postalCode?: string; |
23 | province?: string; |
24 | country?: string; |
25 | countryCode?: string; |
26 | }; |
27 | default?: false | true; |
28 | warehouseRecord?: number; |
29 | } & {}, |
30 | ) { |
31 | const url = new URL( |
32 | `https://api.holded.com/api/invoicing/v1/warehouses/${warehouseId}`, |
33 | ); |
34 |
|
35 | const response = await fetch(url, { |
36 | method: "PUT", |
37 | headers: { |
38 | "Content-Type": "application/json", |
39 | key: auth.apiKey, |
40 | }, |
41 | body: JSON.stringify(body), |
42 | }); |
43 | if (!response.ok) { |
44 | const text = await response.text(); |
45 | throw new Error(`${response.status} ${text}`); |
46 | } |
47 | return await response.json(); |
48 | } |
49 |
|