Edits history of script submission #15557 for ' Preview job offer letter (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Preview job offer letter
     * Retrieve an EOR job offer letter in HTML. This endpoint does not support IC and Global Payroll contract types.
     **Token scopes**: `worker:read`
     */
    export async function main(auth: RT.Deel, contract_id: string) {
    	const url = new URL(
    		`https://api.letsdeel.com/rest/v2/eor/workers/contracts/${contract_id}/offer-letter`
    	)
    
    	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.text()
    }
    

    Submitted by hugo697 235 days ago