//native
/**
* Get Time Off Requests
*
*/
export async function main(
auth: RT.BambooHr,
start: string | undefined,
end: string | undefined,
id?: string | undefined,
action?: string | undefined,
employeeId?: string | undefined,
_type?: string | undefined,
status?: string | undefined,
AcceptHeaderParameter?: string
) {
const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/time_off/requests`)
for (const [k, v] of [
['id', id],
['action', action],
['employeeId', employeeId],
['start', start],
['end', end],
['type', _type],
['status', status]
]) {
if (v !== undefined && v !== '') {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
...(AcceptHeaderParameter ? { AcceptHeaderParameter: AcceptHeaderParameter } : {}),
Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 235 days ago