Edits history of script submission #15561 for ' Request EOR Contract Resignation (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Request EOR Contract Resignation
     * Enable clients with group admin and people manager permissions to initiate a resignation request for an Employee of Record (EOR) contract within their team.
     **Token scopes**: `contracts:read`, `contracts:write`
     */
    export async function main(auth: RT.Deel, oid: string, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/eor/${oid}/terminations/resignation`)
    
    	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: {
    		data: {
    			/**
    			 * Reason why the contract is being terminated
    			 */
    			reason:
    				| 'EMPLOYEE_IS_MOVING_TO_ANOTHER_COUNTRY'
    				| 'MOVING_EMPLOYEE_TO_INTERNAL_ENTITY'
    				| 'MOVING_EMPLOYEE_TO_DEEL_PEO'
    				| 'EMPLOYEE_FOUND_ANOTHER_JOB'
    				| 'EMPLOYEE_NOT_HAPPY_WITH_BENEFITS'
    				| 'EMPLOYEE_NOT_HAPPY_WITH_SALARY'
    				| 'EMPLOYEE_NOT_HAPPY_WITH_THE_ROLE'
    				| 'EMPLOYEE_NOT_HAPPY_WITH_COMPANY_CULTURE'
    				| 'EMPLOYEE_NOT_HAPPY_WITH_DEEL'
    				| 'EMPLOYEE_PROJECT_ENDED'
    				| 'EMPLOYEE_SWITCHING_TO_OTHER_EOR_PROVIDER'
    				| 'EMPLOYEE_LEFT_ROLE_FOR_PERSONAL_MATTERS'
    				| 'EMPLOYEE_MOVING_FROM_EOR_TO_CONTRACTOR_OR_FREELANCE'
    				| 'WORKER_TYPE_CHANGE'
    				| 'DEEL_COLLECTIONS'
    				| 'EMPLOYEE_DID_NOT_TAKE_THE_OFFER'
    				| 'EMPLOYEE_PROVIDED_NO_REASON'
    				| 'OTHER_BUSINESS_REASONS'
    			/**
    			 * Any document that is important for the request to terminate the contract
    			 */
    			attachments?: {
    				key: string
    				file_name?: string
    				[k: string]: unknown
    			}[]
    			/**
    			 * Defines whether the termination is sensitive. In this case, only the person requesting the termination will be able to view the termination, receive emails or notifications.
    			 */
    			is_sensitive?: boolean
    			/**
    			 * Optional field to describe the reason behind the resignation request
    			 */
    			reason_detail?: string
    			used_time_off: {
    				/**
    				 * All time-off used by the employee during contract period
    				 */
    				time_offs?: {
    					/**
    					 * Time off unit
    					 */
    					unit: 'BUSINESS_DAY' | 'CALENDAR_DAY' | 'HOUR' | 'WEEK' | 'MONTH' | 'YEAR'
    					/**
    					 * Time off policy type
    					 */
    					policy_type?:
    						| 'Vacation'
    						| 'Sick leave'
    						| 'Maternity leave'
    						| 'Paternity leave'
    						| 'Parental leave'
    						| 'Bereavement leave'
    						| 'Childcare leave'
    						| 'Civic/public duty leave'
    						| 'Personal leave'
    						| 'Adoption leave'
    						| 'Blood donation leave'
    						| 'Childbirth leave'
    						| 'Disability leave'
    						| "Doctor's appointment leave"
    						| 'Family & domestic violence leave'
    						| 'Hajj leave'
    						| 'Marriage/wedding leave'
    						| 'Military leave'
    						| 'Moving leave'
    						| 'Pregnancy leave'
    						| 'Study leave'
    						| 'Volunteer leave'
    						| 'Unpaid leave'
    						| 'Paid leave'
    						| 'Other leave'
    						| 'RTT'
    						| 'Regional holiday'
    						| 'Breastfeeding leave'
    						| 'Advanced vacation'
    						| 'Supplementary Leave'
    						| 'Floating Holiday Allowance'
    					tracking_periods?: {
    						/**
    						 * Time off used in the period
    						 */
    						used: number
    						/**
    						 * Time off start period
    						 */
    						end_date?: string
    						/**
    						 * Time off end period
    						 */
    						start_date?: string
    						[k: string]: unknown
    					}[]
    					/**
    					 * Time off escheduled until contract end date
    					 */
    					scheduled_until_end_date?: number
    					[k: string]: unknown
    				}[]
    				/**
    				 * Any additional details regarding time off that HRX should know
    				 */
    				additional_details?: string
    				/**
    				 * Defines whether the client agrees with the time off values that are registered in Deel. If false, it means that the client changed the values.
    				 */
    				is_deel_pto_confirmed?: boolean
    				[k: string]: unknown
    			}
    			/**
    			 * The type of severance selected by the client. It's an optional field
    			 */
    			severance_type?: 'DAYS' | 'WEEKS' | 'MONTHS' | 'CASH'
    			/**
    			 * The desired end date. If the date is not provided, it will be selected by HRX the closest date possible
    			 */
    			desired_end_date?: string
    			/**
    			 * The amount of severance needed
    			 */
    			severance_amount?: number
    			/**
    			 * An additional reason can be provided in case the reason selected is MOVING_EMPLOYEE_TO_INTERNAL_ENTITY
    			 */
    			additional_reason?:
    				| 'MOVING_TO_INTERNAL_ENTITY_WITH_DEEL_GLOBAL_PAYROLL'
    				| 'MOVING_TO_INTERNAL_ENTITY_WITH_OTHER_PROVIDER'
    			/**
    			 * Additional notes can be provided regarding the termination for Deel, like questions and doubts
    			 */
    			termination_notes?: string[]
    			/**
    			 * Parameter to inform whether it would be possible for the client to hire the employee again
    			 */
    			eligible_for_rehire?: 'YES' | 'NO' | 'DONT_KNOW'
    			/**
    			 * Termination impact data if there is some configured on HR module
    			 */
    			termination_impact_id?: string
    			/**
    			 * Describe if the option DONT_KNOW was selected on eligibleForRehire
    			 */
    			eligible_for_rehire_reason?: string
    			/**
    			 * Custom termination reason ID. A custom termination reason can be added on Client HR module
    			 */
    			custom_termination_reason_id?: string
    			/**
    			 * Defines if employee will keep using Deel as provider
    			 */
    			is_employee_staying_with_deel: boolean
    			[k: string]: unknown
    		}
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago