Edits history of script submission #15677 for ' Validate time-off request (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Validate time-off request
     * Validate time-off requests and updates
     **Token scopes**: `time-off:read`
     */
    export async function main(auth: RT.Deel, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/time_offs/validate`)
    
    	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.
     */
    
    /**
     * Time off request data
     */
    export interface Body {
    	/**
    	 * Time off request data
    	 */
    	data?: {
    		/**
    		 * The time off id. Required when validating a time off update request
    		 */
    		id?: string
    		/**
    		 * The dates breakdown for the time off request.
    		 */
    		dates?: {
    			/**
    			 * An specific date in the time-off request
    			 */
    			date: string
    			/**
    			 * The amount taken in hours during this specific date. It can not exceed the maximum allowed hours for the date.
    			 */
    			hours?: number
    			/**
    			 * The amount of time off requested for the date. It must be in the same time unit as in the total amount for the time off request.
    			 */
    			amount?: number
    			/**
    			 * The type of day for the time off request. All dates must follow the same type.
    			 */
    			day_type?: 'HALF_DAY' | 'FULL_DAY' | 'PERCENTAGE' | 'HOURLY'
    			[k: string]: unknown
    		}[]
    		/**
    		 * Indicates if the time off request is paid or not. By default it follows the policy configuration.
    		 */
    		is_paid?: boolean
    		/**
    		 * The end date of the time off request.
    		 */
    		end_date: string
    		/**
    		 * The time off policy id. Can be used in place of time_off_type_id
    		 */
    		policy_id?: string
    		/**
    		 * The start date of the time off request.
    		 */
    		start_date: string
    		/**
    		 * The description of the time off request
    		 */
    		description?: string
    		/**
    		 * Event details regarding the leave. Required for event based policies such as parental leave.
    		 */
    		event_details?: {
    			/**
    			 * The birth-date of the child. Required for parental leave requests.
    			 */
    			birth_date?: string
    			/**
    			 * The adoption-date of the child. Required depending on the type of the leave requests.
    			 */
    			adoption_date?: string
    			/**
    			 * Indicates if the child was born prematurely. Required for parental leave requests.
    			 */
    			was_premature_birth?: boolean
    			/**
    			 * Indicates if the request is for multiple children. Required for parental leave requests.
    			 */
    			had_multiple_children?: boolean
    			[k: string]: unknown
    		}
    		/**
    		 * The amount to be deducted from the time off balance. Only valid for policies used by independent contractors
    		 */
    		deduction_amount?: number
    		/**
    		 * The time off type id. Required when policy_id is not provided
    		 */
    		time_off_type_id?: string
    		/**
    		 * The time off event id that this request is associated with. Only present for event-based policies such as parental leave.
    		 */
    		time_off_event_id?: string
    		/**
    		 * The percentage of time off requested. For example, if the request is for a full day, the percentage will be 1. If it's for half a day, the percentage will be 0.5.
    		 */
    		time_off_percentage?: number
    		/**
    		 * The hris profile id of the recipient
    		 */
    		recipient_profile_id: string
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago