1 | |
2 | |
3 | * Update an adjustment |
4 | * Update an adjustment. |
5 | **Token scopes**: `adjustments:write` |
6 | */ |
7 | export async function main(auth: RT.Deel, id: string, body: Body) { |
8 | const url = new URL(`https://api.letsdeel.com/rest/v2/adjustments/${id}`) |
9 |
|
10 | const formData = new FormData() |
11 | for (const [k, v] of Object.entries(body)) { |
12 | if (v !== undefined && v !== '') { |
13 | formData.append(k, String(v)) |
14 | } |
15 | } |
16 | const response = await fetch(url, { |
17 | method: 'PATCH', |
18 | headers: { |
19 | Authorization: 'Bearer ' + auth.apiKey |
20 | }, |
21 | body: formData |
22 | }) |
23 | if (!response.ok) { |
24 | const text = await response.text() |
25 | throw new Error(`${response.status} ${text}`) |
26 | } |
27 | return await response.json() |
28 | } |
29 |
|
30 | |
31 | |
32 | * This file was automatically generated by json-schema-to-typescript. |
33 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
34 | * and run json-schema-to-typescript to regenerate this file. |
35 | */ |
36 |
|
37 | export interface Body { |
38 | |
39 | * Details of adjustment to update |
40 | */ |
41 | data: { |
42 | |
43 | * File of adjustment. |
44 | */ |
45 | file?: string |
46 | |
47 | * Title of adjustment. |
48 | */ |
49 | title?: string |
50 | |
51 | * Amount of adjustment. |
52 | */ |
53 | amount?: string | number |
54 | |
55 | * Description of adjustment. |
56 | */ |
57 | description?: string |
58 | [k: string]: unknown |
59 | } |
60 | [k: string]: unknown |
61 | } |
62 |
|