smile-identity-core 0.2.3 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21c2a5a3b5e5f424a1c496debe16bab3a3950123b734c1a35e43035da2f7c622
4
- data.tar.gz: a8cebcd27f35a24ae3bdcd61c692dae4523d8cf80e2f7adaf2e021dfe150a30e
3
+ metadata.gz: a3b6be5ffaad64aa13c654eca628db1437da28d46a1e3d4b3564b373e4132508
4
+ data.tar.gz: 1042167bb8981ac85cf0a1dbf466f2b099ca5468b013e62119a322582a879c9c
5
5
  SHA512:
6
- metadata.gz: f30735bd2481bd6baecad7b0c37c4aa6ca239e3c00ef61e96aa4f4346b732a2641fc2bcf34898e68de766835ec94aa759d481e014350936a4a6d40b2086b46a5
7
- data.tar.gz: fd8bfef72649e53477633ed2bcd3d2235295b06b78ee418fecdfbe06466da244c1b0afd19ed5e79b9fb526bef191ce90b272e7fb658f48c22bdc214d53ddc015
6
+ metadata.gz: f301a2f41634473bb47393dc5992f30f381a8088250aa2ebfc7739003384c52a37031182fc6e048b78227e990c465659f18fcc0d39bd4efc65ecc48d285325ce
7
+ data.tar.gz: ba2e07c8c8f68117f7343bf0949277999a3e48ec770a50bfdd51ab0f98690d4219d2f989bbe436a558a9ca9adc3092607ae427911f2fc68e1233e94c33267f47
data/CHANGELOG.md CHANGED
@@ -32,3 +32,10 @@ Add the language to the package information
32
32
  ## [0.2.3] - 2019-09-17
33
33
  ### Updated
34
34
  Lenient Decoding of the api key
35
+
36
+ ## [1.0.0] - 2019-10-11
37
+ ## Updated
38
+ Amend the success response when job status is false to be a JSON String containing {"success":true,"smile_job_id":"job_id"}
39
+ Add the ID API Class
40
+ Add the ability to query ID Api from the Web API class
41
+ Update the documentation
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smile-identity-core (0.2.3)
4
+ smile-identity-core (1.0.0)
5
5
  rubyzip (~> 1.2, >= 1.2.3)
6
6
  typhoeus (~> 1.0, >= 1.0.1)
7
7
 
@@ -28,7 +28,7 @@ GEM
28
28
  diff-lcs (>= 1.2.0, < 2.0)
29
29
  rspec-support (~> 3.8.0)
30
30
  rspec-support (3.8.2)
31
- rubyzip (1.2.4)
31
+ rubyzip (1.3.0)
32
32
  simplecov (0.12.0)
33
33
  docile (~> 1.1.0)
34
34
  json (>= 1.8, < 3)
data/README.md CHANGED
@@ -6,6 +6,9 @@ The **Web API Class** allows you as the Partner to validate a user’s identity
6
6
  - submit_job
7
7
  - get_job_status
8
8
 
9
+ The **ID Class** lets you performs basic KYC Services including verifying an ID number as well as retrieve a user's Personal Information. It has the following public methods:
10
+ - submit_job
11
+
9
12
  The **Signature Class** allows you as the Partner to generate a sec key to interact with our servers. It has the following public methods:
10
13
  - generate_sec_key
11
14
  - confirm_sec_key
@@ -15,7 +18,7 @@ The **Utilities Class** allows you as the Partner to have access to our general
15
18
 
16
19
  ## Documentation
17
20
 
18
- This gem requires specific input parameters, for more detail on these parameters please refer to our [documentation for Web API](https://docs-smileid.herokuapp.com/docs#web-api-introduction).
21
+ This gem requires specific input parameters, for more detail on these parameters please refer to our [documentation for Web API](https://docs.smileidentity.com).
19
22
 
20
23
  Please note that you will have to be a Smile Identity Partner to be able to query our services. You can sign up on the [Portal](https://test-smileid.herokuapp.com/signup?products[]=1-IDVALIDATION&products[]=2-AUTHENTICATION).
21
24
 
@@ -52,51 +55,203 @@ $ response = connection.submit_job(partner_params, images, id_info, options)
52
55
  ```
53
56
 
54
57
  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:
58
+
59
+ ```
60
+ $ response = connection.submit_job(partner_params, images, nil, nil);
61
+ ```
62
+
63
+ 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.
64
+
65
+ ```
66
+ $ response = connection.submit_job(partner_params, nil, id_info, nil);
67
+ ```
68
+
69
+ **Response:**
70
+
71
+ Should you choose to *set return_job_status to false*, the response will be a JSON String containing:
55
72
  ```
56
- String response = connection.submit_job(partner_params, images, nil, nil);
73
+ {success: true, smile_job_id: smile_job_id}
57
74
  ```
58
75
 
59
- The response will be nil if you chose to set return_job_status to false, however if you have set return_job_status to true then you will receive a response like below:
76
+ However, if you have *set return_job_status to true (with image_links and history)* then you will receive JSON Object response like below:
77
+ ```
78
+ {
79
+ "job_success":true,
80
+ "result":{
81
+ "ConfidenceValue":"99",
82
+ "JSONVersion":"1.0.0",
83
+ "Actions":{
84
+ "Verify_ID_Number":"Verified",
85
+ "Return_Personal_Info":"Returned",
86
+ "Human_Review_Update_Selfie":"Not Applicable",
87
+ "Human_Review_Compare":"Not Applicable",
88
+ "Update_Registered_Selfie_On_File":"Not Applicable",
89
+ "Liveness_Check":"Not Applicable",
90
+ "Register_Selfie":"Approved",
91
+ "Human_Review_Liveness_Check":"Not Applicable",
92
+ "Selfie_To_ID_Authority_Compare":"Completed",
93
+ "Selfie_To_ID_Card_Compare":"Not Applicable",
94
+ "Selfie_To_Registered_Selfie_Compare":"Not Applicable"
95
+ },
96
+ "ResultText":"Enroll User",
97
+ "IsFinalResult":"true",
98
+ "IsMachineResult":"true",
99
+ "ResultType":"SAIA",
100
+ "PartnerParams":{
101
+ "job_type":"1",
102
+ "optional_info":"we are one",
103
+ "user_id":"HBBBBBBH57g",
104
+ "job_id":"HBBBBBBHg"
105
+ },
106
+ "Source":"WebAPI",
107
+ "ResultCode":"0810",
108
+ "SmileJobID":"0000001111"
109
+ },
110
+ "code":"2302",
111
+ "job_complete":true,
112
+ "signature":"HKBhxcv+1qaLy\C7PjVtk257dE=|1577b051a4313ed5e3e4d29893a66f966e31af0a2d2f6bec2a7f2e00f2701259",
113
+ "history":[
114
+ {
115
+ "ConfidenceValue":"99",
116
+ "JSONVersion":"1.0.0",
117
+ "Actions":{
118
+ "Verify_ID_Number":"Verified",
119
+ "Return_Personal_Info":"Returned",
120
+ "Human_Review_Update_Selfie":"Not Applicable",
121
+ "Human_Review_Compare":"Not Applicable",
122
+ "Update_Registered_Selfie_On_File":"Not Applicable",
123
+ "Liveness_Check":"Not Applicable",
124
+ "Register_Selfie":"Approved",
125
+ "Human_Review_Liveness_Check":"Not Applicable",
126
+ "Selfie_To_ID_Authority_Compare":"Completed",
127
+ "Selfie_To_ID_Card_Compare":"Not Applicable",
128
+ "Selfie_To_Registered_Selfie_Compare":"Not Applicable"
129
+ },
130
+ "ResultText":"Enroll User",
131
+ "IsFinalResult":"true",
132
+ "IsMachineResult":"true",
133
+ "ResultType":"SAIA",
134
+ "PartnerParams":{
135
+ "job_type":"1",
136
+ "optional_info":"we are one",
137
+ "user_id":"HBBBBBBH57g",
138
+ "job_id":"HBBBBBBHg"
139
+ },
140
+ "Source":"WebAPI",
141
+ "ResultCode":"0810",
142
+ "SmileJobID":"0000001111"
143
+ }
144
+ ],
145
+ "image_links":{
146
+ "selfie_image":"image_link"
147
+ },
148
+ "timestamp":"2019-10-10T12:32:04.622Z"
149
+ }
150
+ ```
60
151
 
152
+ You can also *view your response asynchronously at the callback* that you have set, it will look as follows:
61
153
  ```
62
154
  {
63
- "timestamp": "2018-03-13T21:04:11.193Z",
64
- "signature": "<your signature>",
65
- "job_complete": true,
66
- "job_success": true,
67
- "result": {
68
- "ResultText": "Enroll User",
69
- "ResultType": "SAIA",
70
- "SmileJobID": "0000001897",
71
- "JSONVersion": "1.0.0",
72
- "IsFinalResult": "true",
73
- "PartnerParams": {
74
- "job_id": "52d0de86-be3b-4219-9e96-8195b0018944",
75
- "user_id": "e54e0e98-8b8c-4215-89f5-7f9ea42bf650",
76
- "job_type": 4
77
- },
78
- "ConfidenceValue": "100",
79
- "IsMachineResult": "true",
80
- }
81
- "code": "2302"
155
+ "job_success":true,
156
+ "result":{
157
+ "ConfidenceValue":"99",
158
+ "JSONVersion":"1.0.0",
159
+ "Actions":{
160
+ "Verify_ID_Number":"Verified",
161
+ "Return_Personal_Info":"Returned",
162
+ "Human_Review_Update_Selfie":"Not Applicable",
163
+ "Human_Review_Compare":"Not Applicable",
164
+ "Update_Registered_Selfie_On_File":"Not Applicable",
165
+ "Liveness_Check":"Not Applicable",
166
+ "Register_Selfie":"Approved",
167
+ "Human_Review_Liveness_Check":"Not Applicable",
168
+ "Selfie_To_ID_Authority_Compare":"Completed",
169
+ "Selfie_To_ID_Card_Compare":"Not Applicable",
170
+ "Selfie_To_Registered_Selfie_Compare":"Not Applicable"
171
+ },
172
+ "ResultText":"Enroll User",
173
+ "IsFinalResult":"true",
174
+ "IsMachineResult":"true",
175
+ "ResultType":"SAIA",
176
+ "PartnerParams":{
177
+ "job_type":"1",
178
+ "optional_info":"we are one",
179
+ "user_id":"HBBBBBBH57g",
180
+ "job_id":"HBBBBBBHg"
181
+ },
182
+ "Source":"WebAPI",
183
+ "ResultCode":"0810",
184
+ "SmileJobID":"0000001111"
185
+ },
186
+ "code":"2302",
187
+ "job_complete":true,
188
+ "signature":"HKBhxcv+1qaLy\C7PjVtk257dE=|1577b051a4313ed5e3e4d29893a66f966e31af0a2d2f6bec2a7f2e00f2701259",
189
+ "history":[
190
+ {
191
+ "ConfidenceValue":"99",
192
+ "JSONVersion":"1.0.0",
193
+ "Actions":{
194
+ "Verify_ID_Number":"Verified",
195
+ "Return_Personal_Info":"Returned",
196
+ "Human_Review_Update_Selfie":"Not Applicable",
197
+ "Human_Review_Compare":"Not Applicable",
198
+ "Update_Registered_Selfie_On_File":"Not Applicable",
199
+ "Liveness_Check":"Not Applicable",
200
+ "Register_Selfie":"Approved",
201
+ "Human_Review_Liveness_Check":"Not Applicable",
202
+ "Selfie_To_ID_Authority_Compare":"Completed",
203
+ "Selfie_To_ID_Card_Compare":"Not Applicable",
204
+ "Selfie_To_Registered_Selfie_Compare":"Not Applicable"
205
+ },
206
+ "ResultText":"Enroll User",
207
+ "IsFinalResult":"true",
208
+ "IsMachineResult":"true",
209
+ "ResultType":"SAIA",
210
+ "PartnerParams":{
211
+ "job_type":"1",
212
+ "optional_info":"we are one",
213
+ "user_id":"HBBBBBBH57g",
214
+ "job_id":"HBBBBBBHg"
215
+ },
216
+ "Source":"WebAPI",
217
+ "ResultCode":"0810",
218
+ "SmileJobID":"0000001111"
219
+ }
220
+ ],
221
+ "image_links":{
222
+ "selfie_image":"image_link"
223
+ },
224
+ "timestamp":"2019-10-10T12:32:04.622Z"
82
225
  }
83
226
  ```
84
- You can also view your response asynchronously at the callback that you have set, it will look as follows:
227
+
228
+ If you have queried a job type 5, your response be a JSON String that will contain the following:
85
229
  ```
86
230
  {
87
- "ResultCode": "1220",
88
- "ResultText": "Authenticated",
89
- "ResultType": "DIVA",
90
- "SmileJobID": "0000000001",
91
- "JSONVersion": "1.0.0",
92
- "IsFinalResult": "true",
93
- "PartnerParams": {
94
- "job_id": "e7ca3e6c-e527-7165-b0b5-b90db1276378",
95
- "user_id": "07a0c120-98d7-4fdc-bc62-3c6bfd16c60e",
96
- "job_type": 2
97
- },
98
- "ConfidenceValue": "100.000000",
99
- "IsMachineResult": "true"
231
+ "JSONVersion":"1.0.0",
232
+ "SmileJobID":"0000001105",
233
+ "PartnerParams":{
234
+ "user_id":"T6yzdOezucdsPrY0QG9LYNDGOrC",
235
+ "job_id":"FS1kd1dd15JUpd87gTBDapvFxv0",
236
+ "job_type":5
237
+ },
238
+ "ResultType":"ID Verification",
239
+ "ResultText":"ID Number Validated",
240
+ "ResultCode":"1012",
241
+ "IsFinalResult":"true",
242
+ "Actions":{
243
+ "Verify_ID_Number":"Verified",
244
+ "Return_Personal_Info":"Returned"
245
+ },
246
+ "Country":"NG",
247
+ "IDType":"PASSPORT",
248
+ "IDNumber":"A04150107",
249
+ "ExpirationDate":"2017-10-28",
250
+ "FullName":"ADEYEMI KEHINDE ADUNOLA",
251
+ "DOB":"1989-09-20",
252
+ "Photo":"SomeBase64Image",
253
+ "sec_key":"pjxsxEY69zEHjSPFvPEQTqu17vpZbw+zTNqaFxRWpYDiO+7wzKc9zvPU2lRGiKg7rff6nGPBvQ6rA7/wYkcLrlD2SuR2Q8hOcDFgni3PJHutij7j6ThRdpTwJRO2GjLXN5HHDB52NjAvKPyclSDANHrG1qb/tloO7x4bFJ7tKYE=|8faebe00b317654548f8b739dc631431b67d2d4e6ab65c6d53539aaad1600ac7",
254
+ "timestamp":1570698930193
100
255
  }
101
256
  ```
102
257
 
@@ -120,6 +275,127 @@ Please note that if you do not need to pass through options if you will not be u
120
275
  response = connection.get_job_status(partner_params, nil);
121
276
  ```
122
277
 
278
+ **Response**
279
+
280
+ Your response will return a JSON Object below with image_links and history included:
281
+
282
+ ```
283
+ {
284
+ "job_success":true,
285
+ "result":{
286
+ "ConfidenceValue":"99",
287
+ "JSONVersion":"1.0.0",
288
+ "Actions":{
289
+ "Verify_ID_Number":"Verified",
290
+ "Return_Personal_Info":"Returned",
291
+ "Human_Review_Update_Selfie":"Not Applicable",
292
+ "Human_Review_Compare":"Not Applicable",
293
+ "Update_Registered_Selfie_On_File":"Not Applicable",
294
+ "Liveness_Check":"Not Applicable",
295
+ "Register_Selfie":"Approved",
296
+ "Human_Review_Liveness_Check":"Not Applicable",
297
+ "Selfie_To_ID_Authority_Compare":"Completed",
298
+ "Selfie_To_ID_Card_Compare":"Not Applicable",
299
+ "Selfie_To_Registered_Selfie_Compare":"Not Applicable"
300
+ },
301
+ "ResultText":"Enroll User",
302
+ "IsFinalResult":"true",
303
+ "IsMachineResult":"true",
304
+ "ResultType":"SAIA",
305
+ "PartnerParams":{
306
+ "job_type":"1",
307
+ "optional_info":"we are one",
308
+ "user_id":"HBBBBBBH57g",
309
+ "job_id":"HBBBBBBHg"
310
+ },
311
+ "Source":"WebAPI",
312
+ "ResultCode":"0810",
313
+ "SmileJobID":"0000001111"
314
+ },
315
+ "code":"2302",
316
+ "job_complete":true,
317
+ "signature":"HKBhxcv+1qaLy\C7PjVtk257dE=|1577b051a4313ed5e3e4d29893a66f966e31af0a2d2f6bec2a7f2e00f2701259",
318
+ "history":[
319
+ {
320
+ "ConfidenceValue":"99",
321
+ "JSONVersion":"1.0.0",
322
+ "Actions":{
323
+ "Verify_ID_Number":"Verified",
324
+ "Return_Personal_Info":"Returned",
325
+ "Human_Review_Update_Selfie":"Not Applicable",
326
+ "Human_Review_Compare":"Not Applicable",
327
+ "Update_Registered_Selfie_On_File":"Not Applicable",
328
+ "Liveness_Check":"Not Applicable",
329
+ "Register_Selfie":"Approved",
330
+ "Human_Review_Liveness_Check":"Not Applicable",
331
+ "Selfie_To_ID_Authority_Compare":"Completed",
332
+ "Selfie_To_ID_Card_Compare":"Not Applicable",
333
+ "Selfie_To_Registered_Selfie_Compare":"Not Applicable"
334
+ },
335
+ "ResultText":"Enroll User",
336
+ "IsFinalResult":"true",
337
+ "IsMachineResult":"true",
338
+ "ResultType":"SAIA",
339
+ "PartnerParams":{
340
+ "job_type":"1",
341
+ "optional_info":"we are one",
342
+ "user_id":"HBBBBBBH57g",
343
+ "job_id":"HBBBBBBHg"
344
+ },
345
+ "Source":"WebAPI",
346
+ "ResultCode":"0810",
347
+ "SmileJobID":"0000001111"
348
+ }
349
+ ],
350
+ "image_links":{
351
+ "selfie_image":"image_link"
352
+ },
353
+ "timestamp":"2019-10-10T12:32:04.622Z"
354
+ }
355
+ ```
356
+
357
+ #### ID Api Class
358
+
359
+
360
+ ##### submit_job method
361
+ ```
362
+ $ connection = SmileIdentityCore::IDApi.new(partner_id, api_key, sid_server)
363
+
364
+ $ response = connection.submit_job(partner_params, id_info)
365
+ ```
366
+
367
+ **Response**
368
+
369
+ Your response will return a JSON String containing the below:
370
+ ```
371
+ {
372
+ "JSONVersion":"1.0.0",
373
+ "SmileJobID":"0000001105",
374
+ "PartnerParams":{
375
+ "user_id":"T6yzdOezucdsPrY0QG9LYNDGOrC",
376
+ "job_id":"FS1kd1dd15JUpd87gTBDapvFxv0",
377
+ "job_type":5
378
+ },
379
+ "ResultType":"ID Verification",
380
+ "ResultText":"ID Number Validated",
381
+ "ResultCode":"1012",
382
+ "IsFinalResult":"true",
383
+ "Actions":{
384
+ "Verify_ID_Number":"Verified",
385
+ "Return_Personal_Info":"Returned"
386
+ },
387
+ "Country":"NG",
388
+ "IDType":"PASSPORT",
389
+ "IDNumber":"A04150107",
390
+ "ExpirationDate":"2017-10-28",
391
+ "FullName":"ADEYEMI KEHINDE ADUNOLA",
392
+ "DOB":"1989-09-20",
393
+ "Photo":"SomeBase64Image",
394
+ "sec_key":"pjxsxEY69zEHjSPFvPEQTqu17vpZbw+zTNqaFxRWpYDiO+7wzKc9zvPU2lRGiKg7rff6nGPBvQ6rA7/wYkcLrlD2SuR2Q8hOcDFgni3PJHutij7j6ThRdpTwJRO2GjLXN5HHDB52NjAvKPyclSDANHrG1qb/tloO7x4bFJ7tKYE=|8faebe00b317654548f8b739dc631431b67d2d4e6ab65c6d53539aaad1600ac7",
395
+ "timestamp":1570698930193
396
+ }
397
+ ```
398
+
123
399
  #### Signature Class
124
400
 
125
401
  ##### generate_sec_key method
@@ -154,9 +430,7 @@ $ sec_key = connection.confirm_sec_key(sec_key, timestamp)
154
430
 
155
431
  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.
156
432
 
157
- ```java
158
-
159
-
433
+ ```ruby
160
434
  utilities_connection = SmileIdentityCore::Utilities.new('partner_id', 'api_key' , sid_server)
161
435
 
162
436
  utilities_connection.get_job_status('user_id', 'job_id', options)
@@ -1,5 +1,6 @@
1
1
  require "smile-identity-core/version"
2
2
  require "smile-identity-core/web_api.rb"
3
+ require "smile-identity-core/id_api.rb"
3
4
  require "smile-identity-core/signature.rb"
4
5
  require "smile-identity-core/utilities.rb"
5
6
 
@@ -0,0 +1,114 @@
1
+ module SmileIdentityCore
2
+ class IDApi
3
+
4
+ def initialize(partner_id, api_key, sid_server)
5
+ @partner_id = partner_id.to_s
6
+ @api_key = api_key
7
+
8
+ @sid_server = sid_server
9
+ if !(sid_server =~ URI::regexp)
10
+ sid_server_mapping = {
11
+ 0 => 'https://3eydmgh10d.execute-api.us-west-2.amazonaws.com/test',
12
+ 1 => 'https://la7am6gdm8.execute-api.us-west-2.amazonaws.com/prod'
13
+ }
14
+ @url = sid_server_mapping[sid_server.to_i]
15
+ else
16
+ @url = sid_server
17
+ end
18
+ end
19
+
20
+ def submit_job(partner_params, id_info)
21
+ self.partner_params = symbolize_keys partner_params
22
+
23
+ @timestamp = Time.now.to_i
24
+
25
+ self.id_info = symbolize_keys id_info
26
+
27
+ if @partner_params[:job_type].to_i != 5
28
+ raise ArgumentError.new('Please ensure that you are setting your job_type to 5 to query ID Api')
29
+ end
30
+
31
+ return setup_requests
32
+ end
33
+
34
+ def partner_params=(partner_params)
35
+ if partner_params == nil
36
+ raise ArgumentError.new('Please ensure that you send through partner params')
37
+ end
38
+
39
+ if !partner_params.is_a?(Hash)
40
+ raise ArgumentError.new('Partner params needs to be a hash')
41
+ end
42
+
43
+ [:user_id, :job_id, :job_type].each do |key|
44
+ unless partner_params[key] && !partner_params[key].nil? && !(partner_params[key].empty? if partner_params[key].is_a?(String))
45
+ raise ArgumentError.new("Please make sure that #{key.to_s} is included in the partner params")
46
+ end
47
+ end
48
+
49
+ @partner_params = partner_params
50
+ end
51
+
52
+ def id_info=(id_info)
53
+
54
+ updated_id_info = id_info
55
+
56
+ if updated_id_info.nil? || updated_id_info.keys.length == 0
57
+ raise ArgumentError.new("Please make sure that id_info not empty or nil")
58
+ end
59
+
60
+ # maybe do some validation on consistent required fields like id_type and id_number
61
+
62
+ @id_info = updated_id_info
63
+ end
64
+
65
+ private
66
+
67
+ def symbolize_keys params
68
+ (params.is_a?(Hash)) ? Hash[params.map{ |k, v| [k.to_sym, v] }] : params
69
+ end
70
+
71
+ def setup_requests
72
+ url = "#{@url}/id_verification"
73
+
74
+ request = Typhoeus::Request.new(
75
+ url,
76
+ method: 'POST',
77
+ headers: {'Content-Type'=> "application/json"},
78
+ body: configure_json
79
+ )
80
+
81
+ request.on_complete do |response|
82
+ if response.success?
83
+ return response.body
84
+ elsif response.timed_out?
85
+ raise "#{response.code.to_s}: #{response.body}"
86
+ elsif response.code == 0
87
+ # Could not get an http response, something's wrong.
88
+ raise "#{response.code.to_s}: #{response.body}"
89
+ else
90
+ # Received a non-successful http response.
91
+ raise "#{response.code.to_s}: #{response.body}"
92
+ end
93
+ end
94
+ request.run
95
+ end
96
+
97
+ def configure_json
98
+ body = {
99
+ timestamp: @timestamp,
100
+ sec_key: determine_sec_key,
101
+ partner_id: @partner_id,
102
+ partner_params: @partner_params
103
+ }
104
+
105
+ body.merge!(@id_info)
106
+ JSON.generate(body)
107
+ end
108
+
109
+ def determine_sec_key
110
+ @sec_key = SmileIdentityCore::Signature.new(@partner_id, @api_key).generate_sec_key(@timestamp)[:sec_key]
111
+ end
112
+
113
+ end
114
+ end
@@ -1,3 +1,3 @@
1
1
  module SmileIdentityCore
2
- VERSION = "0.2.3"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -28,7 +28,12 @@ module SmileIdentityCore
28
28
  end
29
29
 
30
30
  def submit_job(partner_params, images, id_info, options)
31
+
31
32
  self.partner_params = symbolize_keys partner_params
33
+ if @partner_params[:job_type].to_i == 5
34
+ return SmileIdentityCore::IDApi.new(@partner_id, @api_key, @sid_server).submit_job(partner_params, id_info)
35
+ end
36
+
32
37
  self.images = images
33
38
  @timestamp = Time.now.to_i
34
39
 
@@ -218,7 +223,7 @@ module SmileIdentityCore
218
223
  prep_upload_response = JSON.parse(response.body)
219
224
  info_json = configure_info_json(prep_upload_response)
220
225
 
221
- file_upload_response = upload_file(prep_upload_response['upload_url'], info_json)
226
+ file_upload_response = upload_file(prep_upload_response['upload_url'], info_json, prep_upload_response['smile_job_id'])
222
227
  return file_upload_response
223
228
 
224
229
  elsif response.timed_out?
@@ -311,7 +316,7 @@ module SmileIdentityCore
311
316
  end
312
317
  end
313
318
 
314
- def upload_file(url, info_json)
319
+ def upload_file(url, info_json, smile_job_id)
315
320
 
316
321
  file = zip_up_file(info_json)
317
322
  file.rewind
@@ -329,7 +334,7 @@ module SmileIdentityCore
329
334
  @utilies_connection = SmileIdentityCore::Utilities.new(@partner_id, @api_key, @sid_server)
330
335
  return query_job_status
331
336
  else
332
- return
337
+ return {success: true, smile_job_id: smile_job_id}.to_json
333
338
  end
334
339
  elsif response.timed_out?
335
340
  raise " #{response.code.to_s}: #{response.body}"
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/smileidentity/smile-identity-core-ruby"
19
- spec.metadata["documentation_uri"] = "https://docs-smileid.herokuapp.com/docs#web-api-introduction"
19
+ spec.metadata["documentation_uri"] = "https://docs.smileidentity.com"
20
20
  spec.metadata["changelog_uri"] = "https://github.com/smileidentity/smile-identity-core/blob/master/CHANGELOG.md"
21
21
 
22
22
  # Specify which files should be added to the gem when it is released.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smile-identity-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ridhwana
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-17 00:00:00.000000000 Z
11
+ date: 2019-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -124,6 +124,7 @@ files:
124
124
  - bin/console
125
125
  - bin/setup
126
126
  - lib/smile-identity-core.rb
127
+ - lib/smile-identity-core/id_api.rb
127
128
  - lib/smile-identity-core/signature.rb
128
129
  - lib/smile-identity-core/utilities.rb
129
130
  - lib/smile-identity-core/version.rb
@@ -136,7 +137,7 @@ licenses:
136
137
  metadata:
137
138
  homepage_uri: https://www.smileidentity.com/
138
139
  source_code_uri: https://github.com/smileidentity/smile-identity-core-ruby
139
- documentation_uri: https://docs-smileid.herokuapp.com/docs#web-api-introduction
140
+ documentation_uri: https://docs.smileidentity.com
140
141
  changelog_uri: https://github.com/smileidentity/smile-identity-core/blob/master/CHANGELOG.md
141
142
  post_install_message:
142
143
  rdoc_options: []