1 | |
2 | type Xero = { |
3 | token: string |
4 | } |
5 | |
6 | * Approves a timesheet |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Xero, |
11 | TimesheetID: string, |
12 | Xero_Tenant_Id: string, |
13 | Idempotency_Key: string |
14 | ) { |
15 | const url = new URL(`https://api.xero.com/payroll.xro/2.0/Timesheets/${TimesheetID}/Approve`) |
16 |
|
17 | const response = await fetch(url, { |
18 | method: 'POST', |
19 | headers: { |
20 | Accept: 'application/json', |
21 | 'Xero-Tenant-Id': Xero_Tenant_Id, |
22 | 'Idempotency-Key': Idempotency_Key, |
23 | Authorization: 'Bearer ' + auth.token |
24 | }, |
25 | body: undefined |
26 | }) |
27 | if (!response.ok) { |
28 | const text = await response.text() |
29 | throw new Error(`${response.status} ${text}`) |
30 | } |
31 | return await response.json() |
32 | } |
33 |
|