1 | |
2 | |
3 | * Upload a required immigration document |
4 | * Upload a required immigration document for a specific case. The document will be submitted for review. |
5 | **Token scopes**: `worker:write` |
6 | */ |
7 | export async function main( |
8 | auth: RT.Deel, |
9 | worker_id: string, |
10 | case_id: string, |
11 | document_request_id: string, |
12 | body: Body |
13 | ) { |
14 | const url = new URL( |
15 | `https://api.letsdeel.com/rest/v2/immigration/workers/${worker_id}/cases/${case_id}/required-document/${document_request_id}` |
16 | ) |
17 |
|
18 | const formData = new FormData() |
19 | for (const [k, v] of Object.entries(body)) { |
20 | if (v !== undefined && v !== '') { |
21 | formData.append(k, String(v)) |
22 | } |
23 | } |
24 | const response = await fetch(url, { |
25 | method: 'POST', |
26 | headers: { |
27 | Authorization: 'Bearer ' + auth.apiKey |
28 | }, |
29 | body: formData |
30 | }) |
31 | if (!response.ok) { |
32 | const text = await response.text() |
33 | throw new Error(`${response.status} ${text}`) |
34 | } |
35 | return await response.json() |
36 | } |
37 |
|
38 | |
39 | |
40 | * This file was automatically generated by json-schema-to-typescript. |
41 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
42 | * and run json-schema-to-typescript to regenerate this file. |
43 | */ |
44 |
|
45 | export interface Body { |
46 | |
47 | * Details of immigration document upload |
48 | */ |
49 | data: { |
50 | |
51 | * Immigration right to work document. More than 1 document can be uploaded at the same time (e.g.: front and back) |
52 | */ |
53 | file: string |
54 | [k: string]: unknown |
55 | } |
56 | [k: string]: unknown |
57 | } |
58 |
|