//native
/**
* Get Job Summaries
* Get a list of job summaries. The owner of the API key used must have access to ATS settings. Combine as many different optional parameter filters as you like.
*/
export async function main(
auth: RT.BambooHr,
statusGroups?:
| 'ALL'
| 'DRAFT_AND_OPEN'
| 'Open'
| 'Filled'
| 'Draft'
| 'Deleted'
| 'On Hold'
| 'Canceled'
| undefined,
sortBy?: 'count' | 'title' | 'lead' | 'created' | 'status' | undefined,
sortOrder?: 'ASC' | 'DESC' | undefined
) {
const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/applicant_tracking/jobs`)
for (const [k, v] of [
['statusGroups', statusGroups],
['sortBy', sortBy],
['sortOrder', sortOrder]
]) {
if (v !== undefined && v !== '') {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'GET',
headers: {
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