Deletes a leave record for a specific employee
One script reply has been approved by the moderators Verified
Created by hugo697 448 days ago
Submitted by hugo697 Bun
Verified 448 days ago
1
//native
2
type Xero = {
3
	token: string
4
}
5
/**
6
 * Deletes a leave record for a specific employee
7
 *
8
 */
9
export async function main(
10
	auth: Xero,
11
	EmployeeID: string,
12
	LeaveID: string,
13
	Xero_Tenant_Id: string
14
) {
15
	const url = new URL(
16
		`https://api.xero.com/payroll.xro/2.0/Employees/${EmployeeID}/Leave/${LeaveID}`
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