onfido 1.1.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +5 -5
  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 +2 -8
  6. data/CHANGELOG.md +26 -1
  7. data/Gemfile +2 -0
  8. data/README.md +37 -148
  9. data/lib/onfido.rb +3 -3
  10. data/lib/onfido/api.rb +18 -12
  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 -59
  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 +2 -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 +4 -2
  27. data/lib/onfido/version.rb +3 -1
  28. data/onfido.gemspec +5 -6
  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 +7 -3
  33. data/spec/integrations/extraction_spec.rb +6 -2
  34. data/spec/integrations/live_photo_spec.rb +7 -3
  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 +28 -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 +63 -49
  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/live_photo.json +2 -2
  52. data/spec/support/fixtures/live_photos.json +4 -4
  53. data/spec/support/fixtures/live_video.json +2 -2
  54. data/spec/support/fixtures/live_videos.json +2 -2
  55. data/spec/support/fixtures/report.json +1 -1
  56. data/spec/support/fixtures/reports.json +2 -2
  57. data/spec/support/fixtures/webhook.json +1 -1
  58. data/spec/support/fixtures/webhooks.json +2 -2
  59. metadata +16 -33
  60. data/Rakefile +0 -1
  61. data/lib/onfido/configuration.rb +0 -47
  62. data/lib/onfido/null_logger.rb +0 -5
  63. data/spec/integrations/exceptions_spec.rb +0 -73
  64. data/spec/onfido/resource_spec.rb +0 -133
  65. data/spec/onfido_spec.rb +0 -83
data/spec/onfido_spec.rb DELETED
@@ -1,83 +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 the CA region' do
38
- it 'should change endpoint' do
39
- onfido.region = 'ca'
40
- expect(onfido.endpoint).to eq('https://api.ca.onfido.com/v3/')
41
- end
42
- end
43
-
44
- describe 'using an unsupported region' do
45
- it 'should change endpoint' do
46
- onfido.region = 'de'
47
- expect { onfido.endpoint }.
48
- to raise_error('The region "de" is not currently supported')
49
- end
50
- end
51
-
52
- describe 'using an old API token' do
53
- it 'should use old endpoint' do
54
- onfido.api_key = "live_asdfghjkl1234567890qwertyuiop"
55
- expect(onfido.endpoint).to eq('https://api.onfido.com/v3/')
56
- end
57
- end
58
-
59
- describe '.logger' do
60
- context 'when an option is passed' do
61
- context 'when the option passed behaves like a logger' do
62
- let(:logger_like) { double('LoggerLike', :<< => nil) }
63
-
64
- it 'returns the option' do
65
- onfido.logger = logger_like
66
- expect(onfido.logger).to eq(logger_like)
67
- end
68
- end
69
-
70
- context 'when the option passed does not behave like a logger' do
71
- let(:non_logger) { double('NotLogger') }
72
-
73
- it 'raises an error' do
74
- expect { onfido.logger = non_logger }.
75
- to raise_error(
76
- "#{non_logger.class} doesn't seem to behave like a logger!"
77
- )
78
- end
79
- end
80
- end
81
- end
82
- end
83
- end