1 | |
2 | |
3 | * Request contract resignation |
4 | * Enable clients to initiate a resignation request for an Employee of Record (EOR) contract within their team |
5 | **Token scopes**: `contracts:write` |
6 | */ |
7 | export async function main(auth: RT.Deel, contract_id: string, body: Body) { |
8 | const url = new URL( |
9 | `https://api.letsdeel.com/rest/v2/eor/contracts/${contract_id}/offboarding/resignation` |
10 | ) |
11 |
|
12 | const formData = new FormData() |
13 | for (const [k, v] of Object.entries(body)) { |
14 | if (v !== undefined && v !== '') { |
15 | formData.append(k, String(v)) |
16 | } |
17 | } |
18 | const response = await fetch(url, { |
19 | method: 'POST', |
20 | headers: { |
21 | Authorization: 'Bearer ' + auth.apiKey |
22 | }, |
23 | body: formData |
24 | }) |
25 | if (!response.ok) { |
26 | const text = await response.text() |
27 | throw new Error(`${response.status} ${text}`) |
28 | } |
29 | return await response.json() |
30 | } |
31 |
|
32 | |
33 | |
34 | * This file was automatically generated by json-schema-to-typescript. |
35 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
36 | * and run json-schema-to-typescript to regenerate this file. |
37 | */ |
38 |
|
39 | export interface Body { |
40 | data: { |
41 | |
42 | * Reason why the contract is being terminated |
43 | */ |
44 | reason: |
45 | | 'EMPLOYEE_IS_MOVING_TO_ANOTHER_COUNTRY' |
46 | | 'MOVING_EMPLOYEE_TO_INTERNAL_ENTITY' |
47 | | 'MOVING_EMPLOYEE_TO_DEEL_PEO' |
48 | | 'EMPLOYEE_FOUND_ANOTHER_JOB' |
49 | | 'EMPLOYEE_NOT_HAPPY_WITH_BENEFITS' |
50 | | 'EMPLOYEE_NOT_HAPPY_WITH_SALARY' |
51 | | 'EMPLOYEE_NOT_HAPPY_WITH_THE_ROLE' |
52 | | 'EMPLOYEE_NOT_HAPPY_WITH_COMPANY_CULTURE' |
53 | | 'EMPLOYEE_NOT_HAPPY_WITH_DEEL' |
54 | | 'EMPLOYEE_PROJECT_ENDED' |
55 | | 'EMPLOYEE_SWITCHING_TO_OTHER_EOR_PROVIDER' |
56 | | 'EMPLOYEE_LEFT_ROLE_FOR_PERSONAL_MATTERS' |
57 | | 'EMPLOYEE_MOVING_FROM_EOR_TO_CONTRACTOR_OR_FREELANCE' |
58 | | 'WORKER_TYPE_CHANGE' |
59 | | 'DEEL_COLLECTIONS' |
60 | | 'EMPLOYEE_DID_NOT_TAKE_THE_OFFER' |
61 | | 'EMPLOYEE_PROVIDED_NO_REASON' |
62 | | 'OTHER_BUSINESS_REASONS' |
63 | |
64 | * This field allows for uploading multiple files at once. Attach any document that is important for the request to terminate the contract. Includes common image formats (JPG, JPEG, PNG, HEIC) and PDF documents |
65 | */ |
66 | attachments?: string |
67 | |
68 | * Defines whether the termination is sensitive. In this case, only the person requesting the termination will be able to view the termination, receive emails or notifications. |
69 | */ |
70 | is_sensitive?: boolean |
71 | |
72 | * Optional field to describe the reason behind the resignation request |
73 | */ |
74 | reason_detail?: string |
75 | used_time_off: { |
76 | |
77 | * Type of time off tracking - whether it's tracked on Deel platform or off platform |
78 | */ |
79 | tracking_type?: 'ON_PLATFORM' | 'OFF_PLATFORM' |
80 | |
81 | * Required when tracking_type is OFF_PLATFORM, null otherwise |
82 | */ |
83 | off_platform_used_time_off?: { |
84 | |
85 | * Array of time off entitlements for different tracking periods |
86 | */ |
87 | entitlements: { |
88 | |
89 | * Amount of time off used in the period |
90 | */ |
91 | used: number |
92 | |
93 | * Start date of the tracking period |
94 | */ |
95 | tracking_period: string |
96 | |
97 | * End date of the tracking period |
98 | */ |
99 | tracking_period_end_date: string |
100 | [k: string]: unknown |
101 | }[] |
102 | |
103 | * Total amount of time off scheduled until the end date |
104 | */ |
105 | total_scheduled: number |
106 | |
107 | * Unit of measurement for the time off entitlements |
108 | */ |
109 | entitlement_unit: 'BUSINESS_DAY' | 'CALENDAR_DAY' | 'HOUR' | 'WEEK' | 'MONTH' | 'YEAR' |
110 | [k: string]: unknown |
111 | } |
112 | [k: string]: unknown |
113 | } |
114 | |
115 | * The type of severance selected by the client. It's an optional field |
116 | */ |
117 | severance_type?: 'DAYS' | 'WEEKS' | 'MONTHS' | 'CASH' |
118 | |
119 | * The desired end date. If the date is not provided, it will be selected by HRX the closest date possible |
120 | */ |
121 | desired_end_date?: string |
122 | |
123 | * The amount of severance needed |
124 | */ |
125 | severance_amount?: number |
126 | |
127 | * An additional reason can be provided in case the reason selected is MOVING_EMPLOYEE_TO_INTERNAL_ENTITY |
128 | */ |
129 | additional_reason?: |
130 | | 'MOVING_TO_INTERNAL_ENTITY_WITH_DEEL_GLOBAL_PAYROLL' |
131 | | 'MOVING_TO_INTERNAL_ENTITY_WITH_OTHER_PROVIDER' |
132 | |
133 | * Additional notes can be provided regarding the termination for Deel, like questions and doubts |
134 | */ |
135 | termination_notes?: string[] |
136 | |
137 | * Parameter to inform whether it would be possible for the client to hire the employee again |
138 | */ |
139 | eligible_for_rehire?: 'YES' | 'NO' | 'DONT_KNOW' |
140 | |
141 | * Describe if the option DONT_KNOW was selected on eligible_for_rehire |
142 | */ |
143 | eligible_for_rehire_reason?: string |
144 | |
145 | * Defines if employee will keep using Deel as provider |
146 | */ |
147 | is_employee_staying_with_deel: boolean |
148 | [k: string]: unknown |
149 | } |
150 | [k: string]: unknown |
151 | } |
152 |
|