onfido 0.9.0 → 0.10.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 +4 -0
- data/README.md +4 -2
- data/lib/onfido/resources/live_photo.rb +15 -0
- data/lib/onfido/version.rb +1 -1
- data/spec/integrations/live_photo_spec.rb +29 -0
- data/spec/support/fake_onfido_api.rb +26 -0
- data/spec/support/fixtures/live_photo.json +7 -2
- data/spec/support/fixtures/live_photos.json +22 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3230fbefefe2fe6a65813be33aa6025503aebea8d2959290702d18874d265d0e
|
4
|
+
data.tar.gz: 12bcea5a6c837d30aa1c5ea9ba2e62c4d1d5a7d6c65824fbec55943d941f572c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e179be06571269bba33d62efb85523f26cd43a1df4b1f43dc90bf6b430c68d40d5140d6141686efcd90a5898a285ade72ac51a5215a48dd6115e5232e69658e
|
7
|
+
data.tar.gz: 15a6b1d68484a3174c8fabb49a4f097ba1c3f82766865707351eac513c7c617423468824758f976070bfd0a42f47cb78fdbc135d20984ecf1ec3bfde0f293c72
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## v0.10.0, 3 April 2018
|
2
|
+
|
3
|
+
- Add support for download, find and retrieve all for live_photo resource (@kirsis)
|
4
|
+
|
1
5
|
## v0.9.0, 8 March 2018
|
2
6
|
|
3
7
|
- Remove the ability to create Documents and Live Photos from a remote URL or local path, mitigating a potential security vulnerability (see #45 for details) (@timrogers)
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ This gem supports both `v1` and `v2` of the Onfido API. Refer to Onfido's [API d
|
|
12
12
|
Add this line to your application's Gemfile:
|
13
13
|
|
14
14
|
```ruby
|
15
|
-
gem 'onfido', '~> 0.
|
15
|
+
gem 'onfido', '~> 0.10.0'
|
16
16
|
```
|
17
17
|
|
18
18
|
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.
|
@@ -82,10 +82,12 @@ to `#create`.
|
|
82
82
|
#### Live Photos
|
83
83
|
|
84
84
|
Live Photos, like documents, can provide supporting evidence for Onfido checks.
|
85
|
-
They can only be created - the Onfido does not support finding or listing them.
|
86
85
|
|
87
86
|
```ruby
|
88
87
|
api.live_photo.create('applicant_id', file: 'http://example.com')
|
88
|
+
api.live_photo.find(applicant_id, live_photo_id) # => Finds a live photo
|
89
|
+
api.live_photo.download(applicant_id, live_photo_id) # => Downloads a live photo as binary data
|
90
|
+
api.live_photo.all(applicant_id) # => Returns all applicant's live photos
|
89
91
|
```
|
90
92
|
|
91
93
|
**Note:** The file parameter must be a `File`-like object which responds to `#read` and `#path`.
|
@@ -11,5 +11,20 @@ module Onfido
|
|
11
11
|
payload: payload
|
12
12
|
)
|
13
13
|
end
|
14
|
+
|
15
|
+
def find(applicant_id, live_photo_id)
|
16
|
+
query_string = "applicant_id=#{applicant_id}"
|
17
|
+
get(url: url_for("live_photos/#{live_photo_id}?#{query_string}"))
|
18
|
+
end
|
19
|
+
|
20
|
+
def download(applicant_id, live_photo_id)
|
21
|
+
query_string = "applicant_id=#{applicant_id}"
|
22
|
+
get(url: url_for("live_photos/#{live_photo_id}/download?#{query_string}"))
|
23
|
+
end
|
24
|
+
|
25
|
+
def all(applicant_id)
|
26
|
+
query_string = "applicant_id=#{applicant_id}"
|
27
|
+
get(url: url_for("live_photos?#{query_string}"))
|
28
|
+
end
|
14
29
|
end
|
15
30
|
end
|
data/lib/onfido/version.rb
CHANGED
@@ -29,4 +29,33 @@ describe Onfido::LivePhoto do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
describe '#find' do
|
34
|
+
let(:applicant_id) { '1030303-123123-123123' }
|
35
|
+
let(:live_photo_id) { '3538c8f6-fdce-4745-9d34-fc246bc05aa1' }
|
36
|
+
|
37
|
+
it 'returns the expected live photo' do
|
38
|
+
response = live_photo.find(applicant_id, live_photo_id)
|
39
|
+
expect(response['id']).to eq(live_photo_id)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#all' do
|
44
|
+
let(:applicant_id) { '1030303-123123-123123' }
|
45
|
+
|
46
|
+
it 'returns list of documents' do
|
47
|
+
response = live_photo.all(applicant_id)
|
48
|
+
expect(response['live_photos']).not_to be_empty
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '#download' do
|
53
|
+
let(:applicant_id) { '1030303-123123-123123' }
|
54
|
+
let(:live_photo_id) { '3538c8f6-fdce-4745-9d34-fc246bc05aa1' }
|
55
|
+
|
56
|
+
it 'returns the file data' do
|
57
|
+
response = live_photo.download(applicant_id, live_photo_id)
|
58
|
+
expect(response).not_to be_nil
|
59
|
+
end
|
60
|
+
end
|
32
61
|
end
|
@@ -48,6 +48,32 @@ class FakeOnfidoAPI < Sinatra::Base
|
|
48
48
|
json_response(201, 'live_photo.json')
|
49
49
|
end
|
50
50
|
|
51
|
+
get '/v2/live_photos/:id' do
|
52
|
+
if params["applicant_id"] != "1030303-123123-123123"
|
53
|
+
status 404
|
54
|
+
else
|
55
|
+
json_response(200, 'live_photo.json')
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
get '/v2/live_photos' do
|
60
|
+
if params["applicant_id"] != "1030303-123123-123123"
|
61
|
+
status 404
|
62
|
+
else
|
63
|
+
json_response(200, 'live_photos.json')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
get '/v2/live_photos/:id/download' do
|
68
|
+
if params["applicant_id"] != "1030303-123123-123123"
|
69
|
+
status 404
|
70
|
+
else
|
71
|
+
status 200
|
72
|
+
content_type 'image/jpeg'
|
73
|
+
"\x01\x02\x03" # acts as binary file data
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
51
77
|
post '/v2/applicants/:id/checks' do
|
52
78
|
json_response(201, 'check.json')
|
53
79
|
end
|
@@ -1,4 +1,9 @@
|
|
1
1
|
{
|
2
|
-
"id": "
|
3
|
-
"created_at": "2014-05-23 13:50:33Z"
|
2
|
+
"id": "3538c8f6-fdce-4745-9d34-fc246bc05aa1",
|
3
|
+
"created_at": "2014-05-23 13:50:33Z",
|
4
|
+
"file_name": "onfido_captured_image.jpg",
|
5
|
+
"file_type": "image/jpeg",
|
6
|
+
"file_size": 47544,
|
7
|
+
"href": "/v2/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1",
|
8
|
+
"download_href": "/v2/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1/download"
|
4
9
|
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"live_photos": [
|
3
|
+
{
|
4
|
+
"id": "3538c8f6-fdce-4745-9d34-fc246bc05aa1",
|
5
|
+
"created_at": "2014-05-23 13:50:33Z",
|
6
|
+
"file_name": "onfido_captured_image.jpg",
|
7
|
+
"file_type": "image/jpeg",
|
8
|
+
"file_size": 47544,
|
9
|
+
"href": "/v2/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1",
|
10
|
+
"download_href": "/v2/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1/download"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"id": "5134c12a-555a-1234-5e12-9d34fcbc11ba",
|
14
|
+
"created_at": "2014-05-23 13:50:33Z",
|
15
|
+
"file_name": "onfido_captured_image.jpg",
|
16
|
+
"file_type": "image/jpeg",
|
17
|
+
"file_size": 47544,
|
18
|
+
"href": "/v2/live_photos/5134c12a-555a-1234-5e12-9d34fcbc11ba",
|
19
|
+
"download_href": "/v2/live_photos/5134c12a-555a-1234-5e12-9d34fcbc11ba/download"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
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.
|
4
|
+
version: 0.10.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: 2018-03
|
12
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -204,6 +204,7 @@ files:
|
|
204
204
|
- spec/support/fixtures/document.json
|
205
205
|
- spec/support/fixtures/documents.json
|
206
206
|
- spec/support/fixtures/live_photo.json
|
207
|
+
- spec/support/fixtures/live_photos.json
|
207
208
|
- spec/support/fixtures/report.json
|
208
209
|
- spec/support/fixtures/report_type_group.json
|
209
210
|
- spec/support/fixtures/report_type_groups.json
|
@@ -265,6 +266,7 @@ test_files:
|
|
265
266
|
- spec/support/fixtures/document.json
|
266
267
|
- spec/support/fixtures/documents.json
|
267
268
|
- spec/support/fixtures/live_photo.json
|
269
|
+
- spec/support/fixtures/live_photos.json
|
268
270
|
- spec/support/fixtures/report.json
|
269
271
|
- spec/support/fixtures/report_type_group.json
|
270
272
|
- spec/support/fixtures/report_type_groups.json
|