1 | |
2 | |
3 | * List onboarding employees |
4 | * List all onboarding |
5 | **Token scopes**: `contracts:read`, `people:read` |
6 | */ |
7 | export async function main( |
8 | auth: RT.Deel, |
9 | search?: string | undefined, |
10 | contractOid?: string | undefined, |
11 | hiringTypes?: string | undefined, |
12 | progressStatuses?: string | undefined, |
13 | countries?: string | undefined, |
14 | teams?: string | undefined, |
15 | legalEntities?: string | undefined, |
16 | hrisDirectManagers?: string | undefined, |
17 | fromDate?: string | undefined, |
18 | toDate?: string | undefined, |
19 | actions?: string | undefined, |
20 | limit?: string | undefined, |
21 | sort_by?: 'progressStatusWeight' | undefined, |
22 | sort_order?: 'ASC' | 'DESC' | undefined, |
23 | pagination?: string | undefined, |
24 | include_overview?: string | undefined |
25 | ) { |
26 | const url = new URL(`https://api.letsdeel.com/rest/v2/onboarding/tracker`) |
27 | for (const [k, v] of [ |
28 | ['search', search], |
29 | ['contractOid', contractOid], |
30 | ['hiringTypes', hiringTypes], |
31 | ['progressStatuses', progressStatuses], |
32 | ['countries', countries], |
33 | ['teams', teams], |
34 | ['legalEntities', legalEntities], |
35 | ['hrisDirectManagers', hrisDirectManagers], |
36 | ['fromDate', fromDate], |
37 | ['toDate', toDate], |
38 | ['actions', actions], |
39 | ['limit', limit], |
40 | ['sort_by', sort_by], |
41 | ['sort_order', sort_order], |
42 | ['pagination', pagination], |
43 | ['include_overview', include_overview] |
44 | ]) { |
45 | if (v !== undefined && v !== '') { |
46 | url.searchParams.append(k, v) |
47 | } |
48 | } |
49 | const response = await fetch(url, { |
50 | method: 'GET', |
51 | headers: { |
52 | Authorization: 'Bearer ' + auth.apiKey |
53 | }, |
54 | body: undefined |
55 | }) |
56 | if (!response.ok) { |
57 | const text = await response.text() |
58 | throw new Error(`${response.status} ${text}`) |
59 | } |
60 | return await response.json() |
61 | } |
62 |
|