1 | |
2 | |
3 | * Create a new worker |
4 | * Creates a new worker account with the specified profile type |
5 | */ |
6 | export async function main(auth: RT.Deel, body: Body) { |
7 | const url = new URL(`https://api.letsdeel.com/rest/v2/worker`) |
8 |
|
9 | const response = await fetch(url, { |
10 | method: 'POST', |
11 | headers: { |
12 | 'Content-Type': 'application/json', |
13 | Authorization: 'Bearer ' + auth.apiKey |
14 | }, |
15 | body: JSON.stringify(body) |
16 | }) |
17 | if (!response.ok) { |
18 | const text = await response.text() |
19 | throw new Error(`${response.status} ${text}`) |
20 | } |
21 | return await response.json() |
22 | } |
23 |
|
24 | |
25 | |
26 | * This file was automatically generated by json-schema-to-typescript. |
27 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
28 | * and run json-schema-to-typescript to regenerate this file. |
29 | */ |
30 |
|
31 | export interface Body { |
32 | data: { |
33 | |
34 | * Worker's email address |
35 | */ |
36 | email: string |
37 | company: { |
38 | |
39 | * Type of company registration |
40 | */ |
41 | type: 'COMPANY' | 'INDIVIDUAL' |
42 | personal: { |
43 | |
44 | * Zip/Postal code |
45 | */ |
46 | zip: number |
47 | |
48 | * City |
49 | */ |
50 | city: string |
51 | |
52 | * Phone number |
53 | */ |
54 | phone: number |
55 | |
56 | * Street address |
57 | */ |
58 | street: string |
59 | |
60 | * Citizenship country code |
61 | */ |
62 | citizen: string |
63 | |
64 | * Country code |
65 | */ |
66 | country?: string |
67 | |
68 | * Type of identification |
69 | */ |
70 | id_type?: string |
71 | |
72 | * Province/State |
73 | */ |
74 | province?: string |
75 | |
76 | * Personal timezone |
77 | */ |
78 | timezone?: string |
79 | |
80 | * Personal identification number |
81 | */ |
82 | personal_id: number |
83 | |
84 | * Legal status (required only when type is INDIVIDUAL) |
85 | */ |
86 | legal_status?: string |
87 | |
88 | * Tax residence country code |
89 | */ |
90 | tax_residence?: string |
91 | |
92 | * Entity tax residence (only applicable for company type) |
93 | */ |
94 | entity_tax_residence?: string |
95 | [k: string]: unknown |
96 | } |
97 | [k: string]: unknown |
98 | } |
99 | |
100 | * Worker's timezone |
101 | */ |
102 | timezone: string |
103 | |
104 | * Worker's last name |
105 | */ |
106 | last_name: string |
107 | |
108 | * Worker's first name |
109 | */ |
110 | first_name: string |
111 | |
112 | * Associated contract ID |
113 | */ |
114 | contract_id: string |
115 | |
116 | * Worker's middle name |
117 | */ |
118 | middle_name?: string |
119 | |
120 | * Type of worker profile |
121 | */ |
122 | profile_type: 'CONTRACTOR' | 'EOR' |
123 | |
124 | * Worker's preferred name |
125 | */ |
126 | preferred_name?: string |
127 | |
128 | * Worker's preferred last name |
129 | */ |
130 | preferred_lastName?: string |
131 | |
132 | * Worker's preferred first name |
133 | */ |
134 | preferred_firstname?: string |
135 | [k: string]: unknown |
136 | } |
137 | [k: string]: unknown |
138 | } |
139 |
|