1 | |
2 | |
3 | * Create Goal |
4 | * Create a new goal for an employee. |
5 | */ |
6 | export async function main(auth: RT.BambooHr, employeeId: string, body: Body) { |
7 | const url = new URL( |
8 | `https://${auth.companyDomain}.bamboohr.com/api/v1/performance/employees/${employeeId}/goals` |
9 | ) |
10 |
|
11 | const response = await fetch(url, { |
12 | method: 'POST', |
13 | headers: { |
14 | 'Content-Type': 'application/json', |
15 | Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`) |
16 | }, |
17 | body: JSON.stringify(body) |
18 | }) |
19 | if (!response.ok) { |
20 | const text = await response.text() |
21 | throw new Error(`${response.status} ${text}`) |
22 | } |
23 | return await response.json() |
24 | } |
25 |
|
26 | |
27 | |
28 | * This file was automatically generated by json-schema-to-typescript. |
29 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
30 | * and run json-schema-to-typescript to regenerate this file. |
31 | */ |
32 |
|
33 | export interface Body { |
34 | |
35 | * The title of the goal |
36 | */ |
37 | title: string |
38 | |
39 | * A detailed description of the goal |
40 | */ |
41 | description?: string |
42 | |
43 | * The due date for the goal in YYYY-MM-DD format |
44 | */ |
45 | dueDate: string |
46 | |
47 | * The percentage of completion for the goal (0-100) |
48 | */ |
49 | percentComplete: number |
50 | |
51 | * The date when the goal was completed in YYYY-MM-DD format. Required when percentComplete is 100. |
52 | */ |
53 | completionDate?: string | null |
54 | |
55 | * List of employee IDs with whom the goal is shared. Must include the employee ID of the goal owner. |
56 | */ |
57 | sharedWithEmployeeIds: number[] |
58 | |
59 | * ID of the option this goal aligns with |
60 | */ |
61 | alignsWithOptionId?: number | null |
62 | |
63 | * List of milestones for this goal |
64 | */ |
65 | milestones?: |
66 | | { |
67 | |
68 | * The title of the milestone |
69 | */ |
70 | title?: string |
71 | [k: string]: unknown |
72 | }[] |
73 | | null |
74 | [k: string]: unknown |
75 | } |
76 |
|