0

Get Hourly Report Presets

by
Published Oct 17, 2025

Retrieve hourly report presets for a given contract and work statement. **Token scopes**: `timesheets:read`

Script deel Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
/**
3
 * Get Hourly Report Presets
4
 * Retrieve hourly report presets for a given contract and work statement.
5
 **Token scopes**: `timesheets:read`
6
 */
7
export async function main(
8
	auth: RT.Deel,
9
	contract_id: string,
10
	work_statement_id?: string | undefined,
11
	order_by?: string | undefined,
12
	order_direction?: string | undefined,
13
	cursor?: string | undefined,
14
	limit?: string | undefined
15
) {
16
	const url = new URL(
17
		`https://api.letsdeel.com/rest/v2/contracts/${contract_id}/timesheets/presets`
18
	)
19
	for (const [k, v] of [
20
		['work_statement_id', work_statement_id],
21
		['order_by', order_by],
22
		['order_direction', order_direction],
23
		['cursor', cursor],
24
		['limit', limit]
25
	]) {
26
		if (v !== undefined && v !== '') {
27
			url.searchParams.append(k, v)
28
		}
29
	}
30
	const response = await fetch(url, {
31
		method: 'GET',
32
		headers: {
33
			Authorization: 'Bearer ' + auth.apiKey
34
		},
35
		body: undefined
36
	})
37
	if (!response.ok) {
38
		const text = await response.text()
39
		throw new Error(`${response.status} ${text}`)
40
	}
41
	return await response.json()
42
}
43