Edits history of script submission #14126 for ' Adjust Time Off Balance (bamboo_hr)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Adjust Time Off Balance
     * 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.
     */
    export async function main(auth: RT.BambooHr, employeeId: string, body: Body) {
    	const url = new URL(
    		`https://${auth.companyDomain}.bamboohr.com/api/v1/employees/${employeeId}/time_off/balance_adjustment`
    	)
    
    	const response = await fetch(url, {
    		method: 'PUT',
    		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 {
    	/**
    	 * The date the adjustment should be added in history. Should be in ISO8601 date format (YYYY-MM-DD).
    	 */
    	date: string
    	/**
    	 * The ID of the time off type to add a balance adjustment for.
    	 */
    	timeOffTypeId: number
    	/**
    	 * The number of hours/days to adjust the balance by.
    	 */
    	amount: number
    	/**
    	 * This is an optional note to show in history.
    	 */
    	note?: string
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago