Adjust Time Off Balance
One script reply has been approved by the moderators Verified

To use this API make an HTTP PUT where the body of the request is the JSON documented below. A time off balance adjustment will be inserted into the database. On success, a 201 Created code is returned and the "Location" header of the response will contain a URL that identifies the new history item.

Created by hugo697 51 days ago
Submitted by hugo697 Bun
Verified 51 days ago
1
//native
2
/**
3
 * Adjust Time Off Balance
4
 * To use this API make an HTTP PUT where the body of the request is the JSON documented below. A time off balance adjustment will be inserted into the database. On success, a 201 Created code is returned and the "Location" header of the response will contain a URL that identifies the new history item.
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/employees/${employeeId}/time_off/balance_adjustment`
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
/* 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
export interface Body {
34
	/**
35
	 * The date the adjustment should be added in history. Should be in ISO8601 date format (YYYY-MM-DD).
36
	 */
37
	date: string
38
	/**
39
	 * The ID of the time off type to add a balance adjustment for.
40
	 */
41
	timeOffTypeId: number
42
	/**
43
	 * The number of hours/days to adjust the balance by.
44
	 */
45
	amount: number
46
	/**
47
	 * This is an optional note to show in history.
48
	 */
49
	note?: string
50
	[k: string]: unknown
51
}
52