1 | |
2 | |
3 | * Request termination |
4 | * Request a termination for a global payroll employee. A successful call starts the termination process and does not confirm termination. |
5 | **Token scopes**: `global-payroll:write` |
6 | */ |
7 | export async function main(auth: RT.Deel, worker_id: string, body: Body) { |
8 | const url = new URL(`https://api.letsdeel.com/rest/v2/gp/workers/${worker_id}/terminations`) |
9 |
|
10 | const response = await fetch(url, { |
11 | method: 'POST', |
12 | headers: { |
13 | 'Content-Type': 'application/json', |
14 | Authorization: 'Bearer ' + auth.apiKey |
15 | }, |
16 | body: JSON.stringify(body) |
17 | }) |
18 | if (!response.ok) { |
19 | const text = await response.text() |
20 | throw new Error(`${response.status} ${text}`) |
21 | } |
22 | return await response.json() |
23 | } |
24 |
|
25 | |
26 | |
27 | * This file was automatically generated by json-schema-to-typescript. |
28 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
29 | * and run json-schema-to-typescript to regenerate this file. |
30 | */ |
31 |
|
32 | export interface Body { |
33 | data: { |
34 | |
35 | * The reason for terminating the worker's engagement. |
36 | */ |
37 | message: string |
38 | severance: |
39 | | { |
40 | |
41 | * The type of severance, either in time off. |
42 | */ |
43 | type: 'TIME' |
44 | |
45 | * The amount of severance, specified in the designated currency or time unit. |
46 | */ |
47 | amount: number |
48 | |
49 | * Currency code for severance. |
50 | */ |
51 | currency: string |
52 | |
53 | * The unit of time for severance (e.g., DAYS, WEEKS, MONTHS). |
54 | */ |
55 | time_unit: 'DAYS' | 'WEEKS' | 'MONTHS' |
56 | [k: string]: unknown |
57 | } |
58 | | { |
59 | |
60 | * The type of severance, in cash. |
61 | */ |
62 | type: 'CASH' |
63 | |
64 | * The amount of severance, specified in the designated currency. |
65 | */ |
66 | amount: number |
67 | |
68 | * Currency code for severance. |
69 | */ |
70 | currency: string |
71 | [k: string]: unknown |
72 | } |
73 | |
74 | * Indicates whether the worker termination is voluntary (true) or involuntary (false). |
75 | */ |
76 | is_voluntary: boolean |
77 | |
78 | * The preferred end date for terminating the worker's engagement, in ISO-8601 format (YYYY-MM-DD). |
79 | */ |
80 | desired_end_date: string |
81 | |
82 | * The effective termination date of the worker's employment, in ISO-8601 format (YYYY-MM-DD). |
83 | */ |
84 | last_date_of_work: string |
85 | [k: string]: unknown |
86 | } |
87 | [k: string]: unknown |
88 | } |
89 |
|