Edits history of script submission #14222 for ' Update Goal, V1.1 (bamboo_hr)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Update Goal, V1.1
     * Update a goal. Version 1.1 allows the updating of the milestones contained within the goal, unlike Version 1.
     */
    export async function main(auth: RT.BambooHr, employeeId: string, goalId: string, body: Body) {
    	const url = new URL(
    		`https://${auth.companyDomain}.bamboohr.com/api/v1_1/performance/employees/${employeeId}/goals/${goalId}`
    	)
    
    	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 title of the goal
    	 */
    	title: string
    	/**
    	 * A detailed description of the goal
    	 */
    	description?: string
    	/**
    	 * The due date for the goal in YYYY-MM-DD format
    	 */
    	dueDate: string
    	/**
    	 * The percentage of completion for the goal (0-100). Required when milestonesEnabled is not true.
    	 */
    	percentComplete?: number
    	/**
    	 * The date when the goal was completed in YYYY-MM-DD format. Required when percentComplete is 100.
    	 */
    	completionDate?: string | null
    	/**
    	 * List of employee IDs with whom the goal is shared. Must include the employee ID of the goal owner.
    	 */
    	sharedWithEmployeeIds: number[]
    	/**
    	 * ID of the option this goal aligns with
    	 */
    	alignsWithOptionId?: number | null
    	/**
    	 * Flag indicating whether milestones are enabled for this goal
    	 */
    	milestonesEnabled?: boolean
    	/**
    	 * List of milestone IDs to be deleted from the goal
    	 */
    	deletedMilestoneIds?: number[] | null
    	/**
    	 * List of milestones to add to this goal
    	 */
    	milestones?:
    		| {
    				/**
    				 * The title of the milestone
    				 */
    				title?: string
    				[k: string]: unknown
    		  }[]
    		| null
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago