1 | |
2 | |
3 | * Get pay stub from employees from organization integrated with external benefits vendor |
4 | * Get pay stub from employees from organization integrated with external benefits vendor |
5 | **Token scopes**: `organizations:read` |
6 | */ |
7 | export async function main( |
8 | auth: RT.Deel, |
9 | id: string, |
10 | payroll_start_date?: string | undefined, |
11 | payroll_end_date?: string | undefined, |
12 | status?: string | undefined, |
13 | items_per_page?: string | undefined, |
14 | offset?: string | undefined |
15 | ) { |
16 | const url = new URL(`https://api.letsdeel.com/rest/v2/benefits/legal-entities/${id}/pay-stub`) |
17 | for (const [k, v] of [ |
18 | ['payroll_start_date', payroll_start_date], |
19 | ['payroll_end_date', payroll_end_date], |
20 | ['status', status], |
21 | ['items_per_page', items_per_page], |
22 | ['offset', offset] |
23 | ]) { |
24 | if (v !== undefined && v !== '') { |
25 | url.searchParams.append(k, v) |
26 | } |
27 | } |
28 | const response = await fetch(url, { |
29 | method: 'GET', |
30 | headers: { |
31 | Authorization: 'Bearer ' + auth.apiKey |
32 | }, |
33 | body: undefined |
34 | }) |
35 | if (!response.ok) { |
36 | const text = await response.text() |
37 | throw new Error(`${response.status} ${text}`) |
38 | } |
39 | return await response.json() |
40 | } |
41 |
|