0
Retrieves a specific leave type by using a unique leave type ID
One script reply has been approved by the moderators Verified
Created by hugo697 126 days ago Viewed 11424 times
0
Submitted by hugo697 Bun
Verified 126 days ago
1
//native
2
type Xero = {
3
	token: string
4
}
5
/**
6
 * Retrieves a specific leave type by using a unique leave type ID
7
 *
8
 */
9
export async function main(auth: Xero, LeaveTypeID: string, Xero_Tenant_Id: string) {
10
	const url = new URL(`https://api.xero.com/payroll.xro/2.0/LeaveTypes/${LeaveTypeID}`)
11

12
	const response = await fetch(url, {
13
		method: 'GET',
14
		headers: {
15
			Accept: 'application/json',
16
			'Xero-Tenant-Id': Xero_Tenant_Id,
17
			Authorization: 'Bearer ' + auth.token
18
		},
19
		body: undefined
20
	})
21
	if (!response.ok) {
22
		const text = await response.text()
23
		throw new Error(`${response.status} ${text}`)
24
	}
25
	return await response.json()
26
}
27