Edits history of script submission #15559 for ' Reject contract (deel)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    /**
     * Reject contract
     * Rejects a contract that is in the pending (unsigned) state by specifying its public ID in the contract_id parameter. Use this endpoint when you do not wish to proceed with the agreement. Only contracts that have not yet been signed or previously rejected are eligible for this action
     **Token scopes**: `worker:write`
     */
    export async function main(auth: RT.Deel, contract_id: string) {
    	const url = new URL(`https://api.letsdeel.com/rest/v2/workers/contracts/${contract_id}/reject`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		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