Edits history of script submission #15611 for ' Retrieve offboarding attachment (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Retrieve offboarding attachment
     * This endpoint allows client and employee download the content of a specific attachment associated with a termination for the given contract.
     **Token scopes**: `contracts:read`
     */
    export async function main(auth: RT.Deel, contract_id: string, attachment_id: string) {
    	const url = new URL(
    		`https://api.letsdeel.com/rest/v2/eor/contracts/${contract_id}/offboarding/attachments/${attachment_id}`
    	)
    
    	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