onfido 1.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +31 -0
- data/.github/workflows/ruby.yml +25 -0
- data/.rubocop.yml +5 -49
- data/.travis.yml +3 -10
- data/CHANGELOG.md +27 -0
- data/Gemfile +2 -0
- data/README.md +44 -156
- data/lib/onfido.rb +4 -3
- data/lib/onfido/api.rb +21 -11
- data/lib/onfido/errors/connection_error.rb +2 -0
- data/lib/onfido/errors/onfido_error.rb +2 -0
- data/lib/onfido/errors/request_error.rb +2 -0
- data/lib/onfido/errors/server_error.rb +2 -0
- data/lib/onfido/options.rb +38 -0
- data/lib/onfido/resource.rb +48 -58
- data/lib/onfido/resources/address.rb +3 -4
- data/lib/onfido/resources/applicant.rb +2 -0
- data/lib/onfido/resources/check.rb +6 -0
- data/lib/onfido/resources/document.rb +2 -0
- data/lib/onfido/resources/extraction.rb +11 -0
- data/lib/onfido/resources/live_photo.rb +2 -0
- data/lib/onfido/resources/live_video.rb +2 -0
- data/lib/onfido/resources/report.rb +2 -0
- data/lib/onfido/resources/sdk_token.rb +2 -0
- data/lib/onfido/resources/webhook.rb +8 -2
- data/lib/onfido/version.rb +3 -1
- data/onfido.gemspec +5 -7
- data/spec/integrations/address_spec.rb +4 -2
- data/spec/integrations/applicant_spec.rb +12 -7
- data/spec/integrations/check_spec.rb +17 -4
- data/spec/integrations/document_spec.rb +8 -4
- data/spec/integrations/extraction_spec.rb +23 -0
- data/spec/integrations/live_photo_spec.rb +8 -4
- data/spec/integrations/live_video_spec.rb +6 -1
- data/spec/integrations/report_spec.rb +6 -1
- data/spec/integrations/resource_spec.rb +106 -0
- data/spec/integrations/sdk_token_spec.rb +5 -1
- data/spec/integrations/webhook_spec.rb +35 -24
- data/spec/onfido/api_spec.rb +14 -25
- data/spec/onfido/connection_error_spec.rb +4 -2
- data/spec/onfido/options_spec.rb +39 -0
- data/spec/onfido/request_error_spec.rb +4 -2
- data/spec/spec_helper.rb +3 -5
- data/spec/support/fake_onfido_api.rb +69 -46
- data/spec/support/fixtures/applicant.json +1 -1
- data/spec/support/fixtures/check.json +1 -1
- data/spec/support/fixtures/checks.json +1 -1
- data/spec/support/fixtures/document.json +1 -1
- data/spec/support/fixtures/documents.json +2 -2
- data/spec/support/fixtures/extraction.json +23 -0
- data/spec/support/fixtures/live_photo.json +2 -2
- data/spec/support/fixtures/live_photos.json +4 -4
- data/spec/support/fixtures/live_video.json +2 -2
- data/spec/support/fixtures/live_videos.json +2 -2
- data/spec/support/fixtures/report.json +1 -1
- data/spec/support/fixtures/reports.json +2 -2
- data/spec/support/fixtures/webhook.json +1 -1
- data/spec/support/fixtures/webhooks.json +2 -2
- metadata +18 -43
- data/Rakefile +0 -1
- data/lib/onfido/configuration.rb +0 -46
- data/lib/onfido/null_logger.rb +0 -5
- data/spec/integrations/exceptions_spec.rb +0 -73
- data/spec/onfido/resource_spec.rb +0 -131
- data/spec/onfido_spec.rb +0 -76
data/spec/onfido_spec.rb
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
describe Onfido do
|
2
|
-
subject(:onfido) { described_class }
|
3
|
-
after(:each) { onfido.reset }
|
4
|
-
|
5
|
-
context 'configuration' do
|
6
|
-
describe "default values" do
|
7
|
-
describe ".api_key" do
|
8
|
-
subject { onfido.api_key }
|
9
|
-
it { is_expected.to be_nil }
|
10
|
-
end
|
11
|
-
|
12
|
-
describe ".endpoint" do
|
13
|
-
subject { onfido.endpoint }
|
14
|
-
it { is_expected.to eq('https://api.onfido.com/v3/') }
|
15
|
-
end
|
16
|
-
|
17
|
-
describe ".logger" do
|
18
|
-
subject { onfido.logger }
|
19
|
-
it { is_expected.to be_an_instance_of(Onfido::NullLogger) }
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe "setting an API key" do
|
24
|
-
it 'changes the configuration to the new value' do
|
25
|
-
onfido.api_key = 'some_key'
|
26
|
-
expect(onfido.api_key).to eq('some_key')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe 'using the US region' do
|
31
|
-
it 'should change endpoint' do
|
32
|
-
onfido.region = 'us'
|
33
|
-
expect(onfido.endpoint).to eq('https://api.us.onfido.com/v3/')
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'using an unsupported region' do
|
38
|
-
it 'should change endpoint' do
|
39
|
-
onfido.region = 'de'
|
40
|
-
expect { onfido.endpoint }.
|
41
|
-
to raise_error('The region "de" is not currently supported')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe 'using an old API token' do
|
46
|
-
it 'should use old endpoint' do
|
47
|
-
onfido.api_key = "live_asdfghjkl1234567890qwertyuiop"
|
48
|
-
expect(onfido.endpoint).to eq('https://api.onfido.com/v3/')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '.logger' do
|
53
|
-
context 'when an option is passed' do
|
54
|
-
context 'when the option passed behaves like a logger' do
|
55
|
-
let(:logger_like) { double('LoggerLike', :<< => nil) }
|
56
|
-
|
57
|
-
it 'returns the option' do
|
58
|
-
onfido.logger = logger_like
|
59
|
-
expect(onfido.logger).to eq(logger_like)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'when the option passed does not behave like a logger' do
|
64
|
-
let(:non_logger) { double('NotLogger') }
|
65
|
-
|
66
|
-
it 'raises an error' do
|
67
|
-
expect { onfido.logger = non_logger }.
|
68
|
-
to raise_error(
|
69
|
-
"#{non_logger.class} doesn't seem to behave like a logger!"
|
70
|
-
)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|