Edits history of script submission #15386 for ' Create a direct employee (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Create a direct employee
     * Create employee hired under your own entity to Deel's HRIS. Manage your employee through Deel and export a payroll report to your own providers.
     **Token scopes**: `people:write`
     */
    export async function main(auth: RT.Deel, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/people`)
    
    	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 entity that is hiring the employee
    		 */
    		client: {
    			team: {
    				/**
    				 * The team that the employee is part of
    				 */
    				id: string
    				/**
    				 * The direct manager of the employee
    				 */
    				direct_manager_id?: string
    				[k: string]: unknown
    			}
    			department?: {
    				/**
    				 * The department that the employee is part of
    				 */
    				id: string
    				[k: string]: unknown
    			}
    			legal_entity: {
    				/**
    				 * The legal entity that the employee is part of
    				 */
    				id: string
    				[k: string]: unknown
    			}
    			[k: string]: unknown
    		}
    		/**
    		 * The person that is being hired
    		 */
    		employee: {
    			/**
    			 * The personal email of the person being hired
    			 */
    			email: string
    			/**
    			 * The state of the person being hired
    			 */
    			state?: string
    			/**
    			 * The country of the person being hired
    			 */
    			country: string
    			/**
    			 * The last name of the person being hired
    			 */
    			last_name: string
    			/**
    			 * The first name of the person being hired
    			 */
    			first_name: string
    			/**
    			 * The work email of the person being hired
    			 */
    			work_email?: string
    			/**
    			 * An external identifier for the person being hired
    			 */
    			external_id?: string
    			/**
    			 * The nationality of the person being hired
    			 */
    			nationality: string
    			[k: string]: unknown
    		}
    		/**
    		 * The employment details of the employee
    		 */
    		employment:
    			| {
    					/**
    					 * The type of employment
    					 */
    					type: 'PART_TIME'
    					/**
    					 * The end date of the employment
    					 */
    					end_date?: string
    					/**
    					 * The job title of the employment
    					 */
    					job_title: string
    					/**
    					 * The seniority of the employment
    					 */
    					seniority: string
    					/**
    					 * The start date of the employment
    					 */
    					start_date: string
    					/**
    					 * The document template ID for the employment contract
    					 */
    					document_template_id?: string
    					/**
    					 * The percentage of PART_TIME employment
    					 */
    					part_time_percentage: number
    					[k: string]: unknown
    			  }
    			| {
    					type: 'FULL_TIME'
    					/**
    					 * The end date of the employment
    					 */
    					end_date?: string
    					/**
    					 * The job title of the employment
    					 */
    					job_title: string
    					/**
    					 * The seniority of the employment
    					 */
    					seniority: string
    					/**
    					 * The start date of the employment
    					 */
    					start_date: string
    					/**
    					 * The document template ID for the employment contract
    					 */
    					document_template_id?: string
    					[k: string]: unknown
    			  }
    		/**
    		 * The compensation details of the employee
    		 */
    		compensation_details: {
    			/**
    			 * The salary of the employee
    			 */
    			salary: number
    			/**
    			 * The currency of the salary
    			 */
    			currency: string
    			[k: string]: unknown
    		}
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago