From e216a7ee7920c01e5851a210b54af52bab5d3e99 Mon Sep 17 00:00:00 2001 From: Alan Carrie Date: Mon, 4 Feb 2019 15:24:13 +0000 Subject: [PATCH 1/3] fix linting errors --- lib/onfido/resources/check.rb | 4 ++-- spec/integrations/check_spec.rb | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/onfido/resources/check.rb b/lib/onfido/resources/check.rb index 17e8960..b57516c 100644 --- a/lib/onfido/resources/check.rb +++ b/lib/onfido/resources/check.rb @@ -14,9 +14,9 @@ def find(applicant_id, check_id, expand: nil) end def find_by_url(url, expand: nil) - url_path = url.sub(/^https\:\/\/api\.onfido\.com\/v2\//,'') + url_path = url.sub(%r/^https\:\/\/api\.onfido\.com\/v2\//, '') querystring = "&expand=#{expand}" if expand - get(url: url_for("#{url_path}?#{querystring}")) + get(url: url_for("#{url_path}?#{querystring}")) end def all(applicant_id, page: 1, per_page: 20, expand: nil) diff --git a/spec/integrations/check_spec.rb b/spec/integrations/check_spec.rb index 74b47d9..dd5411a 100644 --- a/spec/integrations/check_spec.rb +++ b/spec/integrations/check_spec.rb @@ -35,7 +35,7 @@ context 'partial url' do let(:url) { "applicants/#{applicant_id}/checks/#{check_id}" } - + it 'returns an existing check for the applicant with the partial url' do response = check.find_by_url(url) expect(response['id']).to eq(check_id) @@ -53,7 +53,9 @@ end context 'full url' do - let(:url) { "https://api.onfido.com/v2/applicants/#{applicant_id}/checks/#{check_id}" } + let(:url) do + "https://api.onfido.com/v2/applicants/#{applicant_id}/checks/#{check_id}" + end it 'returns an existing check for the applicant with the partial url' do response = check.find_by_url(url) From 296a0b44667167f42d0073d311a2186ef230949c Mon Sep 17 00:00:00 2001 From: Alan Carrie Date: Mon, 4 Feb 2019 15:28:40 +0000 Subject: [PATCH 2/3] update changelog, README and bump version --- CHANGELOG.md | 4 ++++ README.md | 3 ++- lib/onfido/version.rb | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9534aa2..4d3682c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## v0.15.0, 4 Feb 2019 + +- Add Check#find_by_url method (@ctrlaltdylan) + ## v0.14.0, 28 Jan 2019 - Add support for applicant deletion and restore endpoints diff --git a/README.md b/README.md index aa20cfa..002a83c 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This gem supports both `v1` and `v2` of the Onfido API. Refer to Onfido's [API d Add this line to your application's Gemfile: ```ruby -gem 'onfido', '~> 0.14.0' +gem 'onfido', '~> 0.15.0' ``` 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. @@ -117,6 +117,7 @@ more "reports" on them. ```ruby api.check.create('applicant_id', type: 'express', reports: [{ name: 'identity' }]) api.check.find('applicant_id', 'check_id') +api.check.find_by_url(params[:payload][:object][:href]) api.check.resume('check_id') api.check.all('applicant_id') ``` diff --git a/lib/onfido/version.rb b/lib/onfido/version.rb index 39139be..2cc6d78 100644 --- a/lib/onfido/version.rb +++ b/lib/onfido/version.rb @@ -1,3 +1,3 @@ module Onfido - VERSION = '0.14.0'.freeze + VERSION = '0.15.0'.freeze end From 2b28736e26e3213b034be162dd4166f5504c45e7 Mon Sep 17 00:00:00 2001 From: Alan Carrie Date: Mon, 4 Feb 2019 17:14:48 +0000 Subject: [PATCH 3/3] improve find_by_url README example --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 002a83c..9c18a4d 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ more "reports" on them. ```ruby api.check.create('applicant_id', type: 'express', reports: [{ name: 'identity' }]) api.check.find('applicant_id', 'check_id') -api.check.find_by_url(params[:payload][:object][:href]) +api.check.find_by_url('applicants/a90e7a17-677a-49ab-a171-281f96c77bde/checks/c9f41bef-0610-4d2f-9982-ae9387876edc') api.check.resume('check_id') api.check.all('applicant_id') ```