1 | |
2 | |
3 | * Get an employee photo |
4 | * Get an employee photo |
5 | */ |
6 | export async function main( |
7 | auth: RT.BambooHr, |
8 | employeeId: string, |
9 | size: 'original' | 'large' | 'medium' | 'small' | 'xs' | 'tiny' |
10 | ) { |
11 | const url = new URL( |
12 | `https://${auth.companyDomain}.bamboohr.com/api/v1/employees/${employeeId}/photo/${size}` |
13 | ) |
14 |
|
15 | const response = await fetch(url, { |
16 | method: 'GET', |
17 | headers: { |
18 | Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`) |
19 | }, |
20 | body: undefined |
21 | }) |
22 | if (!response.ok) { |
23 | const text = await response.text() |
24 | throw new Error(`${response.status} ${text}`) |
25 | } |
26 | return await response.json() |
27 | } |
28 |
|