1 | |
2 | |
3 | * Add Hour Record |
4 | * Add an hour record |
5 | */ |
6 | export async function main(auth: RT.BambooHr, body: TimeTrackingRecord) { |
7 | const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/timetracking/add`) |
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 | export interface TimeTrackingRecord { |
32 | |
33 | * A unique identifier for the record. Use this ID to adjust or delete these hours. It can be any ID you use to track the record up to 36 characters in length. (i.e. UUID). |
34 | */ |
35 | timeTrackingId: string |
36 | |
37 | * The ID of the employee. |
38 | */ |
39 | employeeId: number |
40 | |
41 | * [Optional] The ID of the division for the employee. |
42 | */ |
43 | divisionId?: number |
44 | |
45 | * [Optional] The ID of the department for the employee. |
46 | */ |
47 | departmentId?: number |
48 | |
49 | * [Optional] The ID of the job title for the employee. |
50 | */ |
51 | jobTitleId?: number |
52 | |
53 | * [Optional] Only necessary if the payroll provider requires a pay code |
54 | */ |
55 | payCode?: string |
56 | |
57 | * The date the hours were worked. Please use the ISO-8601 date format YYYY-MM-DD. |
58 | */ |
59 | dateHoursWorked: string |
60 | |
61 | * [Optional] The rate of pay. e.g. $15.00/hour should use 15.00 here. Only necessary if the payroll provider requires a pay rate. |
62 | */ |
63 | payRate?: number |
64 | |
65 | * The type of hours - regular or overtime. Please use either "REG", "OT", or "DT" here. |
66 | */ |
67 | rateType: string |
68 | |
69 | * The number of hours worked. |
70 | */ |
71 | hoursWorked: number |
72 | |
73 | * [Optional] A job code. |
74 | */ |
75 | jobCode?: number |
76 | |
77 | * [Optional] A list of up to four 20 characters max job numbers in comma delimited format with no spaces. |
78 | */ |
79 | jobData?: string |
80 | [k: string]: unknown |
81 | } |
82 |
|