1 | |
2 | |
3 | * Update Goal, V1.1 |
4 | * Update a goal. Version 1.1 allows the updating of the milestones contained within the goal, unlike Version 1. |
5 | */ |
6 | export async function main(auth: RT.BambooHr, employeeId: string, goalId: string, body: Body) { |
7 | const url = new URL( |
8 | `https://${auth.companyDomain}.bamboohr.com/api/v1_1/performance/employees/${employeeId}/goals/${goalId}` |
9 | ) |
10 |
|
11 | const response = await fetch(url, { |
12 | method: 'PUT', |
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). Required when milestonesEnabled is not true. |
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 | * Flag indicating whether milestones are enabled for this goal |
64 | */ |
65 | milestonesEnabled?: boolean |
66 | |
67 | * List of milestone IDs to be deleted from the goal |
68 | */ |
69 | deletedMilestoneIds?: number[] | null |
70 | |
71 | * List of milestones to add to this goal |
72 | */ |
73 | milestones?: |
74 | | { |
75 | |
76 | * The title of the milestone |
77 | */ |
78 | title?: string |
79 | [k: string]: unknown |
80 | }[] |
81 | | null |
82 | [k: string]: unknown |
83 | } |
84 |
|