Add New Employee Training Record
One script reply has been approved by the moderators Verified

Add a new employee training record. The owner of the API key used must have permission to add trainings for the selected employee.

Created by hugo697 51 days ago
Submitted by hugo697 Bun
Verified 51 days ago
1
//native
2
/**
3
 * Add New Employee Training Record
4
 * Add a new employee training record. The owner of the API key used must have permission to add trainings for the selected employee.
5
 */
6
export async function main(auth: RT.BambooHr, employeeId: string = '0', body: Body) {
7
	const url = new URL(
8
		`https://${auth.companyDomain}.bamboohr.com/api/v1/training/record/employee/${employeeId}`
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
export interface Body {
34
	/**
35
	 * Completed is a required field and must be in yyyy-mm-dd format.
36
	 */
37
	completed: string
38
	cost?: {
39
		currency?: string
40
		cost?: number
41
		[k: string]: unknown
42
	}
43
	instructor?: string
44
	hours?: number
45
	credits?: number
46
	notes?: string
47
	/**
48
	 * This must be an existing training type id.
49
	 */
50
	type: number
51
	[k: string]: unknown
52
}
53