Edits history of script submission #15619 for ' Retrieve worker resignations (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Retrieve worker resignations
     * Use this endpoint to retrieve resignations submitted by Employer of Record (EOR) workers. Use it when you need to review resignation progress, confirm desired and confirmed end dates, and access resignation letter details. Filter results by resignation letter status using the query parameter
     **Token scopes**: `worker:read`
     */
    export async function main(auth: RT.Deel, status?: 'AWAITING_SIGNATURE' | 'SIGNED' | undefined) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/eor/workers/resignations`)
    	for (const [k, v] of [['status', status]]) {
    		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