Edits history of script submission #15352 for ' Add Candidate (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Add Candidate
     * Add a candidate to Deel.
     **Token scopes**: `candidates:write`
     */
    export async function main(auth: RT.Deel, body: Body) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/candidates`)
    
    	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 {
    	/**
    	 * Details of candidate to create
    	 */
    	data: {
    		/**
    		 * Unique identifier of candidate in your ATS.
    		 */
    		id: string
    		/**
    		 * Link to candidate's profile in ATS.
    		 */
    		link: string
    		/**
    		 * Worker's work email address.
    		 */
    		email?: string
    		/**
    		 * Job location state.
    		 */
    		state?: string
    		/**
    		 * Offer status
    		 */
    		status: 'offer-accepted' | 'offer-sent' | 'offer-declined' | 'offer-deleted'
    		/**
    		 * Country code.
    		 */
    		country?: string
    		/**
    		 * Job Title.
    		 */
    		job_title?: string
    		/**
    		 * Candidate's last name.
    		 */
    		last_name: string
    		/**
    		 * Candidate's first name.
    		 */
    		first_name: string
    		/**
    		 * Short date in format ISO-8601 (YYYY-MM-DD).
    		 */
    		start_date: string
    		/**
    		 * Nationality of the worker.
    		 */
    		nationality?: string
    		/**
    		 * Worker's personal email address.
    		 */
    		personal_email?: string
    		[k: string]: unknown
    	}
    	[k: string]: unknown
    }
    

    Submitted by hugo697 235 days ago