Delete a single timesheet entry. **Token scopes**: `timesheets:write`
1
//native
2
/**
3
* Delete a timesheet entry
4
* Delete a single timesheet entry.
5
**Token scopes**: `timesheets:write`
6
*/
7
export async function main(auth: RT.Deel, id: string, reason?: string | undefined) {
8
const url = new URL(`https://api.letsdeel.com/rest/v2/timesheets/${id}`)
9
for (const [k, v] of [['reason', reason]]) {
10
if (v !== undefined && v !== '') {
11
url.searchParams.append(k, v)
12
}
13
14
const response = await fetch(url, {
15
method: 'DELETE',
16
headers: {
17
Authorization: 'Bearer ' + auth.apiKey
18
},
19
body: undefined
20
})
21
if (!response.ok) {
22
const text = await response.text()
23
throw new Error(`${response.status} ${text}`)
24
25
return await response.json()
26
27