onfido 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +13 -1
- data/CHANGELOG.md +4 -0
- data/README.md +12 -2
- data/lib/onfido.rb +1 -0
- data/lib/onfido/configuration.rb +3 -3
- data/lib/onfido/null_logger.rb +1 -2
- data/lib/onfido/resource.rb +1 -3
- data/lib/onfido/resources/sdk_token.rb +10 -0
- data/lib/onfido/version.rb +1 -1
- data/onfido.gemspec +10 -6
- data/spec/integrations/sdk_token_spec.rb +14 -0
- data/spec/onfido/resource_spec.rb +4 -2
- data/spec/support/fake_onfido_api.rb +4 -0
- data/spec/support/fixtures/sdk_token.json +3 -0
- metadata +35 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 54ef7de51857895f39c1b960c7959828ff7d36a502a13a1a62db5f76d811ce64
|
4
|
+
data.tar.gz: 495241aeaaa859d1b2b8aed6a250df2519d9df5a2a7624741949156aa9ea7cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d86bab77e16c80dc43fa0269d427814ab3fad06701b95eacfba17794409acd9abe29ccced71388c4a2ecf678268c6b50d952fe90e0abf93188eb3ae6e1a910a
|
7
|
+
data.tar.gz: 7f40677b7801251f9ef247e10c2d0a796e6ce9120d864874bc49eb3d0eca27cc73de0a8e64b479f607011e0d4d8d7d48ab6ad97b9dce30705fa19cacc4f9588d
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# For all options see https://github.com/bbatsov/rubocop/tree/master/config
|
2
2
|
|
3
3
|
AllCops:
|
4
|
+
DisplayCopNames: true
|
4
5
|
Include:
|
5
6
|
- Rakefile
|
6
7
|
- lib/tasks/*.rake
|
@@ -12,16 +13,27 @@ AllCops:
|
|
12
13
|
Style/StringLiterals:
|
13
14
|
Enabled: false
|
14
15
|
|
16
|
+
Style/PercentLiteralDelimiters:
|
17
|
+
Enabled: false
|
18
|
+
|
15
19
|
Style/Documentation:
|
16
20
|
Enabled: false
|
17
21
|
|
18
22
|
Style/SignalException:
|
19
23
|
EnforcedStyle: only_raise
|
20
24
|
|
25
|
+
Style/FileName:
|
26
|
+
Exclude:
|
27
|
+
- Gemfile
|
28
|
+
|
21
29
|
Metrics/MethodLength:
|
22
30
|
CountComments: false
|
23
31
|
Max: 25
|
24
32
|
|
33
|
+
Metrics/BlockLength:
|
34
|
+
Exclude:
|
35
|
+
- spec/**/*
|
36
|
+
|
25
37
|
Metrics/AbcSize:
|
26
38
|
Max: 25
|
27
39
|
|
@@ -35,7 +47,7 @@ Metrics/LineLength:
|
|
35
47
|
Metrics/ClassLength:
|
36
48
|
Enabled: false
|
37
49
|
|
38
|
-
|
50
|
+
Layout/DotPosition:
|
39
51
|
EnforcedStyle: trailing
|
40
52
|
|
41
53
|
# Allow class and message or instance raises
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,7 +12,7 @@ This gem supports both `v1` and `v2` of the Onfido API. Refer to Onfido's [API d
|
|
12
12
|
Add this line to your application's Gemfile:
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
gem 'onfido', '~> 0.8.
|
15
|
+
gem 'onfido', '~> 0.8.3'
|
16
16
|
```
|
17
17
|
|
18
18
|
## Configuration
|
@@ -112,6 +112,7 @@ api.report.cancel('check_id', 'report_id')
|
|
112
112
|
```
|
113
113
|
|
114
114
|
#### Report Type Groups
|
115
|
+
|
115
116
|
Report type groups provide a convenient way to group and organize different types of reports.
|
116
117
|
The Onfido API only provides support for finding and listing them.
|
117
118
|
|
@@ -141,6 +142,15 @@ api.webhook.find('webhook_id') # => Finds a single webhook endpoint
|
|
141
142
|
api.webhook.all # => Returns all webhook endpoints
|
142
143
|
```
|
143
144
|
|
145
|
+
#### SDK Tokens
|
146
|
+
|
147
|
+
Onfido allows you to generate JSON Web Tokens via the API in order to authenticate
|
148
|
+
with Onfido's [JavaScript SDK](https://github.com/onfido/onfido-sdk-ui).
|
149
|
+
|
150
|
+
```ruby
|
151
|
+
api.sdk_token.create(applicant_id: 'applicant_id', referrer: 'referrer')
|
152
|
+
```
|
153
|
+
|
144
154
|
### Pagination
|
145
155
|
|
146
156
|
All resources that support an `all` method also support pagination. By default,
|
@@ -148,7 +158,7 @@ the first 20 records are fetched.
|
|
148
158
|
|
149
159
|
### Error Handling
|
150
160
|
|
151
|
-
There are three classes of errors raised by the library, all of which subclass `Onfido::
|
161
|
+
There are three classes of errors raised by the library, all of which subclass `Onfido::OnfidoError`:
|
152
162
|
- `Onfido::ServerError` is raised whenever Onfido returns a `5xx` response
|
153
163
|
- `Onfido::RequestError` is raised whenever Onfido returns any other kind of error
|
154
164
|
- `Onfido::ConnectionError` is raised whenever a network error occurs (e.g., a timeout)
|
data/lib/onfido.rb
CHANGED
data/lib/onfido/configuration.rb
CHANGED
@@ -19,11 +19,11 @@ module Onfido
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def logger=(log)
|
22
|
-
|
23
|
-
RestClient.log = log
|
24
|
-
else
|
22
|
+
unless log.respond_to?(:<<)
|
25
23
|
raise "#{log.class} doesn't seem to behave like a logger!"
|
26
24
|
end
|
25
|
+
|
26
|
+
RestClient.log = log
|
27
27
|
end
|
28
28
|
|
29
29
|
def logger
|
data/lib/onfido/null_logger.rb
CHANGED
data/lib/onfido/resource.rb
CHANGED
@@ -88,9 +88,7 @@ module Onfido
|
|
88
88
|
def handle_api_error(response)
|
89
89
|
parsed_response = parse(response)
|
90
90
|
|
91
|
-
unless parsed_response["error"]
|
92
|
-
general_api_error(response.code, response.body)
|
93
|
-
end
|
91
|
+
general_api_error(response.code, response.body) unless parsed_response["error"]
|
94
92
|
|
95
93
|
error_class = response.code.to_i >= 500 ? ServerError : RequestError
|
96
94
|
|
data/lib/onfido/version.rb
CHANGED
data/onfido.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'onfido/version'
|
@@ -8,8 +9,11 @@ Gem::Specification.new do |spec|
|
|
8
9
|
spec.version = Onfido::VERSION
|
9
10
|
spec.authors = ['Pericles Theodorou', 'Grey Baker']
|
10
11
|
spec.email = ['periclestheo@gmail.com', 'grey@gocardless.com']
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
12
|
+
spec.summary = 'A wrapper for Onfido API'
|
13
|
+
spec.description = "A thin wrapper for Onfido's API. This gem supports "\
|
14
|
+
"both v1 and v2 of the Onfido API. Refer to Onfido's "\
|
15
|
+
"API documentation for details of the expected "\
|
16
|
+
"requests and responses for both."
|
13
17
|
spec.homepage = 'http://github.com/hvssle/onfido'
|
14
18
|
spec.license = 'MIT'
|
15
19
|
|
@@ -19,13 +23,13 @@ Gem::Specification.new do |spec|
|
|
19
23
|
spec.require_paths = ['lib']
|
20
24
|
|
21
25
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
-
spec.add_development_dependency 'rake', '~>
|
23
|
-
spec.add_development_dependency 'webmock', '~> 2.3'
|
24
|
-
spec.add_development_dependency 'rubocop', '~> 0.37.0'
|
26
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
25
27
|
spec.add_development_dependency 'rspec', '~> 3.1'
|
26
28
|
spec.add_development_dependency 'rspec-its', '~> 1.2'
|
29
|
+
spec.add_development_dependency 'rubocop', '~> 0.52.0'
|
27
30
|
spec.add_development_dependency 'sinatra', '~> 1.4'
|
31
|
+
spec.add_development_dependency 'webmock', '~> 3.0'
|
28
32
|
|
29
|
-
spec.add_dependency 'rest-client', '~> 2.0'
|
30
33
|
spec.add_dependency 'rack', '>= 1.6.0'
|
34
|
+
spec.add_dependency 'rest-client', '~> 2.0'
|
31
35
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
describe Onfido::SdkToken do
|
2
|
+
subject(:sdk_token) { described_class.new }
|
3
|
+
let(:applicant_id) { '61f659cb-c90b-4067-808a-6136b5c01351' }
|
4
|
+
let(:referrer) { 'http://*.mywebsite.com/*' }
|
5
|
+
|
6
|
+
describe '#create' do
|
7
|
+
let(:params) { { applicant_id: applicant_id, referrer: referrer } }
|
8
|
+
|
9
|
+
it 'creates a new SDK token for the applicant' do
|
10
|
+
response = sdk_token.create(params)
|
11
|
+
expect(response['token']).not_to be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -70,7 +70,8 @@ describe Onfido::Resource do
|
|
70
70
|
headers: {
|
71
71
|
'Authorization' => "Token token=#{specific_api_key}",
|
72
72
|
'Accept' => "application/json"
|
73
|
-
}
|
73
|
+
}
|
74
|
+
)
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
@@ -84,7 +85,8 @@ describe Onfido::Resource do
|
|
84
85
|
headers: {
|
85
86
|
'Authorization' => "Token token=#{api_key}",
|
86
87
|
'Accept' => "application/json"
|
87
|
-
}
|
88
|
+
}
|
89
|
+
)
|
88
90
|
end
|
89
91
|
end
|
90
92
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onfido
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pericles Theodorou
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -31,112 +31,112 @@ dependencies:
|
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '12.0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '12.0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
|
-
name:
|
43
|
+
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '3.1'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '3.1'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
|
-
name:
|
57
|
+
name: rspec-its
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: '1.2'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: '1.2'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: rubocop
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version:
|
76
|
+
version: 0.52.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version:
|
83
|
+
version: 0.52.0
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
85
|
+
name: sinatra
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
88
|
- - "~>"
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version: '1.
|
90
|
+
version: '1.4'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - "~>"
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version: '1.
|
97
|
+
version: '1.4'
|
98
98
|
- !ruby/object:Gem::Dependency
|
99
|
-
name:
|
99
|
+
name: webmock
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
102
|
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
104
|
+
version: '3.0'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
109
|
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
111
|
+
version: '3.0'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
|
-
name:
|
113
|
+
name: rack
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
115
115
|
requirements:
|
116
|
-
- - "
|
116
|
+
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version:
|
118
|
+
version: 1.6.0
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
requirements:
|
123
|
-
- - "
|
123
|
+
- - ">="
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version:
|
125
|
+
version: 1.6.0
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
127
|
+
name: rest-client
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- - "
|
130
|
+
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
132
|
+
version: '2.0'
|
133
133
|
type: :runtime
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- - "
|
137
|
+
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
139
|
+
version: '2.0'
|
140
140
|
description: A thin wrapper for Onfido's API. This gem supports both v1 and v2 of
|
141
141
|
the Onfido API. Refer to Onfido's API documentation for details of the expected
|
142
142
|
requests and responses for both.
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- lib/onfido/resources/live_photo.rb
|
173
173
|
- lib/onfido/resources/report.rb
|
174
174
|
- lib/onfido/resources/report_type_group.rb
|
175
|
+
- lib/onfido/resources/sdk_token.rb
|
175
176
|
- lib/onfido/resources/webhook.rb
|
176
177
|
- lib/onfido/version.rb
|
177
178
|
- onfido.gemspec
|
@@ -183,6 +184,7 @@ files:
|
|
183
184
|
- spec/integrations/live_photo_spec.rb
|
184
185
|
- spec/integrations/report_spec.rb
|
185
186
|
- spec/integrations/report_type_group_spec.rb
|
187
|
+
- spec/integrations/sdk_token_spec.rb
|
186
188
|
- spec/integrations/webhook_spec.rb
|
187
189
|
- spec/onfido/api_spec.rb
|
188
190
|
- spec/onfido/connection_error_spec.rb
|
@@ -206,6 +208,7 @@ files:
|
|
206
208
|
- spec/support/fixtures/report_type_group.json
|
207
209
|
- spec/support/fixtures/report_type_groups.json
|
208
210
|
- spec/support/fixtures/reports.json
|
211
|
+
- spec/support/fixtures/sdk_token.json
|
209
212
|
- spec/support/fixtures/unexpected_error_format.json
|
210
213
|
- spec/support/fixtures/webhook.json
|
211
214
|
- spec/support/fixtures/webhooks.json
|
@@ -229,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
232
|
version: '0'
|
230
233
|
requirements: []
|
231
234
|
rubyforge_project:
|
232
|
-
rubygems_version: 2.
|
235
|
+
rubygems_version: 2.7.4
|
233
236
|
signing_key:
|
234
237
|
specification_version: 4
|
235
238
|
summary: A wrapper for Onfido API
|
@@ -242,6 +245,7 @@ test_files:
|
|
242
245
|
- spec/integrations/live_photo_spec.rb
|
243
246
|
- spec/integrations/report_spec.rb
|
244
247
|
- spec/integrations/report_type_group_spec.rb
|
248
|
+
- spec/integrations/sdk_token_spec.rb
|
245
249
|
- spec/integrations/webhook_spec.rb
|
246
250
|
- spec/onfido/api_spec.rb
|
247
251
|
- spec/onfido/connection_error_spec.rb
|
@@ -265,7 +269,7 @@ test_files:
|
|
265
269
|
- spec/support/fixtures/report_type_group.json
|
266
270
|
- spec/support/fixtures/report_type_groups.json
|
267
271
|
- spec/support/fixtures/reports.json
|
272
|
+
- spec/support/fixtures/sdk_token.json
|
268
273
|
- spec/support/fixtures/unexpected_error_format.json
|
269
274
|
- spec/support/fixtures/webhook.json
|
270
275
|
- spec/support/fixtures/webhooks.json
|
271
|
-
has_rdoc:
|