Deletes a specific timesheet line

Script xero Verified

by hugo697 ยท 12/20/2024

The script

Submitted by hugo697 Bun
Verified 515 days ago
1
//native
2
type Xero = {
3
	token: string
4
}
5
/**
6
 * Deletes a specific timesheet line
7
 *
8
 */
9
export async function main(
10
	auth: Xero,
11
	TimesheetID: string,
12
	TimesheetLineID: string,
13
	Xero_Tenant_Id: string
14
) {
15
	const url = new URL(
16
		`https://api.xero.com/payroll.xro/2.0/Timesheets/${TimesheetID}/Lines/${TimesheetLineID}`
17
	)
18

19
	const response = await fetch(url, {
20
		method: 'DELETE',
21
		headers: {
22
			Accept: 'application/json',
23
			'Xero-Tenant-Id': Xero_Tenant_Id,
24
			Authorization: 'Bearer ' + auth.token
25
		},
26
		body: undefined
27
	})
28
	if (!response.ok) {
29
		const text = await response.text()
30
		throw new Error(`${response.status} ${text}`)
31
	}
32
	return await response.json()
33
}
34