//native
/**
* Get Work Schedule and Holidays
* Given a date range (start date, end date) gets the holidays, work schedule and time off dailies for a list of hrisProfileIds or countries.
**Token scopes**: `time-off:read`
*/
export async function main(
auth: RT.Deel,
start_date?: string | undefined,
end_date?: string | undefined,
hris_profile_ids?: string | undefined,
countries?: string | undefined
) {
const url = new URL(`https://api.letsdeel.com/rest/v2/time_offs/dailies`)
for (const [k, v] of [
['start_date', start_date],
['end_date', end_date],
['hris_profile_ids', hris_profile_ids],
['countries', countries]
]) {
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