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