onfido 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5ff31b07bd57afd22994fbf3cdca9b87a445f48
4
- data.tar.gz: 725b94b57bb42062a18dc181996275b5e70c511a
3
+ metadata.gz: 9a1f27eb9ad0741dbb6a79a47e5500a9803949e3
4
+ data.tar.gz: 9b372d911abceaf82a67ffa26acf94b1f39043b0
5
5
  SHA512:
6
- metadata.gz: 86a378c7321ddedea578b7576dbff36af63bcf6ec00bce990fd17dd3c52661aa07ec5a66584185b9617eab4517310244b398d4c0ec3f7cf7d767d7cb852de60b
7
- data.tar.gz: 5845d5e243a8d759d4651e9b13325155ac515ba7097fbc7d77182c945c5533808372ed8c613d4ed1026afdc091b5aeb7d3027df561b41fb7b2444b52edc34a8e
6
+ metadata.gz: 64ec8d066f5c1001fa0ead05077135edff853704d2a36d80051da66825372df75fae278cff76cd29cdacb3bd217e71eb6a794137419c32854a653c3e71c78160
7
+ data.tar.gz: 020226ac91a091febf4039c3e0bde9adb0091163ec135f3f146b98a45d2c0b294788103294954cbaa18e3a48b2824969fe8db6f002a15d539d363c271de6e93a
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .DS_Store
5
6
  .rspec
6
7
  .yardoc
7
8
  Gemfile.lock
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## v0.4.0, 12 May 2016
2
+
3
+ - BREAKING: target v2 of the Onfido API. To continue using v1, specify this
4
+ version in `Onfido.configure`
5
+ - Add `api_version` configuration option
6
+ (see https://github.com/hvssle/onfido#configuration)
7
+ - Add support for `Onfido::LivePhoto` resource
8
+
1
9
  ## v0.3.0, 16 March 2016
2
10
 
3
11
  - Add support for `Onfido::Webhook` resource
data/README.md CHANGED
@@ -1,13 +1,11 @@
1
1
  # Onfido
2
2
 
3
- A wrapper for Onfido's [API](https://onfido.com/documentation#introduction). You should always refer to the documentation for valid API calls.
3
+ A thin wrapper for Onfido's API.
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/onfido.svg)](http://badge.fury.io/rb/onfido)
6
6
  [![Build Status](https://travis-ci.org/hvssle/onfido.svg?branch=master)](https://travis-ci.org/hvssle/onfido)
7
7
 
8
-
9
- [1]: https://gitter.im/hvssle/onfido
10
- [2]: https://badges.gitter.im/gitterHQ/developers.png
8
+ This gem supports both `v1` and `v2` of the Onfido API. Refer to Onfido's [API documentation](https://onfido.com/documentation#introduction) for details of the expected requests and responses for both.
11
9
 
12
10
  ## Installation
13
11
 
@@ -17,134 +15,117 @@ Add this line to your application's Gemfile:
17
15
  gem 'onfido'
18
16
  ```
19
17
 
20
- And then execute:
21
-
22
- $ bundle
23
-
24
- Or install it yourself as:
18
+ ## Configuration
25
19
 
26
- $ gem install onfido
27
-
28
-
29
- ## Usage
30
-
31
- There are 4 configuration options for Onfido, including your `api_key`, timeout details and logging.
20
+ There are 5 configuration options:
32
21
 
33
22
  ```ruby
34
- Onfido.configure do |config|
35
- config.api_key = 'MY_API_KEY'
36
- config.logger = Logger.new(STDOUT)
37
- config.open_timeout = 30
38
- config.read_timeout = 80
39
- end
23
+ Onfido.configure do |config|
24
+ config.api_key = 'MY_API_KEY'
25
+ config.api_version = 'v2'
26
+ config.logger = Logger.new(STDOUT)
27
+ config.open_timeout = 30
28
+ config.read_timeout = 80
29
+ end
40
30
  ```
41
31
 
42
- Assuming you have a valid key, you can conveniently make API calls by using an instance of the `API` class.
32
+ ## Usage
33
+
34
+ You can make API calls by using an instance of the `API` class:
43
35
 
44
36
  ```ruby
45
- api = Onfido::API.new
37
+ api = Onfido::API.new
46
38
  ```
47
39
 
48
- ### Making calls to Onfido's resources
40
+ ### Resources
49
41
 
50
- All resources share the same interface when making API calls. For creating a resource you can use `.create`, for finding one `.find` and for fetching all records for a resource `.all`.
42
+ All resources share the same interface when making API calls. Use `.create` to create a resource, `.find` to find one, and `.all` to fetch all resources.
51
43
 
52
44
  **Note:** *All param keys should be a symbol e.g. `{ type: 'express', reports: [{ name: 'identity' }] }`*
53
45
 
46
+ #### Applicants
54
47
 
55
- ### Applicant
56
-
57
- To create an applicant, you can simply use
48
+ Applicants are the object upon which Onfido checks are performed.
58
49
 
59
50
  ```ruby
60
- api.applicant.create(params)
51
+ api.applicant.create(params) # => Creates an applicant
52
+ api.applicant.find('applicant_id') # => Finds a single applicant
53
+ api.applicant.all # => Returns all applicants
61
54
  ```
62
55
 
63
- To find an existing applicant
64
-
65
- ```ruby
66
- api.applicant.find('applicant_id')
67
- ```
56
+ #### Documents
68
57
 
69
- To get all applicants
58
+ Documents provide supporting evidence for Onfido checks. They can only be
59
+ created - the Onfido does not support finding or listing them.
70
60
 
71
61
  ```ruby
72
- api.applicant.all
62
+ api.document.create('applicant_id', file: 'http://example.com', type: 'passport')
73
63
  ```
74
64
 
75
- ### Document
65
+ **Note:** The file parameter can be either a `File` object or a link to an image.
76
66
 
77
- To upload a document for an applicant, you can simply use
67
+ #### Live Photos
78
68
 
79
- ```ruby
80
- api.document.create('applicant_id', file: 'http://example.com', type: 'passport')
81
- ```
82
-
83
- The file can both be a `File` object or a link to an image.
84
-
85
- ### Check
86
-
87
- To create a check for an applicant, you can simply use
69
+ Live Photos, like documents, can provide supporting evidence for Onfido checks.
70
+ They can only be created - the Onfido does not support finding or listing them.
88
71
 
89
72
  ```ruby
90
- api.check.create('applicant_id', type: 'express', reports: [{ name: 'identity' }])
73
+ api.live_photo.create('applicant_id', file: 'http://example.com')
91
74
  ```
92
75
 
93
- To find an existing check for an applicant
76
+ **Note:** The file parameter can be either a `File` object or a link to an image.
94
77
 
95
- ```ruby
96
- api.check.find('applicant_id', 'check_id')
97
- ```
78
+ #### Checks
98
79
 
99
- To get all checks for an applicant
80
+ Checks are requests for Onfido to check an applicant, by commissioning one or
81
+ more "reports" on them.
100
82
 
101
83
  ```ruby
102
- api.check.all('applicant_id')
84
+ api.check.create('applicant_id', type: 'express', reports: [{ name: 'identity' }])
85
+ api.check.find('applicant_id', 'check_id')
86
+ api.check.all('applicant_id')
103
87
  ```
104
88
 
105
- ### Report
89
+ #### Reports
106
90
 
107
- To find an existing report for a check
91
+ Reports provide details of the results of some part of a "check". They are
92
+ created when a check is created, so the Onfido API only provides support for
93
+ finding and listing them.
108
94
 
109
95
  ```ruby
110
- api.report.find('check_id', 'report_id')
96
+ api.report.find('check_id', 'report_id')
97
+ api.report.all('check_id')
111
98
  ```
112
99
 
113
- To get all reports for a check
100
+ #### Address Lookups
101
+
102
+ Onfido provides an address lookup service, to help ensure well-formatted
103
+ addresses are provided when creating "applicants". To search for addresses
104
+ by postcode, use:
114
105
 
115
106
  ```ruby
116
- api.report.all('check_id')
107
+ api.address.all('SE1 4NG')
117
108
  ```
118
109
 
119
- ### Address Picker
110
+ #### Webhook Endpoints
120
111
 
121
- To search for addresses by postcode
112
+ Onfido allows you to set up and view your webhook endpoints via the API, as well
113
+ as through the dashboard.
122
114
 
123
115
  ```ruby
124
- api.address.all('SE1 4NG')
116
+ api.webhook.create(params) # => Creates a webhook endpoint
117
+ api.webhook.find('webhook_id') # => Finds a single webhook endpoint
118
+ api.webhook.all # => Returns all webhook endpoints
125
119
  ```
126
120
 
127
121
  ### Pagination
128
122
 
129
- Currently, you can paginate over the *applicant* and *check* resources. However, since you can only create 1 check per applicant therefore paginating on the check resource might prove impractical.
130
-
131
- By default, both endpoints are fetching records the first 20 records. That is the maximum amount of records you can request per page.
132
-
133
- To paginate over *applicants*:
134
- ```ruby
135
- api = Onfido::API.new
136
- api.applicant.all(page: 2, per_page: 10)
137
- ```
138
-
139
- To paginate over *checks*:
140
- ```
141
- api = Onfido::API.new
142
- api.check.all('applicant_id', page: 2, per_page: 10)
143
- ```
123
+ All resources that support an `all` method also support pagination. By default,
124
+ the first 20 records are fetched.
144
125
 
145
- ## Error Handling
126
+ ### Error Handling
146
127
 
147
- There are three classes of errors raised by the library, all of which subclass `Onfido::Error`.
128
+ There are three classes of errors raised by the library, all of which subclass `Onfido::Error`:
148
129
  - `Onfido::ServerError` is raised whenever Onfido returns a `5xx` response
149
130
  - `Onfido::RequestError` is raised whenever Onfido returns any other kind of error
150
131
  - `Onfido::ConnectionError` is raised whenever a network error occurs (e.g., a timeout)
@@ -152,20 +133,20 @@ There are three classes of errors raised by the library, all of which subclass `
152
133
  All three error classes provide the `response_code`, `response_body`, `json_body`, `type` and `fields` of the error (although for `Onfido::ServerError` and `Onfido::ConnectionError` the last three are likely to be `nil`).
153
134
 
154
135
  ```ruby
155
- def create_applicant
156
- api.applicant.create(params)
157
- rescue Onfido::RequestError => e
158
- e.type # => 'validation_error'
159
- e.fields # => { "email": { "messages": ["invalid format"] } }
160
- e.response_code # => '422'
161
- end
136
+ def create_applicant
137
+ api.applicant.create(params)
138
+ rescue Onfido::RequestError => e
139
+ e.type # => 'validation_error'
140
+ e.fields # => { "email": { "messages": ["invalid format"] } }
141
+ e.response_code # => '422'
142
+ end
162
143
  ```
163
144
 
164
- ### Roadmap
145
+ ## Roadmap
165
146
 
166
147
  - Improve test coverage with more scenarios
167
- - Add custom errors based on the response code.
168
- - Improve documentation
148
+ - Add custom errors based on the response code
149
+ - Improve pagination handling (use information passed in link header)
169
150
 
170
151
  ## Contributing
171
152
 
@@ -1,6 +1,6 @@
1
1
  module Onfido
2
2
  module Configuration
3
- attr_accessor :api_key, :open_timeout, :read_timeout
3
+ attr_accessor :api_key, :open_timeout, :read_timeout, :api_version
4
4
 
5
5
  def self.extended(base)
6
6
  base.reset
@@ -14,6 +14,7 @@ module Onfido
14
14
  self.api_key = nil
15
15
  self.open_timeout = 30
16
16
  self.read_timeout = 80
17
+ self.api_version = 'v2'
17
18
  RestClient.log = nil
18
19
  end
19
20
 
@@ -30,7 +31,7 @@ module Onfido
30
31
  end
31
32
 
32
33
  def endpoint
33
- 'https://api.onfido.com/v1/'
34
+ "https://api.onfido.com/#{api_version}/"
34
35
  end
35
36
  end
36
37
  end
@@ -11,7 +11,7 @@ module Onfido
11
11
  make_request(
12
12
  method: method.to_sym,
13
13
  url: args.first.fetch(:url),
14
- payload: build_query(args.first.fetch(:payload))
14
+ payload: build_query(args.first.fetch(:payload, {}))
15
15
  )
16
16
  end
17
17
  end
@@ -35,14 +35,14 @@ module Onfido
35
35
  response = RestClient::Request.execute(request_options)
36
36
 
37
37
  parse(response)
38
- rescue RestClient::ExceptionWithResponse => e
39
- if e.response
40
- handle_api_error(e.response)
38
+ rescue RestClient::ExceptionWithResponse => error
39
+ if error.response
40
+ handle_api_error(error.response)
41
41
  else
42
- handle_restclient_error(e, url)
42
+ handle_restclient_error(error, url)
43
43
  end
44
- rescue RestClient::Exception, Errno::ECONNREFUSED => e
45
- handle_restclient_error(e, url)
44
+ rescue RestClient::Exception, Errno::ECONNREFUSED => error
45
+ handle_restclient_error(error, url)
46
46
  end
47
47
 
48
48
  def parse(response)
@@ -97,13 +97,13 @@ module Onfido
97
97
  )
98
98
  end
99
99
 
100
- def handle_restclient_error(e, url)
100
+ def handle_restclient_error(error, url)
101
101
  connection_message =
102
102
  "Please check your internet connection and try again. " \
103
103
  "If this problem persists, you should let us know at info@onfido.com."
104
104
 
105
105
  message =
106
- case e
106
+ case error
107
107
  when RestClient::RequestTimeout
108
108
  "Could not connect to Onfido (#{url}). #{connection_message}"
109
109
 
@@ -127,7 +127,7 @@ module Onfido
127
127
  "If this problem persists, let us know at info@onfido.com."
128
128
  end
129
129
 
130
- full_message = message + "\n\n(Network error: #{e.message})"
130
+ full_message = message + "\n\n(Network error: #{error.message})"
131
131
 
132
132
  raise ConnectionError.new(full_message)
133
133
  end
File without changes
@@ -0,0 +1,15 @@
1
+ module Onfido
2
+ class Applicant < Resource
3
+ def create(payload)
4
+ post(url: url_for('applicants'), payload: payload)
5
+ end
6
+
7
+ def find(applicant_id)
8
+ get(url: url_for("applicants/#{applicant_id}"))
9
+ end
10
+
11
+ def all(page: 1, per_page: 20)
12
+ get(url: url_for("applicants?page=#{page}&per_page=#{per_page}"))
13
+ end
14
+ end
15
+ end
@@ -8,18 +8,12 @@ module Onfido
8
8
  end
9
9
 
10
10
  def find(applicant_id, check_id)
11
- get(
12
- url: url_for("applicants/#{applicant_id}/checks/#{check_id}"),
13
- payload: {}
14
- )
11
+ get(url: url_for("applicants/#{applicant_id}/checks/#{check_id}"))
15
12
  end
16
13
 
17
14
  def all(applicant_id, page: 1, per_page: 20)
18
15
  querystring = "page=#{page}&per_page=#{per_page}"
19
- get(
20
- url: url_for("applicants/#{applicant_id}/checks?#{querystring}"),
21
- payload: {}
22
- )
16
+ get(url: url_for("applicants/#{applicant_id}/checks?#{querystring}"))
23
17
  end
24
18
  end
25
19
  end
File without changes
@@ -0,0 +1,13 @@
1
+ module Onfido
2
+ class LivePhoto < Resource
3
+ # with open-uri the file can be a link or an actual file
4
+
5
+ def create(applicant_id, payload)
6
+ payload[:file] = open(payload.fetch(:file), 'r')
7
+ post(
8
+ url: url_for("applicants/#{applicant_id}/live_photos"),
9
+ payload: payload
10
+ )
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Onfido
2
+ class Report < Resource
3
+ def find(check_id, report_id)
4
+ get(url: url_for("checks/#{check_id}/reports/#{report_id}"))
5
+ end
6
+
7
+ def all(check_id, page: 1, per_page: 20)
8
+ querystring = "page=#{page}&per_page=#{per_page}"
9
+ get(url: url_for("checks/#{check_id}/reports?#{querystring}"))
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ module Onfido
2
+ class Webhook < Resource
3
+ def create(payload)
4
+ post(
5
+ url: url_for('webhooks'),
6
+ payload: payload
7
+ )
8
+ end
9
+
10
+ def find(webhooks_id)
11
+ get(url: url_for("webhooks/#{webhooks_id}"))
12
+ end
13
+
14
+ def all(page: 1, per_page: 20)
15
+ get(url: url_for("webhooks?page=#{page}&per_page=#{per_page}"))
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Onfido
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
data/lib/onfido.rb CHANGED
@@ -10,14 +10,15 @@ require 'onfido/errors/request_error'
10
10
  require 'onfido/errors/server_error'
11
11
  require 'onfido/errors/connection_error'
12
12
  require 'onfido/null_logger'
13
- require 'onfido/resource'
14
- require 'onfido/address'
15
- require 'onfido/applicant'
16
- require 'onfido/document'
17
- require 'onfido/check'
18
- require 'onfido/report'
19
- require 'onfido/webhook'
20
13
  require 'onfido/api'
14
+ require 'onfido/resource'
15
+ require 'onfido/resources/address'
16
+ require 'onfido/resources/applicant'
17
+ require 'onfido/resources/check'
18
+ require 'onfido/resources/document'
19
+ require 'onfido/resources/live_photo'
20
+ require 'onfido/resources/report'
21
+ require 'onfido/resources/webhook'
21
22
 
22
23
  module Onfido
23
24
  extend Configuration
@@ -43,7 +43,7 @@ describe Onfido::Applicant do
43
43
 
44
44
  it 'serializes the payload correctly' do
45
45
  WebMock.after_request do |request_signature, _response|
46
- if request_signature.uri.path == 'v1/applicants'
46
+ if request_signature.uri.path == 'v2/applicants'
47
47
  expect(Rack::Utils.parse_nested_query(request_signature.body)).
48
48
  to eq(params)
49
49
  end
@@ -0,0 +1,22 @@
1
+ require 'tempfile'
2
+
3
+ describe Onfido::LivePhoto do
4
+ subject(:live_photo) { described_class.new }
5
+
6
+ describe '#create' do
7
+ after do
8
+ file.close
9
+ file.unlink
10
+ end
11
+
12
+ let(:file) { Tempfile.new(['photo', '.jpg']) }
13
+ before { allow(live_photo).to receive(:open).and_return(:file) }
14
+ let(:params) { { file: file } }
15
+ let(:applicant_id) { '1030303-123123-123123' }
16
+
17
+ it 'creates a new photo' do
18
+ response = live_photo.create('foobar', params)
19
+ expect(response['id']).not_to be_nil
20
+ end
21
+ end
22
+ end
@@ -25,6 +25,15 @@ describe Onfido::Webhook do
25
25
  end
26
26
  end
27
27
 
28
+ describe '#find' do
29
+ let(:webhook_id) { 'fcb73186-0733-4f6f-9c57-d9d5ef979443' }
30
+
31
+ it 'returns the webhook' do
32
+ response = webhook.find(webhook_id)
33
+ expect(response['id']).to eq(webhook_id)
34
+ end
35
+ end
36
+
28
37
  describe "#all" do
29
38
  it "returns all the registered webhooks" do
30
39
  response = webhook.all
@@ -1,6 +1,6 @@
1
1
  describe Onfido::Resource do
2
2
  subject(:resource) { described_class.new }
3
- let(:endpoint) { 'https://api.onfido.com/v1/' }
3
+ let(:endpoint) { 'https://api.onfido.com/v2/' }
4
4
  let(:path) { 'addresses/pick' }
5
5
  let(:api_key) { 'some_key' }
6
6
 
data/spec/onfido_spec.rb CHANGED
@@ -1,9 +1,8 @@
1
1
  describe Onfido do
2
2
  subject(:onfido) { described_class }
3
+ after(:each) { onfido.reset }
3
4
 
4
5
  context 'configuration' do
5
- before { onfido.reset }
6
-
7
6
  describe "default values" do
8
7
  describe ".api_key" do
9
8
  subject { onfido.api_key }
@@ -12,7 +11,7 @@ describe Onfido do
12
11
 
13
12
  describe ".endpoint" do
14
13
  subject { onfido.endpoint }
15
- it { is_expected.to eq('https://api.onfido.com/v1/') }
14
+ it { is_expected.to eq('https://api.onfido.com/v2/') }
16
15
  end
17
16
 
18
17
  describe ".logger" do
@@ -28,6 +27,14 @@ describe Onfido do
28
27
  end
29
28
  end
30
29
 
30
+ describe "setting the API version" do
31
+ it 'changes the configuration to the new value' do
32
+ onfido.api_version = 'v1'
33
+ expect(onfido.api_version).to eq('v1')
34
+ expect(onfido.endpoint).to eq('https://api.onfido.com/v1/')
35
+ end
36
+ end
37
+
31
38
  describe '.logger' do
32
39
  context 'when an option is passed' do
33
40
  context 'when the option passed behaves like a logger' do
@@ -1,66 +1,73 @@
1
1
  require 'sinatra/base'
2
2
 
3
3
  class FakeOnfidoAPI < Sinatra::Base
4
- get '/v1/addresses/pick' do
4
+ get '/v2/addresses/pick' do
5
5
  json_response(200, 'addresses.json')
6
6
  end
7
7
 
8
- post '/v1/applicants' do
8
+ post '/v2/applicants' do
9
9
  json_response(201, 'applicant.json')
10
10
  end
11
11
 
12
- get '/v1/applicants/:id' do
12
+ get '/v2/applicants/:id' do
13
13
  json_response(200, 'applicant.json')
14
14
  end
15
15
 
16
- get '/v1/applicants' do
16
+ get '/v2/applicants' do
17
17
  response = json_response(200, 'applicants.json')
18
18
  { applicants: JSON.parse(response)['applicants'][pagination_range] }.to_json
19
19
  end
20
20
 
21
- post '/v1/applicants/:id/documents' do
21
+ post '/v2/applicants/:id/documents' do
22
22
  json_response(201, 'document.json')
23
23
  end
24
24
 
25
- post '/v1/applicants/:id/checks' do
25
+ post '/v2/applicants/:id/live_photos' do
26
+ json_response(201, 'live_photo.json')
27
+ end
28
+
29
+ post '/v2/applicants/:id/checks' do
26
30
  json_response(201, 'check.json')
27
31
  end
28
32
 
29
- get '/v1/applicants/:id/checks/:id' do
33
+ get '/v2/applicants/:id/checks/:id' do
30
34
  json_response(200, 'check.json')
31
35
  end
32
36
 
33
- get '/v1/applicants/:id/checks' do
37
+ get '/v2/applicants/:id/checks' do
34
38
  response = json_response(200, 'checks.json')
35
39
  { checks: JSON.parse(response)['checks'][pagination_range] }.to_json
36
40
  end
37
41
 
38
- get '/v1/checks/:id/reports' do
42
+ get '/v2/checks/:id/reports' do
39
43
  json_response(200, 'reports.json')
40
44
  end
41
45
 
42
- get '/v1/checks/:id/reports/:id' do
46
+ get '/v2/checks/:id/reports/:id' do
43
47
  json_response(200, 'report.json')
44
48
  end
45
49
 
46
- post '/v1/webhooks' do
50
+ post '/v2/webhooks' do
47
51
  json_response(201, 'webhook.json')
48
52
  end
49
53
 
50
- get '/v1/webhooks' do
51
- json_response(200, 'webhooks.json')
54
+ get '/v2/webhooks/:id' do
55
+ json_response(200, 'webhook.json')
52
56
  end
53
57
 
58
+ get '/v2/webhooks' do
59
+ json_response(200, 'webhooks.json')
60
+ end
54
61
 
55
- get '/v1/4xx_response' do
62
+ get '/v2/4xx_response' do
56
63
  json_response(422, '4xx_response.json')
57
64
  end
58
65
 
59
- get '/v1/unexpected_error_format' do
66
+ get '/v2/unexpected_error_format' do
60
67
  json_response(400, 'unexpected_error_format.json')
61
68
  end
62
69
 
63
- get '/v1/unparseable_response' do
70
+ get '/v2/unparseable_response' do
64
71
  content_type :json
65
72
  status 504
66
73
  ''
@@ -11,7 +11,7 @@
11
11
  "telephone":"555555555",
12
12
  "mobile":"77777777",
13
13
  "country":"gbr",
14
- "href":"/v1/applicants/61f659cb-c90b-4067-808a-6136b5c01351",
14
+ "href":"/v2/applicants/61f659cb-c90b-4067-808a-6136b5c01351",
15
15
  "id_numbers":[],
16
16
  "addresses": [
17
17
  {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "8546921-123123-123123",
3
3
  "created_at": "2014-05-23T13:50:33Z",
4
- "href": "/v1/applicants/61f659cb-c90b-4067-808a-6136b5c01351/checks/8546921-123123-123123",
4
+ "href": "/v2/applicants/61f659cb-c90b-4067-808a-6136b5c01351/checks/8546921-123123-123123",
5
5
  "type": "standard",
6
6
  "status": "pending",
7
7
  "result": "pending",
@@ -12,7 +12,7 @@
12
12
  "created_at": "2014-05-23T13:50:33Z",
13
13
  "status": "awaiting_applicant",
14
14
  "result": "pending",
15
- "href": "/v1/checks/8546921-123123-123123/reports/6951786-123123-422221",
15
+ "href": "/v2/checks/8546921-123123-123123/reports/6951786-123123-422221",
16
16
  "breakdown": {},
17
17
  "properties": {}
18
18
  },
@@ -22,7 +22,7 @@
22
22
  "created_at": "2014-05-23T13:50:33Z",
23
23
  "status": "awaiting_applicant",
24
24
  "result": "pending",
25
- "href": "/v1/checks/8546921-123123-123123/reports/6951786-123123-316712",
25
+ "href": "/v2/checks/8546921-123123-123123/reports/6951786-123123-316712",
26
26
  "breakdown": {},
27
27
  "properties": {}
28
28
  }
@@ -3,7 +3,7 @@
3
3
  {
4
4
  "id": "8546921-123123-123123",
5
5
  "created_at": "2014-05-23T13:50:33Z",
6
- "href": "/v1/applicants/61f659cb-c90b-4067-808a-6136b5c01351/checks/8546921-123123-123123",
6
+ "href": "/v2/applicants/61f659cb-c90b-4067-808a-6136b5c01351/checks/8546921-123123-123123",
7
7
  "type": "standard",
8
8
  "status": "pending",
9
9
  "result": "pending",
@@ -14,7 +14,7 @@
14
14
  "created_at": "2014-05-23T13:50:33Z",
15
15
  "status": "awaiting_applicant",
16
16
  "result": "pending",
17
- "href": "/v1/checks/8546921-123123-123123/reports/6951786-123123-422221",
17
+ "href": "/v2/checks/8546921-123123-123123/reports/6951786-123123-422221",
18
18
  "breakdown": {},
19
19
  "properties": {}
20
20
  },
@@ -24,7 +24,7 @@
24
24
  "created_at": "2014-05-23T13:50:33Z",
25
25
  "status": "awaiting_applicant",
26
26
  "result": "pending",
27
- "href": "/v1/checks/8546921-123123-123123/reports/6951786-123123-316712",
27
+ "href": "/v2/checks/8546921-123123-123123/reports/6951786-123123-316712",
28
28
  "breakdown": {},
29
29
  "properties": {}
30
30
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "7568415-123123-123123",
3
3
  "created_at": "2014-05-23 13:50:33Z",
4
- "href": "/v1/applicants/1030303-123123-123123/documents/7568415-123123-123123",
4
+ "href": "/v2/applicants/1030303-123123-123123/documents/7568415-123123-123123",
5
5
  "file_name": "passport.jpg",
6
6
  "file_type": "png",
7
7
  "file_size": 282870,
@@ -0,0 +1,4 @@
1
+ {
2
+ "id": "7410A943-8F00-43D8-98DE-36A774196D86",
3
+ "created_at": "2014-05-23 13:50:33Z"
4
+ }
@@ -4,7 +4,7 @@
4
4
  "created_at": "2014-05-23T13:50:33Z",
5
5
  "status": "awaiting_applicant",
6
6
  "result": "pending",
7
- "href": "/v1/checks/8546921-123123-123123/reports/6951786-123123-422221",
7
+ "href": "/v2/checks/8546921-123123-123123/reports/6951786-123123-422221",
8
8
  "breakdown": {},
9
9
  "properties": {}
10
10
  }
@@ -6,7 +6,7 @@
6
6
  "created_at": "2014-05-23T13:50:33Z",
7
7
  "status": "awaiting_applicant",
8
8
  "result": "pending",
9
- "href": "/v1/checks/8546921-123123-123123/reports/6951786-123123-422221",
9
+ "href": "/v2/checks/8546921-123123-123123/reports/6951786-123123-422221",
10
10
  "breakdown": {},
11
11
  "properties": {}
12
12
  },
@@ -16,7 +16,7 @@
16
16
  "created_at": "2014-05-23T13:50:33Z",
17
17
  "status": "awaiting_applicant",
18
18
  "result": "pending",
19
- "href": "/v1/checks/8546921-123123-123123/reports/6951786-123123-316712",
19
+ "href": "/v2/checks/8546921-123123-123123/reports/6951786-123123-316712",
20
20
  "breakdown": {},
21
21
  "properties": {}
22
22
  }
@@ -3,7 +3,7 @@
3
3
  "url": "https://webhookendpoint.url",
4
4
  "token": "yV85IsmuYwmjQGlZ",
5
5
  "enabled": true,
6
- "href": "/v1/webhooks/fcb73186-0733-4f6f-9c57-d9d5ef979443",
6
+ "href": "/v2/webhooks/fcb73186-0733-4f6f-9c57-d9d5ef979443",
7
7
  "events": [
8
8
  "report completion",
9
9
  "report withdrawal",
@@ -3,7 +3,7 @@
3
3
  {
4
4
  "id": "dd0a89e4-d44e-417a-aec4-01137d01ae59",
5
5
  "url": "https://demo.com","enabled":false,
6
- "href": "/v1/webhooks/dd0a89e4-d44e-417a-aec4-01137d01ae59",
6
+ "href": "/v2/webhooks/dd0a89e4-d44e-417a-aec4-01137d01ae59",
7
7
  "events":
8
8
  [
9
9
  "check in progress"
@@ -13,7 +13,7 @@
13
13
  "id": "bfc727a8-f7bf-4073-b123-ed70a70f58e5",
14
14
  "url": "https://demo2.com",
15
15
  "enabled": true,
16
- "href": "/v1/webhooks/bfc727a8-f7bf-4073-b123-ed70a70f58e5",
16
+ "href": "/v2/webhooks/bfc727a8-f7bf-4073-b123-ed70a70f58e5",
17
17
  "events":
18
18
  [
19
19
  "report completion",
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.3.0
4
+ version: 0.4.0
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: 2016-03-16 00:00:00.000000000 Z
12
+ date: 2016-05-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -141,27 +141,29 @@ files:
141
141
  - README.md
142
142
  - Rakefile
143
143
  - lib/onfido.rb
144
- - lib/onfido/address.rb
145
144
  - lib/onfido/api.rb
146
- - lib/onfido/applicant.rb
147
- - lib/onfido/check.rb
148
145
  - lib/onfido/configuration.rb
149
- - lib/onfido/document.rb
150
146
  - lib/onfido/errors/connection_error.rb
151
147
  - lib/onfido/errors/onfido_error.rb
152
148
  - lib/onfido/errors/request_error.rb
153
149
  - lib/onfido/errors/server_error.rb
154
150
  - lib/onfido/null_logger.rb
155
- - lib/onfido/report.rb
156
151
  - lib/onfido/resource.rb
152
+ - lib/onfido/resources/address.rb
153
+ - lib/onfido/resources/applicant.rb
154
+ - lib/onfido/resources/check.rb
155
+ - lib/onfido/resources/document.rb
156
+ - lib/onfido/resources/live_photo.rb
157
+ - lib/onfido/resources/report.rb
158
+ - lib/onfido/resources/webhook.rb
157
159
  - lib/onfido/version.rb
158
- - lib/onfido/webhook.rb
159
160
  - onfido.gemspec
160
161
  - spec/integrations/address_spec.rb
161
162
  - spec/integrations/applicant_spec.rb
162
163
  - spec/integrations/check_spec.rb
163
164
  - spec/integrations/document_spec.rb
164
165
  - spec/integrations/exceptions_spec.rb
166
+ - spec/integrations/live_photo_spec.rb
165
167
  - spec/integrations/report_spec.rb
166
168
  - spec/integrations/webhook_spec.rb
167
169
  - spec/onfido/connection_error_spec.rb
@@ -177,6 +179,7 @@ files:
177
179
  - spec/support/fixtures/check.json
178
180
  - spec/support/fixtures/checks.json
179
181
  - spec/support/fixtures/document.json
182
+ - spec/support/fixtures/live_photo.json
180
183
  - spec/support/fixtures/report.json
181
184
  - spec/support/fixtures/reports.json
182
185
  - spec/support/fixtures/unexpected_error_format.json
@@ -212,6 +215,7 @@ test_files:
212
215
  - spec/integrations/check_spec.rb
213
216
  - spec/integrations/document_spec.rb
214
217
  - spec/integrations/exceptions_spec.rb
218
+ - spec/integrations/live_photo_spec.rb
215
219
  - spec/integrations/report_spec.rb
216
220
  - spec/integrations/webhook_spec.rb
217
221
  - spec/onfido/connection_error_spec.rb
@@ -227,6 +231,7 @@ test_files:
227
231
  - spec/support/fixtures/check.json
228
232
  - spec/support/fixtures/checks.json
229
233
  - spec/support/fixtures/document.json
234
+ - spec/support/fixtures/live_photo.json
230
235
  - spec/support/fixtures/report.json
231
236
  - spec/support/fixtures/reports.json
232
237
  - spec/support/fixtures/unexpected_error_format.json
@@ -1,21 +0,0 @@
1
- module Onfido
2
- class Applicant < Resource
3
- def create(payload)
4
- post(
5
- url: url_for('applicants'),
6
- payload: payload
7
- )
8
- end
9
-
10
- def find(applicant_id)
11
- get(url: url_for("applicants/#{applicant_id}"), payload: {})
12
- end
13
-
14
- def all(page: 1, per_page: 20)
15
- get(
16
- url: url_for("applicants?page=#{page}&per_page=#{per_page}"),
17
- payload: {}
18
- )
19
- end
20
- end
21
- end
data/lib/onfido/report.rb DELETED
@@ -1,11 +0,0 @@
1
- module Onfido
2
- class Report < Resource
3
- def find(check_id, report_id)
4
- get(url: url_for("checks/#{check_id}/reports/#{report_id}"), payload: {})
5
- end
6
-
7
- def all(check_id)
8
- get(url: url_for("checks/#{check_id}/reports"), payload: {})
9
- end
10
- end
11
- end
@@ -1,18 +0,0 @@
1
- module Onfido
2
- class Webhook < Resource
3
- def create(payload)
4
- post(
5
- url: url_for('webhooks'),
6
- payload: payload
7
- )
8
- end
9
-
10
- def all
11
- get(
12
- url: url_for("webhooks"),
13
- payload: {}
14
- )
15
- end
16
-
17
- end
18
- end