Edits history of script submission #14121 for ' Add a Time Off History Item For Time Off Request (bamboo_hr)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Add a Time Off History Item For Time Off Request
     * To use this API make an HTTP PUT where the body of the request is the JSON documented below. A new time off history item 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/history`
    	)
    
    	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 request should be added in history. This will usually be the first date of the request. Should be in ISO8601 date format (YYYY-MM-DD).
    	 */
    	date: string
    	/**
    	 * The ID of the time off request.
    	 */
    	timeOffRequestId: number
    	/**
    	 * This is an optional note to show in history.
    	 */
    	note?: string
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago