1 | |
2 | |
3 | * Create Time Tracking Project |
4 | * Create a time tracking project with optional tasks. |
5 | */ |
6 | export async function main(auth: RT.BambooHr, body?: Body) { |
7 | const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/time_tracking/projects`) |
8 |
|
9 | const response = await fetch(url, { |
10 | method: 'POST', |
11 | headers: { |
12 | 'Content-Type': 'application/json', |
13 | Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`) |
14 | }, |
15 | body: JSON.stringify(body) |
16 | }) |
17 | if (!response.ok) { |
18 | const text = await response.text() |
19 | throw new Error(`${response.status} ${text}`) |
20 | } |
21 | return await response.json() |
22 | } |
23 |
|
24 | |
25 | |
26 | * This file was automatically generated by json-schema-to-typescript. |
27 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
28 | * and run json-schema-to-typescript to regenerate this file. |
29 | */ |
30 |
|
31 | |
32 | * Schema for creating a new time tracking project with optional tasks |
33 | */ |
34 | export interface Body { |
35 | |
36 | * Name of the project. |
37 | */ |
38 | name: string |
39 | |
40 | * Indicates if the project is billable. Defaults to true if not provided. |
41 | */ |
42 | billable?: boolean |
43 | |
44 | * Indicates if all employees can log time for this project. Defaults to true if not provided. |
45 | */ |
46 | allowAllEmployees?: boolean |
47 | |
48 | * A list of employee IDs that can log time for this project. |
49 | */ |
50 | employeeIds?: number[] |
51 | |
52 | * Indicates if the project has tasks. Defaults to false if not provided. |
53 | */ |
54 | hasTasks?: boolean |
55 | |
56 | * List of tasks to create and associate with the project. |
57 | */ |
58 | tasks?: { |
59 | |
60 | * Name of the task. |
61 | */ |
62 | name: string |
63 | |
64 | * Indicates if the task is billable. Defaults to true if not provided. |
65 | */ |
66 | billable?: boolean |
67 | [k: string]: unknown |
68 | }[] |
69 | [k: string]: unknown |
70 | } |
71 |
|