1 | |
2 | |
3 | * Enroll an employee in a 401k plan |
4 | * Enroll an employee in a 401k plan |
5 | **Token scopes**: `benefits:write` |
6 | */ |
7 | export async function main( |
8 | auth: RT.Deel, |
9 | id: string, |
10 | contract_id: string, |
11 | plan_id: string, |
12 | body: Body |
13 | ) { |
14 | const url = new URL( |
15 | `https://api.letsdeel.com/rest/v2/benefits/legal-entities/${id}/contracts/${contract_id}/plans/${plan_id}` |
16 | ) |
17 |
|
18 | const response = await fetch(url, { |
19 | method: 'POST', |
20 | headers: { |
21 | 'Content-Type': 'application/json', |
22 | Authorization: 'Bearer ' + auth.apiKey |
23 | }, |
24 | body: JSON.stringify(body) |
25 | }) |
26 | if (!response.ok) { |
27 | const text = await response.text() |
28 | throw new Error(`${response.status} ${text}`) |
29 | } |
30 | return await response.json() |
31 | } |
32 |
|
33 | |
34 | |
35 | * This file was automatically generated by json-schema-to-typescript. |
36 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
37 | * and run json-schema-to-typescript to regenerate this file. |
38 | */ |
39 |
|
40 | |
41 | * Schema for the 401K Guideline Plan request body. |
42 | */ |
43 | export interface Body { |
44 | |
45 | * Type of the contribution for 401k. |
46 | */ |
47 | type: 'ROTH' | 'TRAD' | 'LOAN' | 'NEC' |
48 | |
49 | * Object containing additional information about the enrollment. |
50 | */ |
51 | details?: { |
52 | |
53 | * A key-value pair providing additional details about the enrollment. |
54 | */ |
55 | key?: string |
56 | [k: string]: unknown |
57 | } |
58 | |
59 | * Type of contribution. |
60 | */ |
61 | contribution_type?: 'PERCENTAGE' | 'FIXED_AMOUNT' |
62 | |
63 | * Maximum limit of contribution. |
64 | */ |
65 | contribution_limit: number |
66 | |
67 | * Value of the contribution. |
68 | */ |
69 | contribution_value?: number |
70 | [k: string]: unknown |
71 | } |
72 |
|