1 | |
2 | |
3 | * Validate time-off request |
4 | * Validate time-off requests and updates |
5 | **Token scopes**: `time-off:read` |
6 | */ |
7 | export async function main(auth: RT.Deel, body: Body) { |
8 | const url = new URL(`https://api.letsdeel.com/rest/v2/time_offs/validate`) |
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 | |
33 | * Time off request data |
34 | */ |
35 | export interface Body { |
36 | |
37 | * Time off request data |
38 | */ |
39 | data?: { |
40 | |
41 | * The time off id. Required when validating a time off update request |
42 | */ |
43 | id?: string |
44 | |
45 | * The dates breakdown for the time off request. |
46 | */ |
47 | dates?: { |
48 | |
49 | * An specific date in the time-off request |
50 | */ |
51 | date: string |
52 | |
53 | * The amount taken in hours during this specific date. It can not exceed the maximum allowed hours for the date. |
54 | */ |
55 | hours?: number |
56 | |
57 | * The amount of time off requested for the date. It must be in the same time unit as in the total amount for the time off request. |
58 | */ |
59 | amount?: number |
60 | |
61 | * The type of day for the time off request. All dates must follow the same type. |
62 | */ |
63 | day_type?: 'HALF_DAY' | 'FULL_DAY' | 'PERCENTAGE' | 'HOURLY' |
64 | [k: string]: unknown |
65 | }[] |
66 | |
67 | * Indicates if the time off request is paid or not. By default it follows the policy configuration. |
68 | */ |
69 | is_paid?: boolean |
70 | |
71 | * The end date of the time off request. |
72 | */ |
73 | end_date: string |
74 | |
75 | * The time off policy id. Can be used in place of time_off_type_id |
76 | */ |
77 | policy_id?: string |
78 | |
79 | * The start date of the time off request. |
80 | */ |
81 | start_date: string |
82 | |
83 | * The description of the time off request |
84 | */ |
85 | description?: string |
86 | |
87 | * Event details regarding the leave. Required for event based policies such as parental leave. |
88 | */ |
89 | event_details?: { |
90 | |
91 | * The birth-date of the child. Required for parental leave requests. |
92 | */ |
93 | birth_date?: string |
94 | |
95 | * The adoption-date of the child. Required depending on the type of the leave requests. |
96 | */ |
97 | adoption_date?: string |
98 | |
99 | * Indicates if the child was born prematurely. Required for parental leave requests. |
100 | */ |
101 | was_premature_birth?: boolean |
102 | |
103 | * Indicates if the request is for multiple children. Required for parental leave requests. |
104 | */ |
105 | had_multiple_children?: boolean |
106 | [k: string]: unknown |
107 | } |
108 | |
109 | * The amount to be deducted from the time off balance. Only valid for policies used by independent contractors |
110 | */ |
111 | deduction_amount?: number |
112 | |
113 | * The time off type id. Required when policy_id is not provided |
114 | */ |
115 | time_off_type_id?: string |
116 | |
117 | * The time off event id that this request is associated with. Only present for event-based policies such as parental leave. |
118 | */ |
119 | time_off_event_id?: string |
120 | |
121 | * The percentage of time off requested. For example, if the request is for a full day, the percentage will be 1. If it's for half a day, the percentage will be 0.5. |
122 | */ |
123 | time_off_percentage?: number |
124 | |
125 | * The hris profile id of the recipient |
126 | */ |
127 | recipient_profile_id: string |
128 | [k: string]: unknown |
129 | } |
130 | [k: string]: unknown |
131 | } |
132 |
|