//native
/**
* Create Time Tracking Project
* Create a time tracking project with optional tasks.
*/
export async function main(auth: RT.BambooHr, body?: Body) {
const url = new URL(`https://${auth.companyDomain}.bamboohr.com/api/v1/time_tracking/projects`)
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.
*/
/**
* Schema for creating a new time tracking project with optional tasks
*/
export interface Body {
/**
* Name of the project.
*/
name: string
/**
* Indicates if the project is billable. Defaults to true if not provided.
*/
billable?: boolean
/**
* Indicates if all employees can log time for this project. Defaults to true if not provided.
*/
allowAllEmployees?: boolean
/**
* A list of employee IDs that can log time for this project.
*/
employeeIds?: number[]
/**
* Indicates if the project has tasks. Defaults to false if not provided.
*/
hasTasks?: boolean
/**
* List of tasks to create and associate with the project.
*/
tasks?: {
/**
* Name of the task.
*/
name: string
/**
* Indicates if the task is billable. Defaults to true if not provided.
*/
billable?: boolean
[k: string]: unknown
}[]
[k: string]: unknown
}
Submitted by hugo697 235 days ago