Add Timesheet Clock-In Entry
One script reply has been approved by the moderators Verified

Clock in an employee.

Created by hugo697 51 days ago
Submitted by hugo697 Bun
Verified 51 days ago
1
//native
2
/**
3
 * Add Timesheet Clock-In Entry
4
 * Clock in 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/time_tracking/employees/${employeeId}/clock_in`
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
/* eslint-disable */
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
/**
34
 * Schema for clock-in request body
35
 */
36
export interface Body {
37
	/**
38
	 * ID of the time tracking project that should be associated with the timesheet entry. Required if taskId is specified.
39
	 */
40
	projectId?: number | null
41
	/**
42
	 * ID of the time tracking task that should be associated with the timesheet entry.
43
	 */
44
	taskId?: number | null
45
	/**
46
	 * The note that should be associated with the timesheet entry
47
	 */
48
	note?: string | null
49
	/**
50
	 * Date for the timesheet entry. Must be in YYYY-MM-DD format.
51
	 */
52
	date?: string | null
53
	/**
54
	 * The time for the clock in. In 24 hour format HH:MM
55
	 */
56
	start?: string | null
57
	/**
58
	 * The timezone associated with the clock in.
59
	 */
60
	timezone?: string | null
61
	[k: string]: unknown
62
}
63