//native
/**
* Get Hourly Report Presets
* Retrieve hourly report presets for a given contract and work statement.
**Token scopes**: `timesheets:read`
*/
export async function main(
auth: RT.Deel,
contract_id: string,
work_statement_id?: string | undefined,
order_by?: string | undefined,
order_direction?: string | undefined,
cursor?: string | undefined,
limit?: string | undefined
) {
const url = new URL(
`https://api.letsdeel.com/rest/v2/contracts/${contract_id}/timesheets/presets`
)
for (const [k, v] of [
['work_statement_id', work_statement_id],
['order_by', order_by],
['order_direction', order_direction],
['cursor', cursor],
['limit', limit]
]) {
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