0

Get Time Off Requests

by
Published Oct 17, 2025
Script bamboo_hr Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Get Time Off Requests
4
 *
5
 */
6
export async function main(
7
	auth: RT.BambooHr,
8
	start: string | undefined,
9
	end: string | undefined,
10
	id?: string | undefined,
11
	action?: string | undefined,
12
	employeeId?: string | undefined,
13
	_type?: string | undefined,
14
	status?: string | undefined,
15
	AcceptHeaderParameter?: string
16
) {
17
	const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/time_off/requests`)
18
	for (const [k, v] of [
19
		['id', id],
20
		['action', action],
21
		['employeeId', employeeId],
22
		['start', start],
23
		['end', end],
24
		['type', _type],
25
		['status', status]
26
	]) {
27
		if (v !== undefined && v !== '') {
28
			url.searchParams.append(k, v)
29
		}
30
	}
31
	const response = await fetch(url, {
32
		method: 'GET',
33
		headers: {
34
			...(AcceptHeaderParameter ? { AcceptHeaderParameter: AcceptHeaderParameter } : {}),
35
			Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
36
		},
37
		body: undefined
38
	})
39
	if (!response.ok) {
40
		const text = await response.text()
41
		throw new Error(`${response.status} ${text}`)
42
	}
43
	return await response.json()
44
}
45