smile-identity-core 1.2.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +18 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +6 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +75 -30
- data/Gemfile +3 -1
- data/Gemfile.lock +35 -7
- data/README.md +33 -464
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/examples/biometric_kyc.rb +67 -0
- data/examples/business_verification.rb +45 -0
- data/examples/document_verification.rb +74 -0
- data/examples/enhanced_kyc.rb +39 -0
- data/examples/example-project/Gemfile +7 -0
- data/examples/example-project/Gemfile.lock +25 -0
- data/examples/example-project/README.md +14 -0
- data/examples/example-project/sample.env +4 -0
- data/examples/example-project/smart_bank.rb +216 -0
- data/examples/smart_selfie_authentication.rb +56 -0
- data/lib/smile-identity-core/business_verification.rb +106 -0
- data/lib/smile-identity-core/constants/env.rb +13 -0
- data/lib/smile-identity-core/constants/image_type.rb +14 -0
- data/lib/smile-identity-core/constants/job_type.rb +13 -0
- data/lib/smile-identity-core/id_api.rb +41 -82
- data/lib/smile-identity-core/signature.rb +15 -36
- data/lib/smile-identity-core/utilities.rb +28 -55
- data/lib/smile-identity-core/validations.rb +32 -0
- data/lib/smile-identity-core/version.rb +4 -1
- data/lib/smile-identity-core/web_api.rb +87 -136
- data/lib/smile-identity-core.rb +11 -5
- data/smile-identity-core.gemspec +26 -21
- metadata +82 -22
- data/.travis.yml +0 -11
data/README.md
CHANGED
@@ -1,27 +1,32 @@
|
|
1
|
-
#
|
1
|
+
# Smile Identity Ruby Server Side SDK
|
2
2
|
|
3
|
-
|
3
|
+
Smile Identity provides the best solutions for real time Digital KYC, identity verification, user onboarding, and user authentication across Africa. Our server side libraries make it easy to integrate us on the server-side. Since the library is server-side, you will be required to pass the images (if required) to the library.
|
4
4
|
|
5
|
-
|
6
|
-
- submit_job
|
7
|
-
- get_job_status
|
8
|
-
- get_web_token
|
5
|
+
If you haven’t already, [sign up for a free Smile Identity account](https://www.smileidentity.com/schedule-a-demo/), which comes with Sandbox access.
|
9
6
|
|
10
|
-
|
11
|
-
- submit_job
|
7
|
+
Please see [CHANGELOG.md](CHANGELOG.md) for release versions and changes.
|
12
8
|
|
13
|
-
|
14
|
-
- generate_sec_key
|
15
|
-
- confirm_sec_key
|
9
|
+
## Features
|
16
10
|
|
17
|
-
The
|
18
|
-
- get_job_status
|
11
|
+
The library exposes four classes namely; the WebApi class, the IDApi class, the Signature class, and the Utilities class.
|
19
12
|
|
20
|
-
|
13
|
+
The WebApi class has the following public methods:
|
14
|
+
|
15
|
+
- `submit_job` - handles submission of any of Smile Identity products that requires an image i.e. [Biometric KYC](https://docs.smileidentity.com/products/biometric-kyc), [Document Verification](https://docs.smileidentity.com/products/document-verification), [SmartSelfieTM Authentication](https://docs.smileidentity.com/products/biometric-authentication) and [Business Verification](https://docs.smileidentity.com/products/for-businesses-kyb/business-verification).
|
16
|
+
- `get_web_token` - handles generation of web token, if you are using the [Hosted Web Integration](https://docs.smileidentity.com/web-mobile-web/web-integration-beta).
|
17
|
+
|
18
|
+
The IDApi class has the following public method:
|
19
|
+
|
20
|
+
- `submit_job` - handles submission of [Enhanced KYC](https://docs.smileidentity.com/products/identity-lookup) and [Basic KYC](https://docs.smileidentity.com/products/id-verification).
|
21
|
+
|
22
|
+
The Signature class has the following public methods:
|
23
|
+
|
24
|
+
- `generate_signature` - generate a signature which is then passed as a signature param when making requests to the Smile Identity server.
|
25
|
+
- `confirm_signature` - ensure a response is truly from the Smile Identity server by confirming the incoming signature.
|
21
26
|
|
22
|
-
|
27
|
+
The Utilities Class allows you as the Partner to have access to our general Utility functions to gain access to your data. It has the following public methods:
|
23
28
|
|
24
|
-
|
29
|
+
- `get_job_status` - retrieve information & results of a job. Read more on job status in the [Smile Identity documentation](https://docs.smileidentity.com/further-reading/job-status).
|
25
30
|
|
26
31
|
## Installation
|
27
32
|
|
@@ -32,6 +37,7 @@ Add this line to your application's Gemfile:
|
|
32
37
|
```ruby
|
33
38
|
gem 'smile-identity-core'
|
34
39
|
```
|
40
|
+
|
35
41
|
and require the package:
|
36
42
|
|
37
43
|
```ruby
|
@@ -40,461 +46,24 @@ require 'smile-identity-core'
|
|
40
46
|
|
41
47
|
Or install it to your system as:
|
42
48
|
|
43
|
-
```
|
44
|
-
|
45
|
-
```
|
46
|
-
|
47
|
-
You now may use the classes as follows:
|
48
|
-
|
49
|
-
#### Web Api Class
|
50
|
-
|
51
|
-
##### submit_job method
|
52
|
-
```ruby
|
53
|
-
connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
|
54
|
-
|
55
|
-
response = connection.submit_job(partner_params, images, id_info, options)
|
56
|
-
```
|
57
|
-
|
58
|
-
Please note that if you do not need to pass through id_info or options, you may omit calling those class and send through nil in submit_job, as follows:
|
59
|
-
|
60
|
-
```ruby
|
61
|
-
response = connection.submit_job(partner_params, images, nil, nil);
|
62
|
-
```
|
63
|
-
|
64
|
-
In the case of a Job Type 5 you can simply omit the the images and options keys. Remember that the response is immediate, so there is no need to query the job_status. There is also no enrollment so no images are required. The response for a job type 5 can be found in the response section below.
|
65
|
-
|
66
|
-
```ruby
|
67
|
-
response = connection.submit_job(partner_params, nil, id_info, nil);
|
68
|
-
```
|
69
|
-
|
70
|
-
**Response:**
|
71
|
-
|
72
|
-
Should you choose to *set return_job_status to false*, the response will be a JSON String containing:
|
73
|
-
```ruby
|
74
|
-
{success: true, smile_job_id: smile_job_id}
|
75
|
-
```
|
76
|
-
|
77
|
-
However, if you have *set return_job_status to true (with image_links and history)* then you will receive JSON Object response like below:
|
78
|
-
```json
|
79
|
-
{
|
80
|
-
"job_success":true,
|
81
|
-
"result":{
|
82
|
-
"ConfidenceValue":"99",
|
83
|
-
"JSONVersion":"1.0.0",
|
84
|
-
"Actions":{
|
85
|
-
"Verify_ID_Number":"Verified",
|
86
|
-
"Return_Personal_Info":"Returned",
|
87
|
-
"Human_Review_Update_Selfie":"Not Applicable",
|
88
|
-
"Human_Review_Compare":"Not Applicable",
|
89
|
-
"Update_Registered_Selfie_On_File":"Not Applicable",
|
90
|
-
"Liveness_Check":"Not Applicable",
|
91
|
-
"Register_Selfie":"Approved",
|
92
|
-
"Human_Review_Liveness_Check":"Not Applicable",
|
93
|
-
"Selfie_To_ID_Authority_Compare":"Completed",
|
94
|
-
"Selfie_To_ID_Card_Compare":"Not Applicable",
|
95
|
-
"Selfie_To_Registered_Selfie_Compare":"Not Applicable"
|
96
|
-
},
|
97
|
-
"ResultText":"Enroll User",
|
98
|
-
"IsFinalResult":"true",
|
99
|
-
"IsMachineResult":"true",
|
100
|
-
"ResultType":"SAIA",
|
101
|
-
"PartnerParams":{
|
102
|
-
"job_type":"1",
|
103
|
-
"optional_info":"we are one",
|
104
|
-
"user_id":"HBBBBBBH57g",
|
105
|
-
"job_id":"HBBBBBBHg"
|
106
|
-
},
|
107
|
-
"Source":"WebAPI",
|
108
|
-
"ResultCode":"0810",
|
109
|
-
"SmileJobID":"0000001111"
|
110
|
-
},
|
111
|
-
"code":"2302",
|
112
|
-
"job_complete":true,
|
113
|
-
"signature":"HKBhxcv+1qaLy\C7PjVtk257dE=|1577b051a4313ed5e3e4d29893a66f966e31af0a2d2f6bec2a7f2e00f2701259",
|
114
|
-
"history":[
|
115
|
-
{
|
116
|
-
"ConfidenceValue":"99",
|
117
|
-
"JSONVersion":"1.0.0",
|
118
|
-
"Actions":{
|
119
|
-
"Verify_ID_Number":"Verified",
|
120
|
-
"Return_Personal_Info":"Returned",
|
121
|
-
"Human_Review_Update_Selfie":"Not Applicable",
|
122
|
-
"Human_Review_Compare":"Not Applicable",
|
123
|
-
"Update_Registered_Selfie_On_File":"Not Applicable",
|
124
|
-
"Liveness_Check":"Not Applicable",
|
125
|
-
"Register_Selfie":"Approved",
|
126
|
-
"Human_Review_Liveness_Check":"Not Applicable",
|
127
|
-
"Selfie_To_ID_Authority_Compare":"Completed",
|
128
|
-
"Selfie_To_ID_Card_Compare":"Not Applicable",
|
129
|
-
"Selfie_To_Registered_Selfie_Compare":"Not Applicable"
|
130
|
-
},
|
131
|
-
"ResultText":"Enroll User",
|
132
|
-
"IsFinalResult":"true",
|
133
|
-
"IsMachineResult":"true",
|
134
|
-
"ResultType":"SAIA",
|
135
|
-
"PartnerParams":{
|
136
|
-
"job_type":"1",
|
137
|
-
"optional_info":"we are one",
|
138
|
-
"user_id":"HBBBBBBH57g",
|
139
|
-
"job_id":"HBBBBBBHg"
|
140
|
-
},
|
141
|
-
"Source":"WebAPI",
|
142
|
-
"ResultCode":"0810",
|
143
|
-
"SmileJobID":"0000001111"
|
144
|
-
}
|
145
|
-
],
|
146
|
-
"image_links":{
|
147
|
-
"selfie_image":"image_link"
|
148
|
-
},
|
149
|
-
"timestamp":"2019-10-10T12:32:04.622Z"
|
150
|
-
}
|
151
|
-
```
|
152
|
-
|
153
|
-
You can also *view your response asynchronously at the callback* that you have set, it will look as follows:
|
154
|
-
```json
|
155
|
-
{
|
156
|
-
"job_success":true,
|
157
|
-
"result":{
|
158
|
-
"ConfidenceValue":"99",
|
159
|
-
"JSONVersion":"1.0.0",
|
160
|
-
"Actions":{
|
161
|
-
"Verify_ID_Number":"Verified",
|
162
|
-
"Return_Personal_Info":"Returned",
|
163
|
-
"Human_Review_Update_Selfie":"Not Applicable",
|
164
|
-
"Human_Review_Compare":"Not Applicable",
|
165
|
-
"Update_Registered_Selfie_On_File":"Not Applicable",
|
166
|
-
"Liveness_Check":"Not Applicable",
|
167
|
-
"Register_Selfie":"Approved",
|
168
|
-
"Human_Review_Liveness_Check":"Not Applicable",
|
169
|
-
"Selfie_To_ID_Authority_Compare":"Completed",
|
170
|
-
"Selfie_To_ID_Card_Compare":"Not Applicable",
|
171
|
-
"Selfie_To_Registered_Selfie_Compare":"Not Applicable"
|
172
|
-
},
|
173
|
-
"ResultText":"Enroll User",
|
174
|
-
"IsFinalResult":"true",
|
175
|
-
"IsMachineResult":"true",
|
176
|
-
"ResultType":"SAIA",
|
177
|
-
"PartnerParams":{
|
178
|
-
"job_type":"1",
|
179
|
-
"optional_info":"we are one",
|
180
|
-
"user_id":"HBBBBBBH57g",
|
181
|
-
"job_id":"HBBBBBBHg"
|
182
|
-
},
|
183
|
-
"Source":"WebAPI",
|
184
|
-
"ResultCode":"0810",
|
185
|
-
"SmileJobID":"0000001111"
|
186
|
-
},
|
187
|
-
"code":"2302",
|
188
|
-
"job_complete":true,
|
189
|
-
"signature":"HKBhxcv+1qaLy\C7PjVtk257dE=|1577b051a4313ed5e3e4d29893a66f966e31af0a2d2f6bec2a7f2e00f2701259",
|
190
|
-
"history":[
|
191
|
-
{
|
192
|
-
"ConfidenceValue":"99",
|
193
|
-
"JSONVersion":"1.0.0",
|
194
|
-
"Actions":{
|
195
|
-
"Verify_ID_Number":"Verified",
|
196
|
-
"Return_Personal_Info":"Returned",
|
197
|
-
"Human_Review_Update_Selfie":"Not Applicable",
|
198
|
-
"Human_Review_Compare":"Not Applicable",
|
199
|
-
"Update_Registered_Selfie_On_File":"Not Applicable",
|
200
|
-
"Liveness_Check":"Not Applicable",
|
201
|
-
"Register_Selfie":"Approved",
|
202
|
-
"Human_Review_Liveness_Check":"Not Applicable",
|
203
|
-
"Selfie_To_ID_Authority_Compare":"Completed",
|
204
|
-
"Selfie_To_ID_Card_Compare":"Not Applicable",
|
205
|
-
"Selfie_To_Registered_Selfie_Compare":"Not Applicable"
|
206
|
-
},
|
207
|
-
"ResultText":"Enroll User",
|
208
|
-
"IsFinalResult":"true",
|
209
|
-
"IsMachineResult":"true",
|
210
|
-
"ResultType":"SAIA",
|
211
|
-
"PartnerParams":{
|
212
|
-
"job_type":"1",
|
213
|
-
"optional_info":"we are one",
|
214
|
-
"user_id":"HBBBBBBH57g",
|
215
|
-
"job_id":"HBBBBBBHg"
|
216
|
-
},
|
217
|
-
"Source":"WebAPI",
|
218
|
-
"ResultCode":"0810",
|
219
|
-
"SmileJobID":"0000001111"
|
220
|
-
}
|
221
|
-
],
|
222
|
-
"image_links":{
|
223
|
-
"selfie_image":"image_link"
|
224
|
-
},
|
225
|
-
"timestamp":"2019-10-10T12:32:04.622Z"
|
226
|
-
}
|
227
|
-
```
|
228
|
-
|
229
|
-
If you have queried a job type 5, your response be a JSON String that will contain the following:
|
230
|
-
```json
|
231
|
-
{
|
232
|
-
"JSONVersion":"1.0.0",
|
233
|
-
"SmileJobID":"0000001105",
|
234
|
-
"PartnerParams":{
|
235
|
-
"user_id":"T6yzdOezucdsPrY0QG9LYNDGOrC",
|
236
|
-
"job_id":"FS1kd1dd15JUpd87gTBDapvFxv0",
|
237
|
-
"job_type":5
|
238
|
-
},
|
239
|
-
"ResultType":"ID Verification",
|
240
|
-
"ResultText":"ID Number Validated",
|
241
|
-
"ResultCode":"1012",
|
242
|
-
"IsFinalResult":"true",
|
243
|
-
"Actions":{
|
244
|
-
"Verify_ID_Number":"Verified",
|
245
|
-
"Return_Personal_Info":"Returned"
|
246
|
-
},
|
247
|
-
"Country":"NG",
|
248
|
-
"IDType":"PASSPORT",
|
249
|
-
"IDNumber":"A04150107",
|
250
|
-
"ExpirationDate":"2017-10-28",
|
251
|
-
"FullName":"ADEYEMI KEHINDE ADUNOLA",
|
252
|
-
"DOB":"1989-09-20",
|
253
|
-
"Photo":"SomeBase64Image",
|
254
|
-
"sec_key":"pjxsxEY69zEHjSPFvPEQTqu17vpZbw+zTNqaFxRWpYDiO+7wzKc9zvPU2lRGiKg7rff6nGPBvQ6rA7/wYkcLrlD2SuR2Q8hOcDFgni3PJHutij7j6ThRdpTwJRO2GjLXN5HHDB52NjAvKPyclSDANHrG1qb/tloO7x4bFJ7tKYE=|8faebe00b317654548f8b739dc631431b67d2d4e6ab65c6d53539aaad1600ac7",
|
255
|
-
"timestamp":1570698930193
|
256
|
-
}
|
257
|
-
```
|
258
|
-
|
259
|
-
##### get_job_status method
|
260
|
-
Sometimes, you may want to get a particular job status at a later time. You may use the get_job_status function to do this:
|
261
|
-
|
262
|
-
You will already have your Web Api class initialised as follows:
|
263
|
-
```ruby
|
264
|
-
connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
|
265
|
-
```
|
266
|
-
|
267
|
-
Thereafter, simply call get_job_status with the correct parameters:
|
268
|
-
```ruby
|
269
|
-
response = connection.get_job_status(partner_params, options)
|
270
|
-
|
271
|
-
where options is {return_history: true | false, return_image_links: true | false}
|
272
|
-
```
|
273
|
-
|
274
|
-
Please note that if you do not need to pass through options if you will not be using them, you may omit pass through an empty hash or nil instead:
|
275
|
-
```ruby
|
276
|
-
response = connection.get_job_status(partner_params, nil);
|
277
|
-
```
|
278
|
-
|
279
|
-
**Response**
|
280
|
-
|
281
|
-
Your response will return a JSON Object below with image_links and history included:
|
282
|
-
|
283
|
-
```json
|
284
|
-
{
|
285
|
-
"job_success":true,
|
286
|
-
"result":{
|
287
|
-
"ConfidenceValue":"99",
|
288
|
-
"JSONVersion":"1.0.0",
|
289
|
-
"Actions":{
|
290
|
-
"Verify_ID_Number":"Verified",
|
291
|
-
"Return_Personal_Info":"Returned",
|
292
|
-
"Human_Review_Update_Selfie":"Not Applicable",
|
293
|
-
"Human_Review_Compare":"Not Applicable",
|
294
|
-
"Update_Registered_Selfie_On_File":"Not Applicable",
|
295
|
-
"Liveness_Check":"Not Applicable",
|
296
|
-
"Register_Selfie":"Approved",
|
297
|
-
"Human_Review_Liveness_Check":"Not Applicable",
|
298
|
-
"Selfie_To_ID_Authority_Compare":"Completed",
|
299
|
-
"Selfie_To_ID_Card_Compare":"Not Applicable",
|
300
|
-
"Selfie_To_Registered_Selfie_Compare":"Not Applicable"
|
301
|
-
},
|
302
|
-
"ResultText":"Enroll User",
|
303
|
-
"IsFinalResult":"true",
|
304
|
-
"IsMachineResult":"true",
|
305
|
-
"ResultType":"SAIA",
|
306
|
-
"PartnerParams":{
|
307
|
-
"job_type":"1",
|
308
|
-
"optional_info":"we are one",
|
309
|
-
"user_id":"HBBBBBBH57g",
|
310
|
-
"job_id":"HBBBBBBHg"
|
311
|
-
},
|
312
|
-
"Source":"WebAPI",
|
313
|
-
"ResultCode":"0810",
|
314
|
-
"SmileJobID":"0000001111"
|
315
|
-
},
|
316
|
-
"code":"2302",
|
317
|
-
"job_complete":true,
|
318
|
-
"signature":"HKBhxcv+1qaLy\C7PjVtk257dE=|1577b051a4313ed5e3e4d29893a66f966e31af0a2d2f6bec2a7f2e00f2701259",
|
319
|
-
"history":[
|
320
|
-
{
|
321
|
-
"ConfidenceValue":"99",
|
322
|
-
"JSONVersion":"1.0.0",
|
323
|
-
"Actions":{
|
324
|
-
"Verify_ID_Number":"Verified",
|
325
|
-
"Return_Personal_Info":"Returned",
|
326
|
-
"Human_Review_Update_Selfie":"Not Applicable",
|
327
|
-
"Human_Review_Compare":"Not Applicable",
|
328
|
-
"Update_Registered_Selfie_On_File":"Not Applicable",
|
329
|
-
"Liveness_Check":"Not Applicable",
|
330
|
-
"Register_Selfie":"Approved",
|
331
|
-
"Human_Review_Liveness_Check":"Not Applicable",
|
332
|
-
"Selfie_To_ID_Authority_Compare":"Completed",
|
333
|
-
"Selfie_To_ID_Card_Compare":"Not Applicable",
|
334
|
-
"Selfie_To_Registered_Selfie_Compare":"Not Applicable"
|
335
|
-
},
|
336
|
-
"ResultText":"Enroll User",
|
337
|
-
"IsFinalResult":"true",
|
338
|
-
"IsMachineResult":"true",
|
339
|
-
"ResultType":"SAIA",
|
340
|
-
"PartnerParams":{
|
341
|
-
"job_type":"1",
|
342
|
-
"optional_info":"we are one",
|
343
|
-
"user_id":"HBBBBBBH57g",
|
344
|
-
"job_id":"HBBBBBBHg"
|
345
|
-
},
|
346
|
-
"Source":"WebAPI",
|
347
|
-
"ResultCode":"0810",
|
348
|
-
"SmileJobID":"0000001111"
|
349
|
-
}
|
350
|
-
],
|
351
|
-
"image_links":{
|
352
|
-
"selfie_image":"image_link"
|
353
|
-
},
|
354
|
-
"timestamp":"2019-10-10T12:32:04.622Z"
|
355
|
-
}
|
49
|
+
```shell
|
50
|
+
gem install smile-identity-core
|
356
51
|
```
|
357
52
|
|
358
|
-
|
359
|
-
You may want to use our hosted web integration, and create a session. The `get_web_token` method enables this.
|
360
|
-
You have your Web Api class initialised as follows:
|
361
|
-
```ruby
|
362
|
-
connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
|
363
|
-
|
364
|
-
```
|
365
|
-
|
366
|
-
Next, you'll need to create your request params. This should take the following
|
367
|
-
structure:
|
368
|
-
|
369
|
-
```ruby
|
370
|
-
{
|
371
|
-
user_id: 'user-1', # String: required
|
372
|
-
job_id: 'job-1', # String: required
|
373
|
-
product: 'authentication', # String: required one of 'authentication', 'identity_verification', 'smartselfie', 'ekyc_smartselfie', 'enhanced_kyc', 'document_verification'
|
374
|
-
callback_url: "https://smileidentity.com/callback" # String: required, optional if callback url was set during instantiation of the class
|
375
|
-
}
|
376
|
-
```
|
377
|
-
|
378
|
-
Thereafter, call `get_web_token` with the correct parameters:
|
379
|
-
```ruby
|
380
|
-
response = connection.get_web_token(request_params)
|
381
|
-
```
|
382
|
-
|
383
|
-
**Response**
|
384
|
-
|
385
|
-
Your response will return a hash that contains
|
386
|
-
```ruby
|
387
|
-
{
|
388
|
-
token: <token_string>
|
389
|
-
}
|
390
|
-
```
|
391
|
-
|
392
|
-
#### ID Api Class
|
393
|
-
|
394
|
-
|
395
|
-
##### submit_job method
|
396
|
-
```ruby
|
397
|
-
connection = SmileIdentityCore::IDApi.new(partner_id, api_key, sid_server)
|
398
|
-
|
399
|
-
response = connection.submit_job(partner_params, id_info)
|
400
|
-
```
|
401
|
-
|
402
|
-
**Response**
|
403
|
-
|
404
|
-
Your response will return a JSON String containing the below:
|
405
|
-
```json
|
406
|
-
{
|
407
|
-
"JSONVersion":"1.0.0",
|
408
|
-
"SmileJobID":"0000001105",
|
409
|
-
"PartnerParams":{
|
410
|
-
"user_id":"T6yzdOezucdsPrY0QG9LYNDGOrC",
|
411
|
-
"job_id":"FS1kd1dd15JUpd87gTBDapvFxv0",
|
412
|
-
"job_type":5
|
413
|
-
},
|
414
|
-
"ResultType":"ID Verification",
|
415
|
-
"ResultText":"ID Number Validated",
|
416
|
-
"ResultCode":"1012",
|
417
|
-
"IsFinalResult":"true",
|
418
|
-
"Actions":{
|
419
|
-
"Verify_ID_Number":"Verified",
|
420
|
-
"Return_Personal_Info":"Returned"
|
421
|
-
},
|
422
|
-
"Country":"NG",
|
423
|
-
"IDType":"PASSPORT",
|
424
|
-
"IDNumber":"A04150107",
|
425
|
-
"ExpirationDate":"2017-10-28",
|
426
|
-
"FullName":"ADEYEMI KEHINDE ADUNOLA",
|
427
|
-
"DOB":"1989-09-20",
|
428
|
-
"Photo":"SomeBase64Image",
|
429
|
-
"sec_key":"pjxsxEY69zEHjSPFvPEQTqu17vpZbw+zTNqaFxRWpYDiO+7wzKc9zvPU2lRGiKg7rff6nGPBvQ6rA7/wYkcLrlD2SuR2Q8hOcDFgni3PJHutij7j6ThRdpTwJRO2GjLXN5HHDB52NjAvKPyclSDANHrG1qb/tloO7x4bFJ7tKYE=|8faebe00b317654548f8b739dc631431b67d2d4e6ab65c6d53539aaad1600ac7",
|
430
|
-
"timestamp":1570698930193
|
431
|
-
}
|
432
|
-
```
|
433
|
-
|
434
|
-
#### Signature Class
|
435
|
-
|
436
|
-
##### generate_sec_key method
|
437
|
-
|
438
|
-
```ruby
|
439
|
-
connection = SmileIdentityCore::Signature.new(partner_id, api_key)
|
440
|
-
|
441
|
-
sec_key = connection.generate_sec_key(timestamp)
|
442
|
-
where timestamp is optional
|
443
|
-
|
444
|
-
```
|
445
|
-
|
446
|
-
The response will be a hash:
|
447
|
-
|
448
|
-
```ruby
|
449
|
-
{
|
450
|
-
:sec_key=> "<the generated sec key>",
|
451
|
-
:timestamp=> 1563283420
|
452
|
-
}
|
453
|
-
```
|
454
|
-
|
455
|
-
##### confirm_sec_key method
|
456
|
-
|
457
|
-
You can also confirm the signature that you receive when you interacting with our servers, simply use the confirm_sec_key method which returns a boolean:
|
458
|
-
|
459
|
-
```ruby
|
460
|
-
connection = SmileIdentityCore::Signature.new(partner_id, api_key)
|
461
|
-
sec_key = connection.confirm_sec_key(sec_key, timestamp)
|
462
|
-
```
|
463
|
-
|
464
|
-
#### Utilities Class
|
465
|
-
|
466
|
-
You may want to receive more information about a job. This is built into Web Api if you choose to set return_job_status as true in the options hash. However, you also have the option to build the functionality yourself by using the Utilities class. Please note that if you are querying a job immediately after submitting it, you will need to poll it for the duration of the job.
|
467
|
-
|
468
|
-
```ruby
|
469
|
-
utilities_connection = SmileIdentityCore::Utilities.new('partner_id', 'api_key' , sid_server)
|
470
|
-
|
471
|
-
utilities_connection.get_job_status('user_id', 'job_id', options)
|
472
|
-
where options is {return_history: true | false, return_image_links: true | false}
|
473
|
-
```
|
474
|
-
|
475
|
-
## Development
|
476
|
-
|
477
|
-
After checking out the repo, run `bundle install` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
478
|
-
|
479
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
480
|
-
|
481
|
-
You can use `bundle console` and then call the necessary classes with their parameters.
|
53
|
+
## Documentation
|
482
54
|
|
483
|
-
|
55
|
+
For extensive instructions on usage of the library and sample codes, please refer to the official Smile Identity [documentation](https://docs.smileidentity.com/server-to-server/ruby).
|
484
56
|
|
485
|
-
|
486
|
-
After running your tests open the coverage/index.html to view the test coverage
|
57
|
+
Before that, you should take a look at the examples in the [examples](/examples) folder.
|
487
58
|
|
488
|
-
##
|
59
|
+
## Getting Help
|
489
60
|
|
490
|
-
|
491
|
-
- Update the version number in `version.rb`
|
492
|
-
- Run `gem build smile-identity-core.gemspec`
|
493
|
-
- Thereafter `gem push smile-identity-core-<version>.gem`.
|
61
|
+
For usage questions, the best resource is [our official documentation](https://docs.smileidentity.com). However, if you require further assistance, you can file a [support ticket via our portal](https://portal.smileidentity.com/partner/support/tickets) or visit the [contact us page](https://portal.smileidentity.com/partner/support/tickets) on our website.
|
494
62
|
|
495
|
-
|
63
|
+
## Contributing
|
496
64
|
|
65
|
+
Bug reports and pull requests are welcome on GitHub [here](https://github.com/smileidentity/smile-identity-core-ruby).
|
497
66
|
|
498
|
-
##
|
67
|
+
## License
|
499
68
|
|
500
|
-
|
69
|
+
MIT License
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'smile-identity-core'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "smile-identity-core"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start(__FILE__)
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'smile-identity-core'
|
4
|
+
|
5
|
+
# See https://docs.smileidentity.com/server-to-server/ruby/products/biometric-kyc for
|
6
|
+
# how to setup and retrieve configuation values for the WebApi class.
|
7
|
+
|
8
|
+
# Initialize
|
9
|
+
partner_id = '<Put your partner ID here>'; # login to the Smile Identity portal to view your partner id
|
10
|
+
default_callback = '<Put your default callback url here>'
|
11
|
+
api_key = '<Put your API key here>'; # copy your API key from the Smile Identity portal
|
12
|
+
sid_server = '<0 | 1>'; # Use '0' for the sandbox server, use '1' for production server
|
13
|
+
|
14
|
+
connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
|
15
|
+
|
16
|
+
# Create required tracking parameters
|
17
|
+
partner_params = {
|
18
|
+
user_id: '<put your unique ID for the user here>',
|
19
|
+
job_id: '<put your unique job ID here>',
|
20
|
+
job_type: 1
|
21
|
+
}
|
22
|
+
|
23
|
+
# Create image list
|
24
|
+
# image_type_id Integer
|
25
|
+
# 0 - Selfie image jpg or png (if you have the full path of the selfie)
|
26
|
+
# 2 - Selfie image jpg or png base64 encoded (if you have the base64image string of the selfie)
|
27
|
+
# 4 - Liveness image jpg or png (if you have the full path of the liveness image)
|
28
|
+
# 6 - Liveness image jpg or png base64 encoded (if you have the base64image string of the liveness image)
|
29
|
+
image_details = [
|
30
|
+
{
|
31
|
+
image_type_id: '<0 | 2>',
|
32
|
+
image: '<full path to selfie image or base64image string>'
|
33
|
+
},
|
34
|
+
{ # Not required if you don't require proof of life (note photo of
|
35
|
+
# photo check will still be performed on the uploaded selfie)
|
36
|
+
image_type_id: '<4 | 6>',
|
37
|
+
image: '<full path to liveness image or base64 image string>'
|
38
|
+
}
|
39
|
+
]
|
40
|
+
|
41
|
+
# Create ID number info
|
42
|
+
id_info = {
|
43
|
+
first_name: '<first name>',
|
44
|
+
last_name: '<surname>',
|
45
|
+
country: '<2-letter country code>',
|
46
|
+
id_type: '<id type>',
|
47
|
+
id_number: '<valid id number>',
|
48
|
+
dob: '<date of birth>', # yyyy-mm-dd
|
49
|
+
entered: 'true' # must be a string
|
50
|
+
}
|
51
|
+
|
52
|
+
# Set options for the job
|
53
|
+
options = {
|
54
|
+
# Set to true if you want to get the job result in sync (in addition to the result been sent
|
55
|
+
# to your callback). If set to false, result is sent to callback url only.
|
56
|
+
return_job_status: '<true | false>',
|
57
|
+
# Set to true to receive all of the updates you would otherwise have received in your callback
|
58
|
+
# as opposed to only the final result. You must set return_job_status to true to use this flag.
|
59
|
+
return_history: '<true | false>',
|
60
|
+
# Set to true to receive links to the selfie and the photo
|
61
|
+
# it was compared to. You must set return_job_status to true to use this flag.
|
62
|
+
return_image_links: '<true | false>',
|
63
|
+
signature: true
|
64
|
+
}
|
65
|
+
|
66
|
+
# Submit the job
|
67
|
+
connection.submit_job(partner_params, image_details, id_info, options)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'smile-identity-core'
|
4
|
+
require 'securerandom'
|
5
|
+
# See https://docs.smileidentity.com/products/for-businesses-kyb/business-verification for
|
6
|
+
# more information on business verification
|
7
|
+
|
8
|
+
# Initialize
|
9
|
+
partner_id = '<Put your partner ID here>'; # login to the Smile Identity portal to view your partner id
|
10
|
+
default_callback = '<Put your default callback url here>'
|
11
|
+
api_key = '<Put your API key here>'; # copy your API key from the Smile Identity portal
|
12
|
+
sid_server = '<0 | 1>'; # Use '0' for the sandbox server, use '1' for production server
|
13
|
+
|
14
|
+
connection = SmileIdentityCore::IDApi.new(partner_id, default_callback, api_key, sid_server)
|
15
|
+
|
16
|
+
# Create required tracking parameters
|
17
|
+
partner_params = {
|
18
|
+
job_id: '<put your unique job ID here>',
|
19
|
+
user_id: '<put your unique ID for the user here>',
|
20
|
+
job_type: SmileIdentityCore::JobType::BUSINESS_VERIFICATION
|
21
|
+
}
|
22
|
+
|
23
|
+
# Create ID info
|
24
|
+
id_info = {
|
25
|
+
# The country where ID document was issued
|
26
|
+
country: '<2-letter country code>',
|
27
|
+
# The ID document type
|
28
|
+
# Available types BASIC_BUSINESS_REGISTRATION, BUSINESS_REGISTRATION and TAX_INFORMATION
|
29
|
+
id_type: '<id type>',
|
30
|
+
# The business registration or tax number
|
31
|
+
id_number: '0000000',
|
32
|
+
# The business incorporation type bn - business name, co - private/public limited, it - incorporated trustees
|
33
|
+
# Only required for BASIC_BUSINESS_REGISTRATION and BUSINESS_REGISTRATION in Nigeria
|
34
|
+
business_type: 'co',
|
35
|
+
# Postal address of business. Only Required for BUSINESS_REGISTRATION in Kenya
|
36
|
+
postal_address: '<postal address>',
|
37
|
+
# Postal code of business. Only Required for BUSINESS_REGISTRATION in Kenya
|
38
|
+
postal_code: '<postal code>'
|
39
|
+
}
|
40
|
+
|
41
|
+
# Set the options for the job
|
42
|
+
options = {}
|
43
|
+
|
44
|
+
# Submit the job
|
45
|
+
connection.submit_job(partner_params, id_info, options)
|