Edits history of script submission #15564 for ' Request termination (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Request termination
     * Request a termination for a global payroll employee. A successful call starts the termination process and does not confirm termination.
     **Token scopes**: `global-payroll: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}/terminations`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		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 reason for terminating the worker's engagement.
    		 */
    		message: string
    		severance:
    			| {
    					/**
    					 * The type of severance, either in time off.
    					 */
    					type: 'TIME'
    					/**
    					 * The amount of severance, specified in the designated currency or time unit.
    					 */
    					amount: number
    					/**
    					 * Currency code for severance.
    					 */
    					currency: string
    					/**
    					 * The unit of time for severance (e.g., DAYS, WEEKS, MONTHS).
    					 */
    					time_unit: 'DAYS' | 'WEEKS' | 'MONTHS'
    					[k: string]: unknown
    			  }
    			| {
    					/**
    					 * The type of severance, in cash.
    					 */
    					type: 'CASH'
    					/**
    					 * The amount of severance, specified in the designated currency.
    					 */
    					amount: number
    					/**
    					 * Currency code for severance.
    					 */
    					currency: string
    					[k: string]: unknown
    			  }
    		/**
    		 * Indicates whether the worker termination is voluntary (true) or involuntary (false).
    		 */
    		is_voluntary: boolean
    		/**
    		 * The preferred end date for terminating the worker's engagement, in ISO-8601 format (YYYY-MM-DD).
    		 */
    		desired_end_date: string
    		/**
    		 * The effective termination date of the worker's employment, in ISO-8601 format (YYYY-MM-DD).
    		 */
    		last_date_of_work: string
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago