smile-identity-core 0.1.0
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 +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +51 -0
- data/README.md +107 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/smile-identity-core/signature.rb +22 -0
- data/lib/smile-identity-core/version.rb +3 -0
- data/lib/smile-identity-core/web_api.rb +333 -0
- data/lib/smile-identity-core.rb +7 -0
- data/smile-identity-core.gemspec +38 -0
- metadata +159 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bda3379b4814443893498daad4c1ebcc02f3b2163be29f442d28e318d5e394a9
|
4
|
+
data.tar.gz: '039561ebc2b625a064fa40f5907448f986df7d8055072a73dcbd54da8cba9a73'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c105ee36a4d54af7889fd7c039d33211eaf842fe35c0effb0d32885bc00abc4c527a03742f4d999605565ad038b1a4f9dba815b9df55db3871529912151db7b7
|
7
|
+
data.tar.gz: e0a68caee85a1b89891c18816d02410349d289fb69a134272528fca30a10d1ba8c6e71ad7497d9ae39789bc136e9eee9e6ac5a6b829391b903a4ba206fc73405
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
smile-identity-core (0.1.0)
|
5
|
+
rubyzip (~> 1.2, >= 1.2.3)
|
6
|
+
typhoeus (~> 1.0, >= 1.0.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
diff-lcs (1.3)
|
12
|
+
docile (1.1.5)
|
13
|
+
ethon (0.12.0)
|
14
|
+
ffi (>= 1.3.0)
|
15
|
+
ffi (1.11.1)
|
16
|
+
json (2.2.0)
|
17
|
+
rake (10.5.0)
|
18
|
+
rspec (3.8.0)
|
19
|
+
rspec-core (~> 3.8.0)
|
20
|
+
rspec-expectations (~> 3.8.0)
|
21
|
+
rspec-mocks (~> 3.8.0)
|
22
|
+
rspec-core (3.8.1)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-expectations (3.8.4)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-mocks (3.8.1)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.8.0)
|
30
|
+
rspec-support (3.8.2)
|
31
|
+
rubyzip (1.2.3)
|
32
|
+
simplecov (0.12.0)
|
33
|
+
docile (~> 1.1.0)
|
34
|
+
json (>= 1.8, < 3)
|
35
|
+
simplecov-html (~> 0.10.0)
|
36
|
+
simplecov-html (0.10.2)
|
37
|
+
typhoeus (1.3.1)
|
38
|
+
ethon (>= 0.9.0)
|
39
|
+
|
40
|
+
PLATFORMS
|
41
|
+
ruby
|
42
|
+
|
43
|
+
DEPENDENCIES
|
44
|
+
bundler (~> 2.0)
|
45
|
+
rake (~> 10.0)
|
46
|
+
rspec (~> 3.0)
|
47
|
+
simplecov (~> 0.12.0)
|
48
|
+
smile-identity-core!
|
49
|
+
|
50
|
+
BUNDLED WITH
|
51
|
+
2.0.2
|
data/README.md
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# SmileIdentityCore
|
2
|
+
|
3
|
+
The official Smile Identity gem exposes two classes namely, the Web API and AuthSmile class.
|
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).
|
6
|
+
|
7
|
+
The Auth Smile class allows you as the Partner to generate a sec key to interact with our servers.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'smile-identity-core'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install smile-identity-core
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
|
28
|
+
#### Calculating your Signature
|
29
|
+
```
|
30
|
+
$ connection = SmileIdentityCore::AuthSmile.new(partner_id, api_key)
|
31
|
+
|
32
|
+
$ sec_key = connection.generate_sec_key(timestamp)
|
33
|
+
where timestamp is optional
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
The response will be a hash:
|
38
|
+
|
39
|
+
```
|
40
|
+
{
|
41
|
+
:sec_key=> "<the generated sec key>",
|
42
|
+
:timestamp=> 1563283420
|
43
|
+
}
|
44
|
+
```
|
45
|
+
|
46
|
+
#### Web api
|
47
|
+
```
|
48
|
+
$ connection = SmileIdentityCore::WebApi.new(partner_id, default_callback, api_key, sid_server)
|
49
|
+
|
50
|
+
$ response = connection.submit_job(partner_params, images, optional_callback, return_job_status)
|
51
|
+
```
|
52
|
+
|
53
|
+
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:
|
54
|
+
|
55
|
+
```
|
56
|
+
{
|
57
|
+
"timestamp": "2018-03-13T21:04:11.193Z",
|
58
|
+
"signature": "<your signature>",
|
59
|
+
"job_complete": true,
|
60
|
+
"job_success": true,
|
61
|
+
"result": {
|
62
|
+
"ResultText": "Enroll User",
|
63
|
+
"ResultType": "SAIA",
|
64
|
+
"SmileJobID": "0000001897",
|
65
|
+
"JSONVersion": "1.0.0",
|
66
|
+
"IsFinalResult": "true",
|
67
|
+
"PartnerParams": {
|
68
|
+
"job_id": "52d0de86-be3b-4219-9e96-8195b0018944",
|
69
|
+
"user_id": "e54e0e98-8b8c-4215-89f5-7f9ea42bf650",
|
70
|
+
"job_type": 4
|
71
|
+
},
|
72
|
+
"ConfidenceValue": "100",
|
73
|
+
"IsMachineResult": "true",
|
74
|
+
}
|
75
|
+
"code": "2302"
|
76
|
+
}
|
77
|
+
```
|
78
|
+
You can also view your response asynchronously at the callback that you have set, it will look as follows:
|
79
|
+
```
|
80
|
+
{
|
81
|
+
"ResultCode": "1220",
|
82
|
+
"ResultText": "Authenticated",
|
83
|
+
"ResultType": "DIVA",
|
84
|
+
"SmileJobID": "0000000001",
|
85
|
+
"JSONVersion": "1.0.0",
|
86
|
+
"IsFinalResult": "true",
|
87
|
+
"PartnerParams": {
|
88
|
+
"job_id": "e7ca3e6c-e527-7165-b0b5-b90db1276378",
|
89
|
+
"user_id": "07a0c120-98d7-4fdc-bc62-3c6bfd16c60e",
|
90
|
+
"job_type": 2
|
91
|
+
},
|
92
|
+
"ConfidenceValue": "100.000000",
|
93
|
+
"IsMachineResult": "true"
|
94
|
+
}
|
95
|
+
```
|
96
|
+
|
97
|
+
## Development
|
98
|
+
|
99
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
100
|
+
|
101
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
102
|
+
|
103
|
+
Please note that you should tag the release when doing a push to rubygems.
|
104
|
+
|
105
|
+
## Contributing
|
106
|
+
|
107
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/smileidentity/smile-identity-core
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "smile-identity-core"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module SmileIdentityCore
|
2
|
+
class Signature
|
3
|
+
|
4
|
+
def initialize(partner_id, api_key)
|
5
|
+
@api_key = api_key
|
6
|
+
@partner_id = partner_id.to_i
|
7
|
+
end
|
8
|
+
|
9
|
+
def generate_sec_key(timestamp=Time.now.to_i)
|
10
|
+
@timestamp = timestamp
|
11
|
+
|
12
|
+
hash_signature = Digest::SHA256.hexdigest([@partner_id, @timestamp].join(":"))
|
13
|
+
public_key = OpenSSL::PKey::RSA.new(Base64.strict_decode64(@api_key))
|
14
|
+
@sec_key = [Base64.strict_encode64(public_key.public_encrypt(hash_signature)), hash_signature].join('|')
|
15
|
+
|
16
|
+
return {
|
17
|
+
sec_key: @sec_key,
|
18
|
+
timestamp: @timestamp
|
19
|
+
}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,333 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'base64'
|
4
|
+
require 'openssl'
|
5
|
+
require 'uri'
|
6
|
+
|
7
|
+
require 'typhoeus'
|
8
|
+
require 'zip'
|
9
|
+
|
10
|
+
module SmileIdentityCore
|
11
|
+
class WebApi
|
12
|
+
|
13
|
+
def initialize(partner_id, default_callback, api_key, sid_server)
|
14
|
+
@partner_id = partner_id.to_s
|
15
|
+
@callback_url = default_callback
|
16
|
+
@api_key = api_key
|
17
|
+
|
18
|
+
if !(sid_server =~ URI::regexp)
|
19
|
+
sid_server_mapping = {
|
20
|
+
0 => 'https://3eydmgh10d.execute-api.us-west-2.amazonaws.com/test',
|
21
|
+
1 => 'https://la7am6gdm8.execute-api.us-west-2.amazonaws.com/prod'
|
22
|
+
}
|
23
|
+
@url = sid_server_mapping[sid_server.to_i]
|
24
|
+
else
|
25
|
+
@url = sid_server
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def submit_job(partner_params, images, id_info, optional_callback, return_job_status)
|
31
|
+
self.partner_params = partner_params
|
32
|
+
self.images = images
|
33
|
+
@timestamp = Time.now.to_i
|
34
|
+
|
35
|
+
self.id_info = id_info
|
36
|
+
self.return_job_status = return_job_status
|
37
|
+
|
38
|
+
if !optional_callback.empty?
|
39
|
+
@callback_url = optional_callback
|
40
|
+
end
|
41
|
+
|
42
|
+
if partner_params[:job_type].to_i == 1
|
43
|
+
validate_enroll_with_id
|
44
|
+
end
|
45
|
+
|
46
|
+
validate_return_data
|
47
|
+
|
48
|
+
return setup_requests
|
49
|
+
end
|
50
|
+
|
51
|
+
def partner_params=(partner_params)
|
52
|
+
if partner_params == nil
|
53
|
+
raise ArgumentError.new('Please ensure that you send through partner params')
|
54
|
+
end
|
55
|
+
|
56
|
+
if !partner_params.is_a?(Hash)
|
57
|
+
raise ArgumentError.new('Partner params needs to be an object')
|
58
|
+
end
|
59
|
+
|
60
|
+
[:user_id, :job_id, :job_type].each do |key|
|
61
|
+
unless partner_params[key] && !partner_params[key].nil? && !(partner_params[key].empty? if partner_params[key].is_a?(String))
|
62
|
+
raise ArgumentError.new("Please make sure that #{key.to_s} is included in the partner params")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
@partner_params = partner_params
|
67
|
+
end
|
68
|
+
|
69
|
+
def images=(images)
|
70
|
+
if images == nil
|
71
|
+
raise ArgumentError.new('Please ensure that you send through image details')
|
72
|
+
end
|
73
|
+
|
74
|
+
if !images.is_a?(Array)
|
75
|
+
raise ArgumentError.new('Image details needs to be an array')
|
76
|
+
end
|
77
|
+
|
78
|
+
# all job types require atleast a selfie
|
79
|
+
if images.length == 0 || images.none? {|h| h[:image_type_id] == 0 || h[:image_type_id] == 2 }
|
80
|
+
raise ArgumentError.new('You need to send through at least one selfie image')
|
81
|
+
end
|
82
|
+
|
83
|
+
@images = images
|
84
|
+
end
|
85
|
+
|
86
|
+
def id_info=(id_info)
|
87
|
+
if id_info[:entered] == 'true'
|
88
|
+
[:first_name, :last_name, :country, :id_type, :id_number].each do |key|
|
89
|
+
unless id_info[key] && !id_info[key].nil? && !id_info[key].empty?
|
90
|
+
raise ArgumentError.new("Please make sure that #{key.to_s} is included in the id_info")
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
@id_info = id_info
|
96
|
+
end
|
97
|
+
|
98
|
+
def return_job_status=(return_job_status)
|
99
|
+
if return_job_status == nil
|
100
|
+
raise ArgumentError.new('Please ensure that you send through return_job_status')
|
101
|
+
end
|
102
|
+
|
103
|
+
if !!return_job_status != return_job_status
|
104
|
+
raise ArgumentError.new('return_job_status needs to be a boolean')
|
105
|
+
end
|
106
|
+
|
107
|
+
@return_job_status = return_job_status
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def validate_return_data
|
113
|
+
if @callback_url.empty? && !@return_job_status
|
114
|
+
raise ArgumentError.new("Please choose to either get your response via the callback or job status query")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def validate_enroll_with_id
|
119
|
+
if(((@images.none? {|h| h[:image_type_id] == 1 || h[:image_type_id] == 3 }) && @id_info[:entered] != 'true'))
|
120
|
+
raise ArgumentError.new("You are attempting to complete a job type 1 without providing an id card image or id info")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def determine_sec_key
|
125
|
+
hash_signature = Digest::SHA256.hexdigest([@partner_id.to_i, @timestamp].join(":"))
|
126
|
+
public_key = OpenSSL::PKey::RSA.new(Base64.decode64(@api_key))
|
127
|
+
@sec_key = [Base64.encode64(public_key.public_encrypt(hash_signature)), hash_signature].join('|')
|
128
|
+
end
|
129
|
+
|
130
|
+
def configure_prep_upload_json
|
131
|
+
body = {
|
132
|
+
file_name: 'selfie.zip',
|
133
|
+
timestamp: @timestamp,
|
134
|
+
sec_key: determine_sec_key,
|
135
|
+
smile_client_id: @partner_id,
|
136
|
+
partner_params: @partner_params,
|
137
|
+
model_parameters: {}, # what is this for
|
138
|
+
callback_url: @callback_url
|
139
|
+
}
|
140
|
+
|
141
|
+
JSON.generate(body)
|
142
|
+
end
|
143
|
+
|
144
|
+
def setup_requests
|
145
|
+
|
146
|
+
url = "#{@url}/upload"
|
147
|
+
request = Typhoeus::Request.new(
|
148
|
+
url,
|
149
|
+
method: 'POST',
|
150
|
+
headers: {'Content-Type'=> "application/json"},
|
151
|
+
body: configure_prep_upload_json
|
152
|
+
)
|
153
|
+
|
154
|
+
request.on_complete do |response|
|
155
|
+
if response.success?
|
156
|
+
|
157
|
+
prep_upload_response = JSON.parse(response.body)
|
158
|
+
info_json = configure_info_json(prep_upload_response)
|
159
|
+
|
160
|
+
file_upload_response = upload_file(prep_upload_response['upload_url'], info_json)
|
161
|
+
return file_upload_response
|
162
|
+
|
163
|
+
elsif response.timed_out?
|
164
|
+
raise "#{response.code.to_s}: #{response.body}"
|
165
|
+
elsif response.code == 0
|
166
|
+
# Could not get an http response, something's wrong.
|
167
|
+
raise "#{response.code.to_s}: #{response.body}"
|
168
|
+
else
|
169
|
+
# Received a non-successful http response.
|
170
|
+
raise "#{response.code.to_s}: #{response.body}"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
request.run
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
def configure_info_json(server_information)
|
178
|
+
info = {
|
179
|
+
"package_information": {
|
180
|
+
"apiVersion": {
|
181
|
+
"buildNumber": 0,
|
182
|
+
"majorVersion": 2,
|
183
|
+
"minorVersion": 0
|
184
|
+
}
|
185
|
+
},
|
186
|
+
"misc_information": {
|
187
|
+
"sec_key": @sec_key,
|
188
|
+
"retry": "false",
|
189
|
+
"partner_params": @partner_params,
|
190
|
+
"timestamp": @timestamp,
|
191
|
+
"file_name": "selfie.zip", # figure out what to do here
|
192
|
+
"smile_client_id": @partner_id,
|
193
|
+
"callback_url": @callback_url,
|
194
|
+
"userData": { # TO ASK what goes here
|
195
|
+
"isVerifiedProcess": false,
|
196
|
+
"name": "",
|
197
|
+
"fbUserID": "",
|
198
|
+
"firstName": "Bill",
|
199
|
+
"lastName": "",
|
200
|
+
"gender": "",
|
201
|
+
"email": "",
|
202
|
+
"phone": "",
|
203
|
+
"countryCode": "+",
|
204
|
+
"countryName": ""
|
205
|
+
}
|
206
|
+
},
|
207
|
+
"id_info": @id_info,
|
208
|
+
"images": configure_image_payload,
|
209
|
+
"server_information": server_information
|
210
|
+
}
|
211
|
+
return info
|
212
|
+
end
|
213
|
+
|
214
|
+
def configure_image_payload
|
215
|
+
@images.map { |i|
|
216
|
+
if isImageFile?i[:image_type_id]
|
217
|
+
{
|
218
|
+
image_type_id: i[:image_type_id],
|
219
|
+
image: '',
|
220
|
+
file_name: File.basename(i[:image])
|
221
|
+
}
|
222
|
+
else
|
223
|
+
{
|
224
|
+
image_type_id: i[:image_type_id],
|
225
|
+
image: i[:image],
|
226
|
+
file_name: ''
|
227
|
+
}
|
228
|
+
end
|
229
|
+
}
|
230
|
+
end
|
231
|
+
|
232
|
+
def isImageFile?type
|
233
|
+
type.to_i == 0 || type.to_i == 1
|
234
|
+
end
|
235
|
+
|
236
|
+
def zip_up_file(info_json)
|
237
|
+
# https://info.michael-simons.eu/2008/01/21/using-rubyzip-to-create-zip-files-on-the-fly/
|
238
|
+
Zip::OutputStream.write_buffer do |zos|
|
239
|
+
zos.put_next_entry('info.json')
|
240
|
+
zos.puts JSON.pretty_generate(info_json)
|
241
|
+
|
242
|
+
if @images.length > 0
|
243
|
+
@images.each do |img|
|
244
|
+
if img[:image_type_id] == 0 || img[:image_type_id] == 1
|
245
|
+
zos.put_next_entry(File.basename(img[:image]))
|
246
|
+
zos.print IO.read(img[:image])
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def upload_file(url, info_json)
|
254
|
+
|
255
|
+
file = zip_up_file(info_json)
|
256
|
+
file.rewind
|
257
|
+
|
258
|
+
request = Typhoeus::Request.new(
|
259
|
+
url,
|
260
|
+
method: 'PUT',
|
261
|
+
headers: {'Content-Type'=> "application/zip"},
|
262
|
+
body: file.read,
|
263
|
+
)
|
264
|
+
|
265
|
+
request.on_complete do |response|
|
266
|
+
if response.success?
|
267
|
+
if @return_job_status
|
268
|
+
return query_job_status
|
269
|
+
else
|
270
|
+
return
|
271
|
+
end
|
272
|
+
elsif response.timed_out?
|
273
|
+
raise " #{response.code.to_s}: #{response.body}"
|
274
|
+
elsif response.code == 0
|
275
|
+
# Could not get an http response, something's wrong.
|
276
|
+
raise " #{response.code.to_s}: #{response.body}"
|
277
|
+
else
|
278
|
+
# Received a non-successful http response.
|
279
|
+
raise " #{response.code.to_s}: #{response.body}"
|
280
|
+
end
|
281
|
+
end
|
282
|
+
request.run
|
283
|
+
|
284
|
+
end
|
285
|
+
|
286
|
+
def query_job_status(counter=0)
|
287
|
+
job_complete = false
|
288
|
+
counter < 4 ? (sleep 2) : (sleep 6)
|
289
|
+
counter += 1
|
290
|
+
|
291
|
+
body = {
|
292
|
+
sec_key: @sec_key,
|
293
|
+
timestamp: @timestamp,
|
294
|
+
user_id: @partner_params[:user_id],
|
295
|
+
job_id: @partner_params[:job_id],
|
296
|
+
partner_id: @partner_id,
|
297
|
+
image_links: "false", # we hardcode to false for now
|
298
|
+
}.to_json
|
299
|
+
|
300
|
+
url = "#{@url}/job_status"
|
301
|
+
|
302
|
+
request = Typhoeus::Request.new(
|
303
|
+
url,
|
304
|
+
headers: {'Content-Type': 'application/json', 'Accept': 'application/json'},
|
305
|
+
method: :post,
|
306
|
+
body: body
|
307
|
+
)
|
308
|
+
|
309
|
+
request.on_complete do |response|
|
310
|
+
|
311
|
+
if response.code == 0
|
312
|
+
return query_job_status(counter)
|
313
|
+
else
|
314
|
+
begin
|
315
|
+
status_body = JSON.load(response.body)
|
316
|
+
job_complete = status_body['job_complete'].to_s
|
317
|
+
rescue => e
|
318
|
+
puts e.message
|
319
|
+
puts e.backtrace
|
320
|
+
end
|
321
|
+
|
322
|
+
if job_complete == 'true' || counter == 20
|
323
|
+
return JSON.parse(response.body)
|
324
|
+
else
|
325
|
+
return query_job_status(counter)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
request.run
|
331
|
+
end
|
332
|
+
end
|
333
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "smile-identity-core/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "smile-identity-core"
|
7
|
+
spec.version = SmileIdentityCore::VERSION
|
8
|
+
spec.authors = ["Ridhwana"]
|
9
|
+
spec.email = ["ridhwana.khan16@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "The Smile Identity Web API allows the user to access most of the features of the Smile Identity system through direct server to server queries."
|
12
|
+
spec.description = "The official Smile Identity gem"
|
13
|
+
spec.homepage = "https://www.smileidentity.com/"
|
14
|
+
spec.required_ruby_version = '>= 2.0'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/smileidentity/smile-identity-core"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/smileidentity/smile-identity-core/blob/master/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
spec.add_development_dependency 'simplecov', '~> 0.12.0'
|
34
|
+
|
35
|
+
spec.add_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
36
|
+
spec.add_dependency 'rubyzip', '~> 1.2', '>= 1.2.3'
|
37
|
+
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: smile-identity-core
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ridhwana
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-07-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.12.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.12.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: typhoeus
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.0.1
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '1.0'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 1.0.1
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rubyzip
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.2'
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.2.3
|
99
|
+
type: :runtime
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.2'
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 1.2.3
|
109
|
+
description: The official Smile Identity gem
|
110
|
+
email:
|
111
|
+
- ridhwana.khan16@gmail.com
|
112
|
+
executables: []
|
113
|
+
extensions: []
|
114
|
+
extra_rdoc_files: []
|
115
|
+
files:
|
116
|
+
- ".gitignore"
|
117
|
+
- ".rspec"
|
118
|
+
- ".travis.yml"
|
119
|
+
- CHANGELOG.md
|
120
|
+
- Gemfile
|
121
|
+
- Gemfile.lock
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- bin/console
|
125
|
+
- bin/setup
|
126
|
+
- lib/smile-identity-core.rb
|
127
|
+
- lib/smile-identity-core/signature.rb
|
128
|
+
- lib/smile-identity-core/version.rb
|
129
|
+
- lib/smile-identity-core/web_api.rb
|
130
|
+
- smile-identity-core.gemspec
|
131
|
+
homepage: https://www.smileidentity.com/
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata:
|
135
|
+
homepage_uri: https://www.smileidentity.com/
|
136
|
+
source_code_uri: https://github.com/smileidentity/smile-identity-core
|
137
|
+
changelog_uri: https://github.com/smileidentity/smile-identity-core/blob/master/CHANGELOG.md
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '2.0'
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
requirements: []
|
153
|
+
rubyforge_project:
|
154
|
+
rubygems_version: 2.7.6
|
155
|
+
signing_key:
|
156
|
+
specification_version: 4
|
157
|
+
summary: The Smile Identity Web API allows the user to access most of the features
|
158
|
+
of the Smile Identity system through direct server to server queries.
|
159
|
+
test_files: []
|