Edits history of script submission #15641 for ' Termination Request (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Termination Request
     * This API enables clients with group admin and people manager permissions to initiate a request for the termination of an Employee of Record (EOR) contract for members of 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/regular`)
    
    	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: {
    		/**
    		 * Reason why the contract is being terminated
    		 */
    		reason:
    			| 'DEEL_COLLECTIONS'
    			| 'STATUS_CHANGE'
    			| 'RELOCATION'
    			| 'COMPENSATION'
    			| 'RETIREMENT'
    			| 'JOB_ABANDONMENT'
    			| 'WORK_RELATED'
    			| 'PERSONAL'
    			| 'OTHER_OPPORTUNITY'
    			| 'NON_RENEWAL'
    			| 'PROBATION'
    			| 'ASSIGNMENT_ENDED'
    			| 'POSITION_ELIMINATION'
    			| 'FORCE_REDUCTION'
    			| 'DEATH'
    			| 'FOR_CAUSE'
    			| 'PERFORMANCE'
    			| 'MEDICAL'
    			| 'PERFORMANCE_ISSUES'
    			| 'ATTENDANCE_ISSUES'
    			| 'REORGANIZATION_DOWNSIZING_BUDGET_OR_REDUCTION_OF_WORKFORCE'
    			| 'ROLE_BECAME_REDUNDANT_OR_ROLE_CHANGED'
    			| 'OFFER_WAS_REVOKED'
    			| 'EXITING_THE_MARKET'
    			| 'NO_LONGER_WISH_TO_WORK_WITH_DEEL'
    			| 'COMPANY_ACQUIRED'
    			| 'STEALING'
    			| 'MISCONDUCT'
    			| 'FALSIFYING'
    			| 'HARASSMENT'
    			| 'VIOLENCE'
    			| 'REORGANIZATION_DOWNSIZING_BUDGET_OR_REDUCTION_OF_WORKFORCE_OR_ROLE_BECAME_REDUNDANT_OR_ROLE_CHANGED'
    			| 'UNAUTHORIZED_ABSENCES_OR_LACK_OF_ATTENDANCE'
    			| 'STANDARD_RESELLER_PRACTICE'
    			| 'MOVING_EMPLOYEE_TO_INTERNAL_ENTITY'
    			| 'MOVING_EMPLOYEE_TO_DEEL_PEO'
    			| 'OTHER'
    		/**
    		 * 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
    		/**
    		 * Field to better explain how communication with the employee will be and/or their reaction to the communication, or other necessary information
    		 */
    		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 NO_LONGER_WISH_TO_WORK_WITH_DEEL
    		 */
    		additional_reason?:
    			| 'DISSATISFIED_WITH_DEEL_SERVICE'
    			| 'DISSATISFIED_WITH_DEEL_PRICING'
    			| 'DISSATISFIED_WITH_DEEL_PRODUCT'
    		/**
    		 * 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'
    		/**
    		 * The current country data id
    		 */
    		eor_country_data_id?: number
    		/**
    		 * Defines if employee was informed by client or not before the termination
    		 */
    		is_employee_notified: boolean
    		/**
    		 * Termination impact data if there is some configured on HR module
    		 */
    		termination_impact_id?: string
    		/**
    		 * For some countries some data is needed to help Deel to process the termination. The questions comes from another endpoint to get the additional country data
    		 */
    		additional_country_data?: {
    			answer: boolean
    			question: string
    			[k: string]: unknown
    		}[]
    		/**
    		 * Custom termination reason ID. A custom termination reason can be added on Client HR module
    		 */
    		custom_termination_reason_id?: string
    		/**
    		 * If it's an termination contract ending and employee was already informed, the employee notification details should be provided
    		 */
    		employee_notification_detail?: string
    		/**
    		 * Any proof such as correspondence, documentation of previous warnings or attendance records for the reason select above.
    		 */
    		additional_supporting_documents?: {
    			key: string
    			file_name?: string
    			[k: string]: unknown
    		}[]
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago