1 | |
2 | |
3 | * Create a new adjustment |
4 | * Create a new adjustment. |
5 | **Token scopes**: `adjustments:write` |
6 | */ |
7 | export async function main(auth: RT.Deel, body: Body) { |
8 | const url = new URL(`https://api.letsdeel.com/rest/v2/adjustments`) |
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: 'POST', |
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 create |
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 | * Vendor of adjustment. |
56 | */ |
57 | vendor: string |
58 | |
59 | * Country code. |
60 | */ |
61 | country: string |
62 | |
63 | * The identifier of the contract associated with the adjustment |
64 | */ |
65 | contract_id: string |
66 | |
67 | * Description of adjustment. |
68 | */ |
69 | description: string |
70 | |
71 | * Cycle reference of adjustment. |
72 | */ |
73 | cycle_reference?: string |
74 | |
75 | * If an adjustments can belong to another payroll cycle. |
76 | */ |
77 | move_next_cycle?: boolean |
78 | |
79 | * Short date in format ISO-8601 (YYYY-MM-DD). For example: 2022-12-31. |
80 | */ |
81 | date_of_adjustment?: string |
82 | |
83 | * Adjustment category id. |
84 | */ |
85 | adjustment_category_id: string |
86 | [k: string]: unknown |
87 | } |
88 | [k: string]: unknown |
89 | } |
90 |
|