onfido 1.0.0 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/gem-push.yml +31 -0
  3. data/.github/workflows/ruby.yml +25 -0
  4. data/.rubocop.yml +5 -49
  5. data/.travis.yml +3 -10
  6. data/CHANGELOG.md +27 -0
  7. data/Gemfile +2 -0
  8. data/README.md +44 -156
  9. data/lib/onfido.rb +4 -3
  10. data/lib/onfido/api.rb +21 -11
  11. data/lib/onfido/errors/connection_error.rb +2 -0
  12. data/lib/onfido/errors/onfido_error.rb +2 -0
  13. data/lib/onfido/errors/request_error.rb +2 -0
  14. data/lib/onfido/errors/server_error.rb +2 -0
  15. data/lib/onfido/options.rb +38 -0
  16. data/lib/onfido/resource.rb +48 -58
  17. data/lib/onfido/resources/address.rb +3 -4
  18. data/lib/onfido/resources/applicant.rb +2 -0
  19. data/lib/onfido/resources/check.rb +6 -0
  20. data/lib/onfido/resources/document.rb +2 -0
  21. data/lib/onfido/resources/extraction.rb +11 -0
  22. data/lib/onfido/resources/live_photo.rb +2 -0
  23. data/lib/onfido/resources/live_video.rb +2 -0
  24. data/lib/onfido/resources/report.rb +2 -0
  25. data/lib/onfido/resources/sdk_token.rb +2 -0
  26. data/lib/onfido/resources/webhook.rb +8 -2
  27. data/lib/onfido/version.rb +3 -1
  28. data/onfido.gemspec +5 -7
  29. data/spec/integrations/address_spec.rb +4 -2
  30. data/spec/integrations/applicant_spec.rb +12 -7
  31. data/spec/integrations/check_spec.rb +17 -4
  32. data/spec/integrations/document_spec.rb +8 -4
  33. data/spec/integrations/extraction_spec.rb +23 -0
  34. data/spec/integrations/live_photo_spec.rb +8 -4
  35. data/spec/integrations/live_video_spec.rb +6 -1
  36. data/spec/integrations/report_spec.rb +6 -1
  37. data/spec/integrations/resource_spec.rb +106 -0
  38. data/spec/integrations/sdk_token_spec.rb +5 -1
  39. data/spec/integrations/webhook_spec.rb +35 -24
  40. data/spec/onfido/api_spec.rb +14 -25
  41. data/spec/onfido/connection_error_spec.rb +4 -2
  42. data/spec/onfido/options_spec.rb +39 -0
  43. data/spec/onfido/request_error_spec.rb +4 -2
  44. data/spec/spec_helper.rb +3 -5
  45. data/spec/support/fake_onfido_api.rb +69 -46
  46. data/spec/support/fixtures/applicant.json +1 -1
  47. data/spec/support/fixtures/check.json +1 -1
  48. data/spec/support/fixtures/checks.json +1 -1
  49. data/spec/support/fixtures/document.json +1 -1
  50. data/spec/support/fixtures/documents.json +2 -2
  51. data/spec/support/fixtures/extraction.json +23 -0
  52. data/spec/support/fixtures/live_photo.json +2 -2
  53. data/spec/support/fixtures/live_photos.json +4 -4
  54. data/spec/support/fixtures/live_video.json +2 -2
  55. data/spec/support/fixtures/live_videos.json +2 -2
  56. data/spec/support/fixtures/report.json +1 -1
  57. data/spec/support/fixtures/reports.json +2 -2
  58. data/spec/support/fixtures/webhook.json +1 -1
  59. data/spec/support/fixtures/webhooks.json +2 -2
  60. metadata +18 -43
  61. data/Rakefile +0 -1
  62. data/lib/onfido/configuration.rb +0 -46
  63. data/lib/onfido/null_logger.rb +0 -5
  64. data/spec/integrations/exceptions_spec.rb +0 -73
  65. data/spec/onfido/resource_spec.rb +0 -131
  66. 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