-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(onfido API): Add support for monitors * refactor(version): Bump to 2.6.0 * refactor(monitor spec): Remove unnecessary Tempfile require * refactor(fixtures): Add missing new lines
- Loading branch information
1 parent
665d462
commit f51d65e
Showing
9 changed files
with
114 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module Onfido | ||
class Monitor < Resource | ||
def create(applicant_id:, report_name:, **payload) | ||
payload[:applicant_id] = applicant_id | ||
payload[:report_name] = report_name | ||
|
||
post(path: 'watchlist_monitors', payload: payload) | ||
end | ||
|
||
def find(monitor_id) | ||
get(path: "watchlist_monitors/#{monitor_id}") | ||
end | ||
|
||
def all(applicant_id) | ||
get(path: "watchlist_monitors?applicant_id=#{applicant_id}") | ||
end | ||
|
||
def destroy(monitor_id) | ||
delete(path: "watchlist_monitors/#{monitor_id}") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Onfido | ||
VERSION = '2.5.0' | ||
VERSION = '2.6.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
describe Onfido::Monitor do | ||
include_context 'fake onfido api' | ||
|
||
subject(:monitor) { onfido.monitor } | ||
|
||
let(:monitor_id) { '2748c4fc-c6b8-4c1e-a383-21efa241ce1e' } | ||
|
||
describe '#create' do | ||
let(:applicant_id) { '61f659cb-c90b-4067-808a-6136b5c01351' } | ||
let(:report_name) { 'watchlist_standard' } | ||
|
||
it 'creates a monitor for the applicant' do | ||
response = monitor.create(applicant_id: applicant_id, report_name: report_name) | ||
expect(response).to be_a(Hash).and include('id' => monitor_id, 'report_name' => report_name) | ||
end | ||
end | ||
|
||
describe '#find' do | ||
it 'returns the expected monitor' do | ||
response = monitor.find(monitor_id) | ||
|
||
expect(response).to be_a(Hash).and include('id' => monitor_id) | ||
end | ||
end | ||
|
||
describe '#all' do | ||
it 'returns a list of monitors' do | ||
applicant_id = '1030303-123123-123123' | ||
response = monitor.all(applicant_id) | ||
|
||
expect(response['monitors']).to be_an(Array).and contain_exactly(an_instance_of(Hash)) | ||
end | ||
end | ||
|
||
it 'returns success code' do | ||
expect { monitor.destroy(monitor_id) }.not_to raise_error | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": "2748c4fc-c6b8-4c1e-a383-21efa241ce1e", | ||
"report_name": "watchlist_standard", | ||
"created_at": "2022-09-01T15:01:36.921Z", | ||
"deleted_at": null, | ||
"sandbox": false, | ||
"tags": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"monitors": [ | ||
{ | ||
"id": "2748c4fc-c6b8-4c1e-a383-21efa241ce1e", | ||
"report_name": "watchlist_standard", | ||
"created_at": "2022-09-01T15:01:36.921Z", | ||
"deleted_at": null, | ||
"sandbox": false, | ||
"tags": [] | ||
} | ||
] | ||
} |