onfido 0.15.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/LICENSE +2 -1
- data/README.md +18 -32
- data/lib/onfido.rb +0 -1
- data/lib/onfido/api.rb +0 -4
- data/lib/onfido/configuration.rb +2 -3
- data/lib/onfido/resource.rb +1 -5
- data/lib/onfido/resources/address.rb +4 -2
- data/lib/onfido/resources/applicant.rb +6 -6
- data/lib/onfido/resources/check.rb +9 -19
- data/lib/onfido/resources/document.rb +11 -11
- data/lib/onfido/resources/live_photo.rb +9 -14
- data/lib/onfido/resources/live_video.rb +5 -8
- data/lib/onfido/resources/report.rb +8 -9
- data/lib/onfido/resources/sdk_token.rb +3 -5
- data/lib/onfido/resources/webhook.rb +7 -9
- data/lib/onfido/version.rb +1 -1
- data/onfido.gemspec +6 -6
- data/spec/integrations/address_spec.rb +1 -0
- data/spec/integrations/applicant_spec.rb +18 -36
- data/spec/integrations/check_spec.rb +13 -67
- data/spec/integrations/document_spec.rb +16 -17
- data/spec/integrations/exceptions_spec.rb +12 -13
- data/spec/integrations/live_photo_spec.rb +12 -13
- data/spec/integrations/live_video_spec.rb +7 -10
- data/spec/integrations/report_spec.rb +11 -13
- data/spec/integrations/sdk_token_spec.rb +5 -5
- data/spec/integrations/webhook_spec.rb +26 -18
- data/spec/onfido/resource_spec.rb +6 -12
- data/spec/onfido_spec.rb +3 -11
- data/spec/support/fake_onfido_api.rb +44 -78
- data/spec/support/fixtures/applicant.json +21 -42
- data/spec/support/fixtures/check.json +4 -4
- data/spec/support/fixtures/checks.json +4 -4
- data/spec/support/fixtures/document.json +2 -2
- data/spec/support/fixtures/documents.json +8 -8
- data/spec/support/fixtures/live_photo.json +3 -3
- data/spec/support/fixtures/live_photos.json +6 -6
- data/spec/support/fixtures/live_video.json +3 -3
- data/spec/support/fixtures/live_videos.json +4 -4
- data/spec/support/fixtures/report.json +4 -4
- data/spec/support/fixtures/reports.json +8 -8
- data/spec/support/fixtures/webhook.json +6 -5
- data/spec/support/fixtures/webhooks.json +17 -12
- metadata +11 -24
- data/lib/onfido/resources/report_type_group.rb +0 -11
- data/spec/integrations/report_type_group_spec.rb +0 -19
- data/spec/support/fixtures/check_with_expanded_reports.json +0 -30
- data/spec/support/fixtures/checks_with_expanded_reports.json +0 -34
- data/spec/support/fixtures/report_type_group.json +0 -25
- data/spec/support/fixtures/report_type_groups.json +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c2b7ace145ea9b4804afb24664f452851753bb15dca4221e94c43cf1db6f96e
|
4
|
+
data.tar.gz: c0477b41310dc691e99a218d03a40777c5e91d3e1cc72d90884f9d6d01772a3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 598a9e0fcf166be224cf0b28dd0f8ca92f8e285ac3955d7ff06ad450bd018741ce580f99de6e506100f879ef5002e485926fec8d741d7bb313d496486f4ffb48
|
7
|
+
data.tar.gz: 1786150e8f9b3d8d7b1bec8aad0ff35565c77e3000c70534757aec49ae85fff9c15deb398e53d2676337b3ff9432a25ed48a690833112304ad91d249ae82f550
|
data/CHANGELOG.md
CHANGED
data/LICENSE
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2015 Hassle
|
3
|
+
Original work Copyright (c) 2015 Hassle
|
4
|
+
Modified work Copyright 2019 Onfido
|
4
5
|
|
5
6
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
7
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -3,28 +3,30 @@
|
|
3
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
|
-
[![Build Status](https://travis-ci.org/
|
6
|
+
[![Build Status](https://travis-ci.org/onfido/onfido-ruby.svg?branch=master)](https://travis-ci.org/onfido/onfido-ruby)
|
7
|
+
|
8
|
+
This gem supports only `v3` of Onfido's API from version `1.0.0` ownards.
|
9
|
+
The latest version that supports `v2` of Onfido's API is `0.15.0`. `v1` of Onfido's API is deprecated
|
10
|
+
Refer to Onfido's [API documentation](https://documentation.onfido.com) for details of the expected requests and responses.
|
7
11
|
|
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.
|
9
12
|
|
10
13
|
## Installation
|
11
14
|
|
12
15
|
Add this line to your application's Gemfile:
|
13
16
|
|
14
17
|
```ruby
|
15
|
-
gem 'onfido', '~> 0.
|
18
|
+
gem 'onfido', '~> 1.0.0'
|
16
19
|
```
|
17
20
|
|
18
21
|
The gem is compatible with Ruby 2.2.0 and onwards. Earlier versions of Ruby have [reached end-of-life](https://www.ruby-lang.org/en/news/2017/04/01/support-of-ruby-2-1-has-ended/), are no longer supported and no longer receive security fixes.
|
19
22
|
|
20
23
|
## Configuration
|
21
24
|
|
22
|
-
There are
|
25
|
+
There are 5 configuration options:
|
23
26
|
|
24
27
|
```ruby
|
25
28
|
Onfido.configure do |config|
|
26
29
|
config.api_key = 'MY_API_KEY'
|
27
|
-
config.api_version = 'v2'
|
28
30
|
config.logger = Logger.new(STDOUT)
|
29
31
|
config.open_timeout = 30
|
30
32
|
config.read_timeout = 80
|
@@ -59,7 +61,7 @@ api = Onfido::API.new(api_key: 'API_KEY')
|
|
59
61
|
|
60
62
|
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.
|
61
63
|
|
62
|
-
**Note:** *All param keys should be a symbol e.g. `{
|
64
|
+
**Note:** *All param keys should be a symbol e.g. `{ report_names: ['document'] }`*
|
63
65
|
|
64
66
|
#### Applicants
|
65
67
|
|
@@ -83,8 +85,8 @@ Documents provide supporting evidence for Onfido checks.
|
|
83
85
|
|
84
86
|
```ruby
|
85
87
|
api.document.create('applicant_id', file: 'http://example.com', type: 'passport') # => Creates a document
|
86
|
-
api.document.find('
|
87
|
-
api.document.download('
|
88
|
+
api.document.find('document_id') # => Finds a document
|
89
|
+
api.document.download('document_id') # => Downloads a document as a binary data
|
88
90
|
api.document.all('applicant_id') # => Returns all applicant's documents
|
89
91
|
```
|
90
92
|
|
@@ -99,8 +101,8 @@ Live Photos, like documents, can provide supporting evidence for Onfido checks.
|
|
99
101
|
|
100
102
|
```ruby
|
101
103
|
api.live_photo.create('applicant_id', file: 'http://example.com')
|
102
|
-
api.live_photo.find(
|
103
|
-
api.live_photo.download(
|
104
|
+
api.live_photo.find(live_photo_id) # => Finds a live photo
|
105
|
+
api.live_photo.download(live_photo_id) # => Downloads a live photo as binary data
|
104
106
|
api.live_photo.all(applicant_id) # => Returns all applicant's live photos
|
105
107
|
```
|
106
108
|
|
@@ -115,9 +117,8 @@ Checks are requests for Onfido to check an applicant, by commissioning one or
|
|
115
117
|
more "reports" on them.
|
116
118
|
|
117
119
|
```ruby
|
118
|
-
api.check.create('applicant_id',
|
119
|
-
api.check.find('
|
120
|
-
api.check.find_by_url('applicants/a90e7a17-677a-49ab-a171-281f96c77bde/checks/c9f41bef-0610-4d2f-9982-ae9387876edc')
|
120
|
+
api.check.create('applicant_id', report_names: ['document'])
|
121
|
+
api.check.find('check_id')
|
121
122
|
api.check.resume('check_id')
|
122
123
|
api.check.all('applicant_id')
|
123
124
|
```
|
@@ -130,20 +131,10 @@ finding and listing them. For paused reports specifically, additional support fo
|
|
130
131
|
cancelling reports is also available.
|
131
132
|
|
132
133
|
```ruby
|
133
|
-
api.report.find('
|
134
|
+
api.report.find('report_id')
|
134
135
|
api.report.all('check_id')
|
135
|
-
api.report.resume('
|
136
|
-
api.report.cancel('
|
137
|
-
```
|
138
|
-
|
139
|
-
#### Report Type Groups
|
140
|
-
|
141
|
-
Report type groups provide a convenient way to group and organize different types of reports.
|
142
|
-
The Onfido API only provides support for finding and listing them.
|
143
|
-
|
144
|
-
```ruby
|
145
|
-
api.report_type_group.find('report_type_group_id')
|
146
|
-
api.report_type_group.all()
|
136
|
+
api.report.resume('report_id')
|
137
|
+
api.report.cancel('report_id')
|
147
138
|
```
|
148
139
|
|
149
140
|
#### Address Lookups
|
@@ -176,11 +167,6 @@ with Onfido's [JavaScript SDK](https://github.com/onfido/onfido-sdk-ui).
|
|
176
167
|
api.sdk_token.create(applicant_id: 'applicant_id', referrer: 'referrer')
|
177
168
|
```
|
178
169
|
|
179
|
-
### Pagination
|
180
|
-
|
181
|
-
All resources that support an `all` method also support pagination. By default,
|
182
|
-
the first 20 records are fetched.
|
183
|
-
|
184
170
|
### Error Handling
|
185
171
|
|
186
172
|
There are three classes of errors raised by the library, all of which subclass `Onfido::OnfidoError`:
|
@@ -224,7 +210,7 @@ end
|
|
224
210
|
|
225
211
|
## Contributing
|
226
212
|
|
227
|
-
1. Fork it ( https://github.com/
|
213
|
+
1. Fork it ( https://github.com/onfido/onfido/fork )
|
228
214
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
229
215
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
230
216
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/onfido.rb
CHANGED
@@ -19,7 +19,6 @@ require 'onfido/resources/document'
|
|
19
19
|
require 'onfido/resources/live_photo'
|
20
20
|
require 'onfido/resources/live_video'
|
21
21
|
require 'onfido/resources/report'
|
22
|
-
require 'onfido/resources/report_type_group'
|
23
22
|
require 'onfido/resources/sdk_token'
|
24
23
|
require 'onfido/resources/webhook'
|
25
24
|
|
data/lib/onfido/api.rb
CHANGED
data/lib/onfido/configuration.rb
CHANGED
@@ -4,7 +4,7 @@ module Onfido
|
|
4
4
|
us: "api.us.onfido.com"
|
5
5
|
}.freeze
|
6
6
|
|
7
|
-
attr_accessor :api_key, :region, :open_timeout, :read_timeout
|
7
|
+
attr_accessor :api_key, :region, :open_timeout, :read_timeout
|
8
8
|
|
9
9
|
def self.extended(base)
|
10
10
|
base.reset
|
@@ -19,7 +19,6 @@ module Onfido
|
|
19
19
|
self.region = nil
|
20
20
|
self.open_timeout = 30
|
21
21
|
self.read_timeout = 80
|
22
|
-
self.api_version = 'v2'
|
23
22
|
RestClient.log = nil
|
24
23
|
end
|
25
24
|
|
@@ -41,7 +40,7 @@ module Onfido
|
|
41
40
|
raise "The region \"#{region.downcase}\" is not currently supported"
|
42
41
|
end
|
43
42
|
|
44
|
-
"https://#{region_host}
|
43
|
+
"https://#{region_host}/v3/"
|
45
44
|
end
|
46
45
|
end
|
47
46
|
end
|
data/lib/onfido/resource.rb
CHANGED
@@ -7,15 +7,11 @@ module Onfido
|
|
7
7
|
@api_key = api_key || Onfido.api_key
|
8
8
|
end
|
9
9
|
|
10
|
-
def url_for(path)
|
11
|
-
Onfido.endpoint + path
|
12
|
-
end
|
13
|
-
|
14
10
|
VALID_HTTP_METHODS.each do |method|
|
15
11
|
define_method method do |*args|
|
16
12
|
make_request(
|
17
13
|
method: method.to_sym,
|
18
|
-
url: args.first.fetch(:
|
14
|
+
url: Onfido.endpoint + args.first.fetch(:path),
|
19
15
|
payload: build_query(args.first.fetch(:payload, {}))
|
20
16
|
)
|
21
17
|
end
|
@@ -1,8 +1,10 @@
|
|
1
1
|
module Onfido
|
2
2
|
class Address < Resource
|
3
3
|
def all(postcode)
|
4
|
-
|
5
|
-
|
4
|
+
get(
|
5
|
+
path: 'addresses/pick',
|
6
|
+
payload: { postcode: postcode.delete(' ') }
|
7
|
+
)
|
6
8
|
end
|
7
9
|
end
|
8
10
|
end
|
@@ -1,27 +1,27 @@
|
|
1
1
|
module Onfido
|
2
2
|
class Applicant < Resource
|
3
3
|
def create(payload)
|
4
|
-
post(
|
4
|
+
post(path: 'applicants', payload: payload)
|
5
5
|
end
|
6
6
|
|
7
7
|
def update(applicant_id, payload)
|
8
|
-
put(
|
8
|
+
put(path: "applicants/#{applicant_id}", payload: payload)
|
9
9
|
end
|
10
10
|
|
11
11
|
def destroy(applicant_id)
|
12
|
-
delete(
|
12
|
+
delete(path: "applicants/#{applicant_id}")
|
13
13
|
end
|
14
14
|
|
15
15
|
def find(applicant_id)
|
16
|
-
get(
|
16
|
+
get(path: "applicants/#{applicant_id}")
|
17
17
|
end
|
18
18
|
|
19
19
|
def all(page: 1, per_page: 20)
|
20
|
-
get(
|
20
|
+
get(path: "applicants?page=#{page}&per_page=#{per_page}")
|
21
21
|
end
|
22
22
|
|
23
23
|
def restore(applicant_id)
|
24
|
-
post(
|
24
|
+
post(path: "applicants/#{applicant_id}/restore")
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,32 +1,22 @@
|
|
1
1
|
module Onfido
|
2
2
|
class Check < Resource
|
3
|
-
def create(applicant_id
|
4
|
-
|
5
|
-
|
6
|
-
payload: payload
|
7
|
-
)
|
8
|
-
end
|
3
|
+
def create(applicant_id:, report_names:, **payload)
|
4
|
+
payload[:applicant_id] = applicant_id
|
5
|
+
payload[:report_names] = report_names
|
9
6
|
|
10
|
-
|
11
|
-
querystring = "&expand=#{expand}" if expand
|
12
|
-
get(url: url_for("applicants/#{applicant_id}/checks/#{check_id}?" \
|
13
|
-
"#{querystring}"))
|
7
|
+
post(path: 'checks', payload: payload)
|
14
8
|
end
|
15
9
|
|
16
|
-
def
|
17
|
-
|
18
|
-
querystring = "&expand=#{expand}" if expand
|
19
|
-
get(url: url_for("#{url_path}?#{querystring}"))
|
10
|
+
def find(check_id)
|
11
|
+
get(path: "checks/#{check_id}")
|
20
12
|
end
|
21
13
|
|
22
|
-
def all(applicant_id
|
23
|
-
|
24
|
-
querystring += "&expand=#{expand}" if expand
|
25
|
-
get(url: url_for("applicants/#{applicant_id}/checks?#{querystring}"))
|
14
|
+
def all(applicant_id)
|
15
|
+
get(path: "checks?applicant_id=#{applicant_id}")
|
26
16
|
end
|
27
17
|
|
28
18
|
def resume(check_id)
|
29
|
-
post(
|
19
|
+
post(path: "checks/#{check_id}/resume")
|
30
20
|
end
|
31
21
|
end
|
32
22
|
end
|
@@ -2,25 +2,25 @@ module Onfido
|
|
2
2
|
class Document < Resource
|
3
3
|
# with open-uri the file can be a link or an actual file
|
4
4
|
|
5
|
-
def create(applicant_id
|
6
|
-
validate_file!(
|
5
|
+
def create(applicant_id:, file:, type:, **payload)
|
6
|
+
validate_file!(file)
|
7
|
+
payload[:applicant_id] = applicant_id
|
8
|
+
payload[:file] = file
|
9
|
+
payload[:type] = type
|
7
10
|
|
8
|
-
post(
|
9
|
-
url: url_for("applicants/#{applicant_id}/documents"),
|
10
|
-
payload: payload
|
11
|
-
)
|
11
|
+
post(path: 'documents', payload: payload)
|
12
12
|
end
|
13
13
|
|
14
|
-
def find(
|
15
|
-
get(
|
14
|
+
def find(document_id)
|
15
|
+
get(path: "documents/#{document_id}")
|
16
16
|
end
|
17
17
|
|
18
|
-
def download(
|
19
|
-
get(
|
18
|
+
def download(document_id)
|
19
|
+
get(path: "documents/#{document_id}/download")
|
20
20
|
end
|
21
21
|
|
22
22
|
def all(applicant_id)
|
23
|
-
get(
|
23
|
+
get(path: "documents?applicant_id=#{applicant_id}")
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -2,29 +2,24 @@ module Onfido
|
|
2
2
|
class LivePhoto < Resource
|
3
3
|
# with open-uri the file can be a link or an actual file
|
4
4
|
|
5
|
-
def create(applicant_id
|
6
|
-
validate_file!(
|
5
|
+
def create(applicant_id:, file:, **payload)
|
6
|
+
validate_file!(file)
|
7
7
|
payload[:applicant_id] = applicant_id
|
8
|
+
payload[:file] = file
|
8
9
|
|
9
|
-
post(
|
10
|
-
url: url_for("/live_photos"),
|
11
|
-
payload: payload
|
12
|
-
)
|
10
|
+
post(path: 'live_photos', payload: payload)
|
13
11
|
end
|
14
12
|
|
15
|
-
def find(
|
16
|
-
|
17
|
-
get(url: url_for("live_photos/#{live_photo_id}?#{query_string}"))
|
13
|
+
def find(live_photo_id)
|
14
|
+
get(path: "live_photos/#{live_photo_id}")
|
18
15
|
end
|
19
16
|
|
20
|
-
def download(
|
21
|
-
|
22
|
-
get(url: url_for("live_photos/#{live_photo_id}/download?#{query_string}"))
|
17
|
+
def download(live_photo_id)
|
18
|
+
get(path: "live_photos/#{live_photo_id}/download")
|
23
19
|
end
|
24
20
|
|
25
21
|
def all(applicant_id)
|
26
|
-
|
27
|
-
get(url: url_for("live_photos?#{query_string}"))
|
22
|
+
get(path: "live_photos?applicant_id=#{applicant_id}")
|
28
23
|
end
|
29
24
|
end
|
30
25
|
end
|
@@ -1,18 +1,15 @@
|
|
1
1
|
module Onfido
|
2
2
|
class LiveVideo < Resource
|
3
|
-
def find(
|
4
|
-
|
5
|
-
get(url: url_for("live_videos/#{live_video_id}?#{query_string}"))
|
3
|
+
def find(live_video_id)
|
4
|
+
get(path: "live_videos/#{live_video_id}")
|
6
5
|
end
|
7
6
|
|
8
|
-
def download(
|
9
|
-
|
10
|
-
get(url: url_for("live_videos/#{live_video_id}/download?#{query_string}"))
|
7
|
+
def download(live_video_id)
|
8
|
+
get(path: "live_videos/#{live_video_id}/download")
|
11
9
|
end
|
12
10
|
|
13
11
|
def all(applicant_id)
|
14
|
-
|
15
|
-
get(url: url_for("live_videos?#{query_string}"))
|
12
|
+
get(path: "live_videos?applicant_id=#{applicant_id}")
|
16
13
|
end
|
17
14
|
end
|
18
15
|
end
|
@@ -1,20 +1,19 @@
|
|
1
1
|
module Onfido
|
2
2
|
class Report < Resource
|
3
|
-
def find(
|
4
|
-
get(
|
3
|
+
def find(report_id)
|
4
|
+
get(path: "reports/#{report_id}")
|
5
5
|
end
|
6
6
|
|
7
|
-
def all(check_id
|
8
|
-
|
9
|
-
get(url: url_for("checks/#{check_id}/reports?#{querystring}"))
|
7
|
+
def all(check_id)
|
8
|
+
get(path: "reports?check_id=#{check_id}")
|
10
9
|
end
|
11
10
|
|
12
|
-
def resume(
|
13
|
-
post(
|
11
|
+
def resume(report_id)
|
12
|
+
post(path: "reports/#{report_id}/resume")
|
14
13
|
end
|
15
14
|
|
16
|
-
def cancel(
|
17
|
-
post(
|
15
|
+
def cancel(report_id)
|
16
|
+
post(path: "reports/#{report_id}/cancel")
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module Onfido
|
2
2
|
class SdkToken < Resource
|
3
|
-
def create(payload)
|
4
|
-
|
5
|
-
|
6
|
-
payload: payload
|
7
|
-
)
|
3
|
+
def create(applicant_id:, **payload)
|
4
|
+
payload[:applicant_id] = applicant_id
|
5
|
+
post(path: 'sdk_token', payload: payload)
|
8
6
|
end
|
9
7
|
end
|
10
8
|
end
|