1 | |
2 | type Holded = { |
3 | apiKey: string; |
4 | }; |
5 | |
6 | * Create Treasury Account |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Holded, |
11 | body: { |
12 | id?: string; |
13 | name?: string; |
14 | type?: string; |
15 | balance?: number; |
16 | accountNumber?: number; |
17 | iban?: string; |
18 | swift?: string; |
19 | bank?: string; |
20 | bankname?: string; |
21 | } & {}, |
22 | ) { |
23 | const url = new URL(`https://api.holded.com/api/invoicing/v1/treasury`); |
24 |
|
25 | const response = await fetch(url, { |
26 | method: "POST", |
27 | headers: { |
28 | "Content-Type": "application/json", |
29 | key: auth.apiKey, |
30 | }, |
31 | body: JSON.stringify(body), |
32 | }); |
33 | if (!response.ok) { |
34 | const text = await response.text(); |
35 | throw new Error(`${response.status} ${text}`); |
36 | } |
37 | return await response.json(); |
38 | } |
39 |
|