//native
/**
* Add Training Type
* Add a training type. The owner of the API key used must have access to training settings.
*/
export async function main(auth: RT.BambooHr, body: Body) {
const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/training/type`)
const response = await fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Basic ' + btoa(`${auth.apiKey}:x`)
},
body: JSON.stringify(body)
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
/* eslint-disable */
/**
* This file was automatically generated by json-schema-to-typescript.
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
* and run json-schema-to-typescript to regenerate this file.
*/
export interface Body {
/**
* Name of the new training type.
*/
name: string
/**
* The frequency is the (optional) amount of months between renewing trainings. Not valid if training are not renewable.
*/
frequency?: number
/**
* Renewable is optional but if you are setting it to true you must pass a frequency which is the months between renewals.
*/
renewable?: boolean
/**
* The category is optional and you can pass either a category id or a category name.
*/
category?: {
/**
* Category ID
*/
id?: number
/**
* Category Name
*/
name?: string
/**
* Accuracy in meters of the clock in location
*/
accuracy?: number
/**
* Address...
*/
address?: string
[k: string]: unknown
}
/**
* Is this a required training?
*/
required: boolean
/**
* Number of days before the training is due for new hires. Not valid unless training is required.
*/
dueFromHireDate?: number
/**
* Optional URL that can be included with a training.
*/
linkUrl?: string
/**
* Description for the training.
*/
description?: string
/**
* Allows all employees who can view the training to be able to mark it complete.
*/
allowEmployeesToMarkComplete?: boolean
[k: string]: unknown
}
Submitted by hugo697 51 days ago