//native
/**
* Get Time Off Events for Profile
* List time off events for profile
**Token scopes**: `time-off:read`
*/
export async function main(
auth: RT.Deel,
hris_profile_id: string | undefined,
time_off_type_id?: string | undefined,
policy_id?: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/time_offs/time-off-events`)
for (const [k, v] of [
['hris_profile_id', hris_profile_id],
['time_off_type_id', time_off_type_id],
['policy_id', policy_id]
]) {
if (v !== undefined && v !== '') {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: 'Bearer ' + auth.apiKey
},
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