1 | |
2 | |
3 | * Get Applications |
4 | * Get a list of applications. The owner of the API key used must have access to ATS settings. Combine as many different optional parameter filters as you like. |
5 | */ |
6 | export async function main( |
7 | auth: RT.BambooHr, |
8 | page?: string | undefined, |
9 | jobId?: string | undefined, |
10 | applicationStatusId?: string | undefined, |
11 | applicationStatus?: 'ALL' | 'ALL_ACTIVE' | 'NEW' | 'ACTIVE' | 'INACTIVE' | 'HIRED' | undefined, |
12 | jobStatusGroups?: |
13 | | 'ALL' |
14 | | 'DRAFT_AND_OPEN' |
15 | | 'Open' |
16 | | 'Filled' |
17 | | 'Draft' |
18 | | 'Deleted' |
19 | | 'On Hold' |
20 | | 'Canceled' |
21 | | undefined, |
22 | searchString?: string | undefined, |
23 | sortBy?: |
24 | | 'first_name' |
25 | | 'job_title' |
26 | | 'rating' |
27 | | 'phone' |
28 | | 'status' |
29 | | 'last_updated' |
30 | | 'created_date' |
31 | | undefined, |
32 | sortOrder?: 'ASC' | 'DESC' | undefined, |
33 | newSince?: string | undefined |
34 | ) { |
35 | const url = new URL( |
36 | `https://${auth.companyDomain}.bamboohr.com/api/v1/applicant_tracking/applications` |
37 | ) |
38 | for (const [k, v] of [ |
39 | ['page', page], |
40 | ['jobId', jobId], |
41 | ['applicationStatusId', applicationStatusId], |
42 | ['applicationStatus', applicationStatus], |
43 | ['jobStatusGroups', jobStatusGroups], |
44 | ['searchString', searchString], |
45 | ['sortBy', sortBy], |
46 | ['sortOrder', sortOrder], |
47 | ['newSince', newSince] |
48 | ]) { |
49 | if (v !== undefined && v !== '') { |
50 | url.searchParams.append(k, v) |
51 | } |
52 | } |
53 | const response = await fetch(url, { |
54 | method: 'GET', |
55 | headers: { |
56 | Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`) |
57 | }, |
58 | body: undefined |
59 | }) |
60 | if (!response.ok) { |
61 | const text = await response.text() |
62 | throw new Error(`${response.status} ${text}`) |
63 | } |
64 | return await response.json() |
65 | } |
66 |
|