Add/Edit Hour Records
One script reply has been approved by the moderators Verified

Bulk add/edit hour records

Created by hugo697 51 days ago
Submitted by hugo697 Bun
Verified 51 days ago
1
//native
2
/**
3
 * Add/Edit Hour Records
4
 * Bulk add/edit hour records
5
 */
6
export async function main(auth: RT.BambooHr, body: TimeTrackingRecordBulk) {
7
	const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/timetracking/record`)
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
/* eslint-disable */
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 type TimeTrackingRecordBulk = TimeTrackingRecord[]
32

33
export interface TimeTrackingRecord {
34
	/**
35
	 * 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).
36
	 */
37
	timeTrackingId: string
38
	/**
39
	 * The ID of the employee.
40
	 */
41
	employeeId: number
42
	/**
43
	 * [Optional] The ID of the division for the employee.
44
	 */
45
	divisionId?: number
46
	/**
47
	 * [Optional] The ID of the department for the employee.
48
	 */
49
	departmentId?: number
50
	/**
51
	 * [Optional] The ID of the job title for the employee.
52
	 */
53
	jobTitleId?: number
54
	/**
55
	 * [Optional] Only necessary if the payroll provider requires a pay code
56
	 */
57
	payCode?: string
58
	/**
59
	 * The date the hours were worked. Please use the ISO-8601 date format YYYY-MM-DD.
60
	 */
61
	dateHoursWorked: string
62
	/**
63
	 * [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.
64
	 */
65
	payRate?: number
66
	/**
67
	 * The type of hours - regular or overtime. Please use either "REG", "OT", or "DT" here.
68
	 */
69
	rateType: string
70
	/**
71
	 * The number of hours worked.
72
	 */
73
	hoursWorked: number
74
	/**
75
	 * [Optional] A job code.
76
	 */
77
	jobCode?: number
78
	/**
79
	 * [Optional] A list of up to four 20 characters max job numbers in comma delimited format with no spaces.
80
	 */
81
	jobData?: string
82
	[k: string]: unknown
83
}
84