1 | |
2 | type Base64 = string |
3 | |
4 | * Create manual verification screening |
5 | * Create manual verification screening |
6 | **Token scopes**: `worker:write`, `screenings:write` |
7 | */ |
8 | export async function main(auth: RT.Deel, body: Body) { |
9 | const url = new URL(`https://api.letsdeel.com/rest/v2/screenings/manual-verification`) |
10 |
|
11 | const formData = new FormData() |
12 | for (const [k, v] of Object.entries(body)) { |
13 | if (v !== undefined && v !== '') { |
14 | if (['back', 'front', 'additional', 'selfie_with_id', 'proof_of_residence'].includes(k)) { |
15 | const { base64, type, name } = v as { |
16 | base64: Base64 |
17 | type: string |
18 | name: string |
19 | } |
20 | formData.append( |
21 | k, |
22 | new Blob([Uint8Array.from(atob(base64), (m) => m.codePointAt(0)!)], { type }), |
23 | name |
24 | ) |
25 | } else { |
26 | formData.append(k, String(v)) |
27 | } |
28 | } |
29 | } |
30 | const response = await fetch(url, { |
31 | method: 'POST', |
32 | headers: { |
33 | Authorization: 'Bearer ' + auth.apiKey |
34 | }, |
35 | body: formData |
36 | }) |
37 | if (!response.ok) { |
38 | const text = await response.text() |
39 | throw new Error(`${response.status} ${text}`) |
40 | } |
41 | return await response.json() |
42 | } |
43 |
|
44 | |
45 | |
46 | * This file was automatically generated by json-schema-to-typescript. |
47 | * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file, |
48 | * and run json-schema-to-typescript to regenerate this file. |
49 | */ |
50 |
|
51 | export interface Body { |
52 | |
53 | * The back side of the document |
54 | */ |
55 | back?: { |
56 | base64: Base64 |
57 | type: |
58 | | 'image/png' |
59 | | 'image/jpeg' |
60 | | 'image/gif' |
61 | | 'application/pdf' |
62 | | 'appication/json' |
63 | | 'text/csv' |
64 | | 'text/plain' |
65 | | 'audio/mpeg' |
66 | | 'audio/wav' |
67 | | 'video/mp4' |
68 | name: string |
69 | } |
70 | |
71 | * The front side of the document |
72 | */ |
73 | front: { |
74 | base64: Base64 |
75 | type: |
76 | | 'image/png' |
77 | | 'image/jpeg' |
78 | | 'image/gif' |
79 | | 'application/pdf' |
80 | | 'appication/json' |
81 | | 'text/csv' |
82 | | 'text/plain' |
83 | | 'audio/mpeg' |
84 | | 'audio/wav' |
85 | | 'video/mp4' |
86 | name: string |
87 | } |
88 | |
89 | * An additional document |
90 | */ |
91 | additional?: { |
92 | base64: Base64 |
93 | type: |
94 | | 'image/png' |
95 | | 'image/jpeg' |
96 | | 'image/gif' |
97 | | 'application/pdf' |
98 | | 'appication/json' |
99 | | 'text/csv' |
100 | | 'text/plain' |
101 | | 'audio/mpeg' |
102 | | 'audio/wav' |
103 | | 'video/mp4' |
104 | name: string |
105 | } |
106 | |
107 | * The type of document to be verified |
108 | */ |
109 | document_type: 'PASSPORT' | 'DRIVING_LICENSE' | 'GOVERNMENT_ID' | 'OTHER' |
110 | |
111 | * The type of KYC operation to perform |
112 | */ |
113 | operation_type: 'IDENTITY_RESUBMISSION_KYC' | 'IDENTITY_VERIFICATION_KYC' | 'NAME_CHANGE_KYC' |
114 | |
115 | * A selfie of the user holding the ID document |
116 | */ |
117 | selfie_with_id: { |
118 | base64: Base64 |
119 | type: |
120 | | 'image/png' |
121 | | 'image/jpeg' |
122 | | 'image/gif' |
123 | | 'application/pdf' |
124 | | 'appication/json' |
125 | | 'text/csv' |
126 | | 'text/plain' |
127 | | 'audio/mpeg' |
128 | | 'audio/wav' |
129 | | 'video/mp4' |
130 | name: string |
131 | } |
132 | |
133 | * The issuing country code of the document to be verified (ISO 3166-1 alpha-2) |
134 | */ |
135 | document_country: string |
136 | |
137 | * A proof of residence document |
138 | */ |
139 | proof_of_residence?: { |
140 | base64: Base64 |
141 | type: |
142 | | 'image/png' |
143 | | 'image/jpeg' |
144 | | 'image/gif' |
145 | | 'application/pdf' |
146 | | 'appication/json' |
147 | | 'text/csv' |
148 | | 'text/plain' |
149 | | 'audio/mpeg' |
150 | | 'audio/wav' |
151 | | 'video/mp4' |
152 | name: string |
153 | } |
154 | |
155 | * Indicates whether the document requires translation |
156 | */ |
157 | translation_required: boolean |
158 | [k: string]: unknown |
159 | } |
160 |
|