1 | |
2 | |
3 | * Request a custom report |
4 | * **Warning: This endpoint will soon be deprecated and replaced with Datasets - Get Data from Dataset. |
5 | */ |
6 | export async function main( |
7 | auth: RT.BambooHr, |
8 | format: string | undefined, |
9 | body: RequestCustomReport, |
10 | onlyCurrent?: string | undefined |
11 | ) { |
12 | const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/reports/custom`) |
13 | for (const [k, v] of [ |
14 | ['format', format], |
15 | ['onlyCurrent', onlyCurrent] |
16 | ]) { |
17 | if (v !== undefined && v !== '') { |
18 | url.searchParams.append(k, v) |
19 | } |
20 | } |
21 | const response = await fetch(url, { |
22 | method: 'POST', |
23 | headers: { |
24 | 'Content-Type': 'application/json', |
25 | Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`) |
26 | }, |
27 | body: JSON.stringify(body) |
28 | }) |
29 | if (!response.ok) { |
30 | const text = await response.text() |
31 | throw new Error(`${response.status} ${text}`) |
32 | } |
33 | return await response.json() |
34 | } |
35 |
|
36 | |
37 | |
38 | * This file was automatically generated by json-schema-to-typescript. |
39 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
40 | * and run json-schema-to-typescript to regenerate this file. |
41 | */ |
42 |
|
43 | export interface RequestCustomReport { |
44 | title?: string |
45 | filters?: { |
46 | lastChanged?: { |
47 | |
48 | * yes|no |
49 | */ |
50 | includeNull?: string |
51 | |
52 | * Date last changed |
53 | */ |
54 | value?: string |
55 | [k: string]: unknown |
56 | } |
57 | [k: string]: unknown |
58 | } |
59 | fields?: string[] |
60 | [k: string]: unknown |
61 | } |
62 |
|