Edits history of script submission #15612 for ' Retrieve offboarding list (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Retrieve offboarding list
     * Retrieve offboarding list
     **Token scopes**: `contracts:read`, `people:read`
     */
    export async function main(
    	auth: RT.Deel,
    	search?: string | undefined,
    	hiring_types?: string | undefined,
    	progress_statuses?: string | undefined,
    	limit?: string | undefined,
    	sort_by?: 'progressStatusWeight' | undefined,
    	sort_order?: 'ASC' | 'DESC' | undefined,
    	pagination?: string | undefined,
    	include_overview?: string | undefined
    ) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/offboarding/tracker`)
    	for (const [k, v] of [
    		['search', search],
    		['hiring_types', hiring_types],
    		['progress_statuses', progress_statuses],
    		['limit', limit],
    		['sort_by', sort_by],
    		['sort_order', sort_order],
    		['pagination', pagination],
    		['include_overview', include_overview]
    	]) {
    		if (v !== undefined && v !== '') {
    			url.searchParams.append(k, v)
    		}
    	}
    	const response = await fetch(url, {
    		method: 'GET',
    		headers: {
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 235 days ago