Edits history of script submission #15662 for ' Update compensation (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Update compensation
     * Update the compensation of a Global Payroll employee. Returns the full compensation history including the update.
     **Token scopes**: `people:write`
     */
    export async function main(auth: RT.Deel, worker_id: string, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/gp/workers/${worker_id}/compensation`)
    
    	const response = await fetch(url, {
    		method: 'PATCH',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		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 {
    	data: {
    		/**
    		 * The scale to which a given salary applies.
    		 */
    		scale: 'YEAR' | 'MONTH' | 'HOUR'
    		/**
    		 * Compensation salary.
    		 */
    		salary: number
    		/**
    		 * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31.
    		 */
    		effective_date: string
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago