1 | |
2 | type Xero = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Creates a superfund |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Xero, |
11 | Xero_Tenant_Id: string, |
12 | Idempotency_Key: string, |
13 | body: { |
14 | SuperFundID?: string; |
15 | Type: "REGULATED" | "SMSF"; |
16 | Name?: string; |
17 | ABN?: string; |
18 | BSB?: string; |
19 | AccountNumber?: string; |
20 | AccountName?: string; |
21 | ElectronicServiceAddress?: string; |
22 | EmployerNumber?: string; |
23 | SPIN?: string; |
24 | USI?: string; |
25 | UpdatedDateUTC?: string; |
26 | ValidationErrors?: { Message?: string }[]; |
27 | }[], |
28 | ) { |
29 | const url = new URL(`https://api.xero.com/payroll.xro/1.0/Superfunds`); |
30 |
|
31 | const response = await fetch(url, { |
32 | method: "POST", |
33 | headers: { |
34 | Accept: 'application/json', |
35 | "Xero-Tenant-Id": Xero_Tenant_Id, |
36 | "Idempotency-Key": Idempotency_Key, |
37 | "Content-Type": "application/json", |
38 | Authorization: "Bearer " + auth.token, |
39 | }, |
40 | body: JSON.stringify(body), |
41 | }); |
42 | if (!response.ok) { |
43 | const text = await response.text(); |
44 | throw new Error(`${response.status} ${text}`); |
45 | } |
46 | return await response.json(); |
47 | } |
48 |
|