smile-identity-core 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +1 -1
- data/README.md +94 -26
- data/lib/smile-identity-core/signature.rb +27 -9
- data/lib/smile-identity-core/utilities.rb +83 -0
- data/lib/smile-identity-core/version.rb +1 -1
- data/lib/smile-identity-core/web_api.rb +78 -62
- data/lib/smile-identity-core.rb +1 -0
- metadata +3 -3
- data/smile-identity-core-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 242bd9cb947cb4734124d9c281ddf07911b0d8c7a2fe6fdd908546934c1a0dca
|
4
|
+
data.tar.gz: a411c7cf697a15cc5a5c4c618a50795f8c24d1057126e599e82ceb98795cbecd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeed377d63e6655d1c4659a0b26a49c633f8ec03e8c1204fdf2553cb1618135ffa09b9ae55923bd291c2674257ec9ba85fb41f2769297ef7703bcce78b5a14a3
|
7
|
+
data.tar.gz: ff670ae6913b44a02b394c264aa5aa9a01215162da762827978774f92f10de736b424be6739145939eca26d1173fd90acd55acc67b714ab75496a23e01628a15
|
data/CHANGELOG.md
CHANGED
@@ -13,3 +13,14 @@ Some package configurations were added.
|
|
13
13
|
### Added
|
14
14
|
Removed two parameters: optional_callback and return_job_status in the submit_job function in favour of an options hash.
|
15
15
|
Introduced return_history and image_links
|
16
|
+
|
17
|
+
## [0.2.1] - 2019-09-05
|
18
|
+
### Updated
|
19
|
+
Updates to the readme
|
20
|
+
Update some error messages
|
21
|
+
Use the signature class in the Web API class
|
22
|
+
Accept more formats as inputs
|
23
|
+
Fix the loss of optional_callback
|
24
|
+
Ensure that we allow nil inputs or empty hashes for options and id_info
|
25
|
+
Confirm the signature when querying the job status
|
26
|
+
Add a Utilities class with get_job_status that we use internally to expose a public get_job_status method on WebApi
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,24 +1,34 @@
|
|
1
1
|
# SmileIdentityCore
|
2
2
|
|
3
|
-
The official Smile Identity gem exposes two classes namely, the Web API and
|
3
|
+
The official Smile Identity gem exposes two classes namely, the Web API and Signature class.
|
4
4
|
|
5
|
-
The Web API allows you as the Partner to validate a user’s identity against the relevant Identity Authorities/Third Party databases that Smile Identity has access to using ID information provided by your customer/user (including photo for compare).
|
5
|
+
The **Web API Class** allows you as the Partner to validate a user’s identity against the relevant Identity Authorities/Third Party databases that Smile Identity has access to using ID information provided by your customer/user (including photo for compare). It has the following public methods:
|
6
|
+
- submit_job
|
7
|
+
- get_job_status
|
6
8
|
|
7
|
-
The Signature
|
9
|
+
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
|
+
- generate_sec_key
|
11
|
+
- confirm_sec_key
|
12
|
+
|
13
|
+
<!-- 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:
|
14
|
+
- get_job_status -->
|
8
15
|
|
9
16
|
## Documentation
|
10
17
|
|
11
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).
|
12
19
|
|
13
|
-
Please note that you will have to be a Smile Identity Partner to be able to query our services.
|
14
|
-
|
20
|
+
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
|
+
|
22
|
+
## Installation
|
23
|
+
|
24
|
+
View the package on [Rubygems](https://rubygems.org/gems/smile-identity-core).
|
15
25
|
|
16
26
|
Add this line to your application's Gemfile:
|
17
27
|
|
18
28
|
```ruby
|
19
29
|
gem 'smile-identity-core'
|
20
30
|
```
|
21
|
-
and
|
31
|
+
and require the package:
|
22
32
|
|
23
33
|
```ruby
|
24
34
|
require 'smile-identity-core'
|
@@ -30,30 +40,20 @@ Or install it to your system as:
|
|
30
40
|
$ gem install smile-identity-core
|
31
41
|
```
|
32
42
|
|
33
|
-
|
34
|
-
|
35
|
-
```
|
36
|
-
$ connection = SmileIdentityCore::AuthSmile.new(partner_id, api_key)
|
43
|
+
You now may use the classes as follows:
|
37
44
|
|
38
|
-
|
39
|
-
where timestamp is optional
|
45
|
+
#### Web Api Class
|
40
46
|
|
47
|
+
##### submit_job method
|
41
48
|
```
|
49
|
+
$ connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
|
42
50
|
|
43
|
-
|
44
|
-
|
45
|
-
```
|
46
|
-
{
|
47
|
-
:sec_key=> "<the generated sec key>",
|
48
|
-
:timestamp=> 1563283420
|
49
|
-
}
|
51
|
+
$ response = connection.submit_job(partner_params, images, id_info, options)
|
50
52
|
```
|
51
53
|
|
52
|
-
|
54
|
+
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:
|
53
55
|
```
|
54
|
-
|
55
|
-
|
56
|
-
$ response = connection.submit_job(partner_params, images, optional_callback, return_job_status)
|
56
|
+
String response = connection.submit_job(partner_params, images, nil, nil);
|
57
57
|
```
|
58
58
|
|
59
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:
|
@@ -100,13 +100,81 @@ You can also view your response asynchronously at the callback that you have set
|
|
100
100
|
}
|
101
101
|
```
|
102
102
|
|
103
|
+
##### get_job_status method
|
104
|
+
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:
|
105
|
+
|
106
|
+
You will already have your Web Api class initialised as follows:
|
107
|
+
```ruby
|
108
|
+
connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
|
109
|
+
```
|
110
|
+
|
111
|
+
Thereafter, simply call get_job_status with the correct parameters:
|
112
|
+
```ruby
|
113
|
+
response = connection.get_job_status(partner_params, options)
|
114
|
+
|
115
|
+
where options is {return_history: true | false, return_image_links: true | false}
|
116
|
+
```
|
117
|
+
|
118
|
+
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:
|
119
|
+
```ruby
|
120
|
+
response = connection.get_job_status(partner_params, nil);
|
121
|
+
```
|
122
|
+
|
123
|
+
#### Signature Class
|
124
|
+
|
125
|
+
##### generate_sec_key method
|
126
|
+
|
127
|
+
```
|
128
|
+
$ connection = SmileIdentityCore::Signature.new(partner_id, api_key)
|
129
|
+
|
130
|
+
$ sec_key = connection.generate_sec_key(timestamp)
|
131
|
+
where timestamp is optional
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
The response will be a hash:
|
136
|
+
|
137
|
+
```
|
138
|
+
{
|
139
|
+
:sec_key=> "<the generated sec key>",
|
140
|
+
:timestamp=> 1563283420
|
141
|
+
}
|
142
|
+
```
|
143
|
+
|
144
|
+
##### confirm_sec_key method
|
145
|
+
|
146
|
+
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:
|
147
|
+
|
148
|
+
```ruby
|
149
|
+
$ connection = SmileIdentityCore::Signature.new(partner_id, api_key)
|
150
|
+
$ sec_key = connection.confirm_sec_key(sec_key, timestamp)
|
151
|
+
```
|
152
|
+
|
153
|
+
<!-- #### Utilities Class
|
154
|
+
|
155
|
+
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
|
+
|
157
|
+
```java
|
158
|
+
|
159
|
+
|
160
|
+
utilities_connection = SmileIdentityCore::Utilities.new('partner_id', 'api_key' , sid_server)
|
161
|
+
|
162
|
+
utilities_connection.get_job_status('user_id', 'job_id', options)
|
163
|
+
where options is {return_history: true | false, return_image_links: true | false}
|
164
|
+
``` -->
|
165
|
+
|
103
166
|
## Development
|
104
167
|
|
105
|
-
After checking out the repo, run `
|
168
|
+
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.
|
169
|
+
|
170
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
106
171
|
|
107
|
-
To
|
172
|
+
To release a new version:
|
173
|
+
- Update the version number in `version.rb`
|
174
|
+
- Run `gem build smile-identity-core.gemspec`
|
175
|
+
- Thereafter `gem push smile-identity-core-version.gem`.
|
108
176
|
|
109
|
-
|
177
|
+
Make sure to git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
110
178
|
|
111
179
|
## Contributing
|
112
180
|
|
@@ -7,16 +7,34 @@ module SmileIdentityCore
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def generate_sec_key(timestamp=Time.now.to_i)
|
10
|
-
|
10
|
+
begin
|
11
|
+
@timestamp = timestamp
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
hash_signature = Digest::SHA256.hexdigest([@partner_id, @timestamp].join(":"))
|
14
|
+
public_key = OpenSSL::PKey::RSA.new(Base64.strict_decode64(@api_key))
|
15
|
+
@sec_key = [Base64.strict_encode64(public_key.public_encrypt(hash_signature)), hash_signature].join('|')
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
return {
|
18
|
+
sec_key: @sec_key,
|
19
|
+
timestamp: @timestamp
|
20
|
+
}
|
21
|
+
rescue => e
|
22
|
+
raise e
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def confirm_sec_key(timestamp, sec_key)
|
27
|
+
begin
|
28
|
+
hash_signature = Digest::SHA256.hexdigest([@partner_id, timestamp].join(":"))
|
29
|
+
encrypted = sec_key.split('|')[0]
|
30
|
+
|
31
|
+
public_key = OpenSSL::PKey::RSA.new(Base64.strict_decode64(@api_key))
|
32
|
+
decrypted = public_key.public_decrypt(Base64.strict_decode64(encrypted))
|
33
|
+
|
34
|
+
return decrypted == hash_signature
|
35
|
+
rescue => e
|
36
|
+
raise e
|
37
|
+
end
|
38
|
+
end
|
21
39
|
end
|
22
40
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module SmileIdentityCore
|
2
|
+
class Utilities
|
3
|
+
|
4
|
+
def initialize(partner_id, api_key, sid_server)
|
5
|
+
@partner_id = partner_id.to_s
|
6
|
+
@api_key = api_key
|
7
|
+
|
8
|
+
if !(sid_server =~ URI::regexp)
|
9
|
+
sid_server_mapping = {
|
10
|
+
0 => 'https://3eydmgh10d.execute-api.us-west-2.amazonaws.com/test',
|
11
|
+
1 => 'https://la7am6gdm8.execute-api.us-west-2.amazonaws.com/prod'
|
12
|
+
}
|
13
|
+
@url = sid_server_mapping[sid_server.to_i]
|
14
|
+
else
|
15
|
+
@url = sid_server
|
16
|
+
end
|
17
|
+
|
18
|
+
@signature_connection = SmileIdentityCore::Signature.new(@partner_id, @api_key)
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_job_status(user_id, job_id, options = {})
|
23
|
+
|
24
|
+
if(options.nil? || options.empty?)
|
25
|
+
options = {
|
26
|
+
return_history: false,
|
27
|
+
return_job_status: false
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
@timestamp = Time.now.to_i
|
32
|
+
return query_job_status(user_id, job_id, symbolize_keys(options))
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def symbolize_keys params
|
38
|
+
(params.is_a?(Hash)) ? Hash[params.map{ |k, v| [k.to_sym, v] }] : params
|
39
|
+
end
|
40
|
+
|
41
|
+
def query_job_status(user_id, job_id, options)
|
42
|
+
url = "#{@url}/job_status"
|
43
|
+
|
44
|
+
request = Typhoeus::Request.new(
|
45
|
+
url,
|
46
|
+
headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
|
47
|
+
method: :post,
|
48
|
+
body: configure_job_query(user_id, job_id, options)
|
49
|
+
)
|
50
|
+
|
51
|
+
request.on_complete do |response|
|
52
|
+
begin
|
53
|
+
body = JSON.parse(response.body)
|
54
|
+
|
55
|
+
valid = @signature_connection.confirm_sec_key(body['timestamp'], body['signature'])
|
56
|
+
|
57
|
+
if(!valid)
|
58
|
+
raise "Unable to confirm validity of the job_status response"
|
59
|
+
end
|
60
|
+
|
61
|
+
return body
|
62
|
+
rescue => e
|
63
|
+
raise e
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
request.run
|
68
|
+
end
|
69
|
+
|
70
|
+
def configure_job_query(user_id, job_id, options)
|
71
|
+
return {
|
72
|
+
sec_key: @signature_connection.generate_sec_key(@timestamp)[:sec_key],
|
73
|
+
timestamp: @timestamp,
|
74
|
+
user_id: user_id,
|
75
|
+
job_id: job_id,
|
76
|
+
partner_id: @partner_id,
|
77
|
+
image_links: options[:return_image_links] || false,
|
78
|
+
history: options[:return_history] || false
|
79
|
+
}.to_json
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
@@ -15,6 +15,7 @@ module SmileIdentityCore
|
|
15
15
|
@callback_url = default_callback
|
16
16
|
@api_key = api_key
|
17
17
|
|
18
|
+
@sid_server = sid_server
|
18
19
|
if !(sid_server =~ URI::regexp)
|
19
20
|
sid_server_mapping = {
|
20
21
|
0 => 'https://3eydmgh10d.execute-api.us-west-2.amazonaws.com/test',
|
@@ -24,22 +25,21 @@ module SmileIdentityCore
|
|
24
25
|
else
|
25
26
|
@url = sid_server
|
26
27
|
end
|
27
|
-
|
28
28
|
end
|
29
29
|
|
30
30
|
def submit_job(partner_params, images, id_info, options)
|
31
|
-
self.partner_params = partner_params
|
31
|
+
self.partner_params = symbolize_keys partner_params
|
32
32
|
self.images = images
|
33
33
|
@timestamp = Time.now.to_i
|
34
34
|
|
35
|
-
self.id_info = id_info
|
36
|
-
self.options = options
|
35
|
+
self.id_info = symbolize_keys id_info
|
36
|
+
self.options = symbolize_keys options
|
37
37
|
|
38
|
-
if options[:optional_callback] && options[:optional_callback].length > 0
|
39
|
-
@callback_url = options[:optional_callback]
|
38
|
+
if @options[:optional_callback] && @options[:optional_callback].length > 0
|
39
|
+
@callback_url = @options[:optional_callback]
|
40
40
|
end
|
41
41
|
|
42
|
-
if partner_params[:job_type].to_i == 1
|
42
|
+
if @partner_params[:job_type].to_i == 1
|
43
43
|
validate_enroll_with_id
|
44
44
|
end
|
45
45
|
|
@@ -48,13 +48,24 @@ module SmileIdentityCore
|
|
48
48
|
return setup_requests
|
49
49
|
end
|
50
50
|
|
51
|
+
def get_job_status(partner_params, options)
|
52
|
+
partner_params = symbolize_keys partner_params
|
53
|
+
@timestamp = Time.now.to_i
|
54
|
+
|
55
|
+
user_id = partner_params[:user_id]
|
56
|
+
job_id = partner_params[:job_id]
|
57
|
+
|
58
|
+
utilities = SmileIdentityCore::Utilities.new(@partner_id, @api_key, @sid_server)
|
59
|
+
return utilities.get_job_status(user_id, job_id, options);
|
60
|
+
end
|
61
|
+
|
51
62
|
def partner_params=(partner_params)
|
52
63
|
if partner_params == nil
|
53
64
|
raise ArgumentError.new('Please ensure that you send through partner params')
|
54
65
|
end
|
55
66
|
|
56
67
|
if !partner_params.is_a?(Hash)
|
57
|
-
raise ArgumentError.new('Partner params needs to be
|
68
|
+
raise ArgumentError.new('Partner params needs to be a hash')
|
58
69
|
end
|
59
70
|
|
60
71
|
[:user_id, :job_id, :job_type].each do |key|
|
@@ -80,11 +91,28 @@ module SmileIdentityCore
|
|
80
91
|
raise ArgumentError.new('You need to send through at least one selfie image')
|
81
92
|
end
|
82
93
|
|
83
|
-
@images = images
|
94
|
+
@images = images.map { |image| symbolize_keys image }
|
84
95
|
end
|
85
96
|
|
86
97
|
def id_info=(id_info)
|
87
|
-
|
98
|
+
|
99
|
+
updated_id_info = id_info
|
100
|
+
|
101
|
+
if updated_id_info.nil?
|
102
|
+
updated_id_info = {}
|
103
|
+
end
|
104
|
+
|
105
|
+
# if it doesnt exist, set it false
|
106
|
+
if(!updated_id_info.key?(:entered) || id_info[:entered].empty?)
|
107
|
+
updated_id_info[:entered] = "false"
|
108
|
+
end
|
109
|
+
|
110
|
+
# if it's a boolean
|
111
|
+
if(!!updated_id_info[:entered] == updated_id_info[:entered])
|
112
|
+
updated_id_info[:entered] = id_info[:entered].to_s
|
113
|
+
end
|
114
|
+
|
115
|
+
if updated_id_info[:entered] && updated_id_info[:entered] == 'true'
|
88
116
|
[:first_name, :last_name, :country, :id_type, :id_number].each do |key|
|
89
117
|
unless id_info[key] && !id_info[key].nil? && !id_info[key].empty?
|
90
118
|
raise ArgumentError.new("Please make sure that #{key.to_s} is included in the id_info")
|
@@ -92,14 +120,25 @@ module SmileIdentityCore
|
|
92
120
|
end
|
93
121
|
end
|
94
122
|
|
95
|
-
|
123
|
+
if updated_id_info[:country] && updated_id_info[:country].upcase == 'NG' && ['PASSPORT', 'VOTER_ID', 'DRIVERS_LICENSE', 'NATIONAL_ID', 'TIN', 'CAC'].include?(updated_id_info[:id_type].upcase) && (!updated_id_info[:dob] || updated_id_info[:dob].empty? || updated_id_info[:dob].nil?)
|
124
|
+
raise ArgumentError.new("The ID type #{updated_id_info[:id_type]} for #{updated_id_info[:country]} requires a valid dob paramater.")
|
125
|
+
end
|
126
|
+
|
127
|
+
@id_info = updated_id_info
|
96
128
|
end
|
97
129
|
|
98
130
|
def options=(options)
|
99
|
-
updated_options =
|
131
|
+
updated_options = options
|
132
|
+
|
133
|
+
if updated_options.nil?
|
134
|
+
updated_options = {}
|
135
|
+
end
|
136
|
+
|
100
137
|
[:optional_callback, :return_job_status, :return_image_links, :return_history].map do |key|
|
101
138
|
if key != :optional_callback
|
102
|
-
updated_options[key] = check_boolean(key, options
|
139
|
+
updated_options[key] = check_boolean(key, options)
|
140
|
+
else
|
141
|
+
updated_options[key] = check_string(key, options)
|
103
142
|
end
|
104
143
|
end
|
105
144
|
|
@@ -108,6 +147,10 @@ module SmileIdentityCore
|
|
108
147
|
|
109
148
|
private
|
110
149
|
|
150
|
+
def symbolize_keys params
|
151
|
+
(params.is_a?(Hash)) ? Hash[params.map{ |k, v| [k.to_sym, v] }] : params
|
152
|
+
end
|
153
|
+
|
111
154
|
def validate_return_data
|
112
155
|
if (!@callback_url || @callback_url.empty?) && !@options[:return_job_status]
|
113
156
|
raise ArgumentError.new("Please choose to either get your response via the callback or job status query")
|
@@ -120,26 +163,33 @@ module SmileIdentityCore
|
|
120
163
|
end
|
121
164
|
end
|
122
165
|
|
123
|
-
def check_boolean(key,
|
124
|
-
if (!
|
125
|
-
|
166
|
+
def check_boolean(key, obj)
|
167
|
+
if (!obj || !obj[key])
|
168
|
+
return false
|
126
169
|
end
|
127
170
|
|
128
|
-
if !!
|
171
|
+
if !!obj[key] != obj[key]
|
129
172
|
raise ArgumentError.new("#{key} needs to be a boolean")
|
130
173
|
end
|
131
174
|
|
132
|
-
return
|
175
|
+
return obj[key]
|
176
|
+
end
|
177
|
+
|
178
|
+
def check_string(key, obj)
|
179
|
+
if (!obj || !obj[key])
|
180
|
+
return ''
|
181
|
+
else
|
182
|
+
return obj[key]
|
183
|
+
end
|
133
184
|
end
|
134
185
|
|
135
186
|
def determine_sec_key
|
136
|
-
|
137
|
-
public_key = OpenSSL::PKey::RSA.new(Base64.decode64(@api_key))
|
138
|
-
@sec_key = [Base64.encode64(public_key.public_encrypt(hash_signature)), hash_signature].join('|')
|
187
|
+
@sec_key = SmileIdentityCore::Signature.new(@partner_id, @api_key).generate_sec_key(@timestamp)[:sec_key]
|
139
188
|
end
|
140
189
|
|
141
190
|
def configure_prep_upload_json
|
142
|
-
|
191
|
+
|
192
|
+
body = {
|
143
193
|
file_name: 'selfie.zip',
|
144
194
|
timestamp: @timestamp,
|
145
195
|
sec_key: determine_sec_key,
|
@@ -182,7 +232,6 @@ module SmileIdentityCore
|
|
182
232
|
end
|
183
233
|
end
|
184
234
|
request.run
|
185
|
-
|
186
235
|
end
|
187
236
|
|
188
237
|
def configure_info_json(server_information)
|
@@ -276,6 +325,7 @@ module SmileIdentityCore
|
|
276
325
|
request.on_complete do |response|
|
277
326
|
if response.success?
|
278
327
|
if @options[:return_job_status]
|
328
|
+
@utilies_connection = SmileIdentityCore::Utilities.new(@partner_id, @api_key, @sid_server)
|
279
329
|
return query_job_status
|
280
330
|
else
|
281
331
|
return
|
@@ -295,51 +345,17 @@ module SmileIdentityCore
|
|
295
345
|
end
|
296
346
|
|
297
347
|
def query_job_status(counter=0)
|
298
|
-
job_complete = false
|
299
348
|
counter < 4 ? (sleep 2) : (sleep 6)
|
300
349
|
counter += 1
|
301
350
|
|
302
|
-
|
303
|
-
sec_key: @sec_key,
|
304
|
-
timestamp: @timestamp,
|
305
|
-
user_id: @partner_params[:user_id],
|
306
|
-
job_id: @partner_params[:job_id],
|
307
|
-
partner_id: @partner_id,
|
308
|
-
image_links: @options[:return_image_links],
|
309
|
-
history: @options[:return_history]
|
310
|
-
}.to_json
|
311
|
-
|
312
|
-
url = "#{@url}/job_status"
|
351
|
+
response = @utilies_connection.get_job_status(@partner_params[:user_id], @partner_params[:job_id], @options)
|
313
352
|
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
body: body
|
319
|
-
)
|
320
|
-
|
321
|
-
request.on_complete do |response|
|
322
|
-
|
323
|
-
if response.code == 0
|
324
|
-
return query_job_status(counter)
|
325
|
-
else
|
326
|
-
begin
|
327
|
-
status_body = JSON.load(response.body)
|
328
|
-
job_complete = status_body['job_complete'].to_s
|
329
|
-
rescue => e
|
330
|
-
puts e.message
|
331
|
-
puts e.backtrace
|
332
|
-
end
|
333
|
-
|
334
|
-
if job_complete == 'true' || counter == 20
|
335
|
-
return JSON.parse(response.body)
|
336
|
-
else
|
337
|
-
return query_job_status(counter)
|
338
|
-
end
|
339
|
-
end
|
353
|
+
if response && (response['job_complete'] == true || counter == 20)
|
354
|
+
return response
|
355
|
+
else
|
356
|
+
return query_job_status(counter)
|
340
357
|
end
|
341
358
|
|
342
|
-
request.run
|
343
359
|
end
|
344
360
|
end
|
345
361
|
end
|
data/lib/smile-identity-core.rb
CHANGED
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.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ridhwana
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -125,9 +125,9 @@ files:
|
|
125
125
|
- bin/setup
|
126
126
|
- lib/smile-identity-core.rb
|
127
127
|
- lib/smile-identity-core/signature.rb
|
128
|
+
- lib/smile-identity-core/utilities.rb
|
128
129
|
- lib/smile-identity-core/version.rb
|
129
130
|
- lib/smile-identity-core/web_api.rb
|
130
|
-
- smile-identity-core-0.1.0.gem
|
131
131
|
- smile-identity-core.gemspec
|
132
132
|
- travis.yml
|
133
133
|
homepage: https://www.smileidentity.com/
|
Binary file
|