Get all employee dependents
1
//native
2
/**
3
* Get all employee dependents
4
5
*/
6
export async function main(
7
auth: RT.BambooHr,
8
employeeid: string | undefined,
9
AcceptHeaderParameter?: string
10
) {
11
const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/employeedependents`)
12
for (const [k, v] of [['employeeid', employeeid]]) {
13
if (v !== undefined && v !== '') {
14
url.searchParams.append(k, v)
15
}
16
17
const response = await fetch(url, {
18
method: 'GET',
19
headers: {
20
...(AcceptHeaderParameter ? { AcceptHeaderParameter: AcceptHeaderParameter } : {}),
21
Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
22
},
23
body: undefined
24
})
25
if (!response.ok) {
26
const text = await response.text()
27
throw new Error(`${response.status} ${text}`)
28
29
return await response.json()
30
31