Skip to content

Commit

Permalink
Merge pull request #33 from onfido/release/v3.3
Browse files Browse the repository at this point in the history
Support for API v3.3
  • Loading branch information
Phoebe-B authored Mar 2, 2022
2 parents cd60cda + dcb5aea commit be7f709
Show file tree
Hide file tree
Showing 20 changed files with 67 additions and 63 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v2.2.0, 02 March 2022

- Support Onfido API version 3.3

## v2.1.1, 01 February 2022

- Send params as json
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The official Ruby library for integrating with the Onfido API.

Documentation can be found at https://documentation.onfido.com

This version uses Onfido API v3.2 and is compatible with Ruby 2.4 onwards. Refer to our [API versioning guide](https://developers.onfido.com/guide/api-versioning-policy#client-libraries) for details of which client library versions use which versions of the API.
This version uses Onfido API v3.3 and is compatible with Ruby 2.4 onwards. Refer to our [API versioning guide](https://developers.onfido.com/guide/api-versioning-policy#client-libraries) for details of which client library versions use which versions of the API.

## Installation

Expand Down
2 changes: 1 addition & 1 deletion lib/onfido/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def rest_client
attr_reader :api_key, :open_timeout, :read_timeout

def base_url
@unknown_api_url || "https://api.#{@region}.onfido.com/v3.2/"
@unknown_api_url || "https://api.#{@region}.onfido.com/v3.3/"
end
end
end
2 changes: 1 addition & 1 deletion lib/onfido/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Onfido
VERSION = '2.1.1'
VERSION = '2.2.0'
end
2 changes: 1 addition & 1 deletion spec/integrations/applicant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

it 'serializes the payload correctly' do
WebMock.after_request do |request_signature, _response|
if request_signature.uri.path == 'v3.2/applicants'
if request_signature.uri.path == 'v3.3/applicants'
expect(Rack::Utils.parse_nested_query(request_signature.body))
.to eq(params)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/onfido/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
end

it 'configures with region' do
expect(rest_client.url).to eq 'https://api.us.onfido.com/v3.2/'
expect(rest_client.url).to eq 'https://api.us.onfido.com/v3.3/'
end

it 'configures with timeouts' do
Expand Down
72 changes: 36 additions & 36 deletions spec/support/fake_onfido_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,168 +19,168 @@ class FakeOnfidoAPI < Sinatra::Base # rubocop:disable Metrics/ClassLength
end
end

get '/v3.2/addresses/pick' do
get '/v3.3/addresses/pick' do
json_response(200, 'addresses.json')
end

post '/v3.2/applicants' do
post '/v3.3/applicants' do
json_response(201, 'applicant.json')
end

put '/v3.2/applicants/:id' do
put '/v3.3/applicants/:id' do
json_response(200, 'applicant.json')
end

get '/v3.2/applicants/:id' do
get '/v3.3/applicants/:id' do
json_response(200, 'applicant.json')
end

get '/v3.2/applicants' do
get '/v3.3/applicants' do
response = json_response(200, 'applicants.json')
{ applicants: JSON.parse(response)['applicants'][pagination_range] }.to_json
end

delete '/v3.2/applicants/:id' do
delete '/v3.3/applicants/:id' do
status 204
end

post '/v3.2/applicants/:id/restore' do
post '/v3.3/applicants/:id/restore' do
if params['id'] == 'a2fb9c62-ab10-4898-a8ec-342c4b552ad5'
json_response(422, 'not_scheduled_for_deletion_error.json')
else
status 204
end
end

post '/v3.2/documents' do
post '/v3.3/documents' do
json_response(201, 'document.json')
end

post '/v3.2/extractions' do
post '/v3.3/extractions' do
json_response(201, 'extraction.json')
end

get '/v3.2/documents/:id' do
get '/v3.3/documents/:id' do
json_response(200, 'document.json')
end

get '/v3.2/documents' do
get '/v3.3/documents' do
json_response(200, 'documents.json')
end

get '/v3.2/documents/:id/download' do
get '/v3.3/documents/:id/download' do
status 200
content_type 'application/octet-stream'
"\x01\x02\x03" # acts as binary file data
end

post '/v3.2/live_photos' do
post '/v3.3/live_photos' do
json_response(201, 'live_photo.json')
end

get '/v3.2/live_photos/:id' do
get '/v3.3/live_photos/:id' do
json_response(200, 'live_photo.json')
end

get '/v3.2/live_photos' do
get '/v3.3/live_photos' do
if params['applicant_id'] == '1030303-123123-123123'
json_response(200, 'live_photos.json')
else
status 404
end
end

get '/v3.2/live_photos/:id/download' do
get '/v3.3/live_photos/:id/download' do
status 200
content_type 'image/jpeg'
"\x01\x02\x03" # acts as binary file data
end

get '/v3.2/live_videos/:id' do
get '/v3.3/live_videos/:id' do
json_response(200, 'live_video.json')
end

get '/v3.2/live_videos' do
get '/v3.3/live_videos' do
if params['applicant_id'] == '1030303-123123-123123'
json_response(200, 'live_videos.json')
else
status 404
end
end

get '/v3.2/live_videos/:id/download' do
get '/v3.3/live_videos/:id/download' do
status 200
content_type 'video/quicktime'
"\x01\x02\x03" # acts as binary file data
end

post '/v3.2/checks' do
post '/v3.3/checks' do
params['applicant_id'].nil? ? status(422) : json_response(201, 'check.json')
end

get '/v3.2/checks/:id' do
get '/v3.3/checks/:id' do
json_response(200, 'check.json')
end

get '/v3.2/checks' do
get '/v3.3/checks' do
json_response(200, 'checks.json')
end

post '/v3.2/checks/:id/resume' do
post '/v3.3/checks/:id/resume' do
status 204 # no_content
end

get '/v3.2/checks/:id/download' do
get '/v3.3/checks/:id/download' do
status 200
content_type 'application/pdf'
"\x01\x02\x03" # acts as binary file data
end

get '/v3.2/reports' do
get '/v3.3/reports' do
json_response(200, 'reports.json')
end

get '/v3.2/reports/:id' do
get '/v3.3/reports/:id' do
json_response(200, 'report.json')
end

post '/v3.2/reports/:id/resume' do
post '/v3.3/reports/:id/resume' do
status 204
end

post '/v3.2/reports/:id/cancel' do
post '/v3.3/reports/:id/cancel' do
status 204
end

post '/v3.2/sdk_token' do
post '/v3.3/sdk_token' do
json_response(201, 'sdk_token.json')
end

post '/v3.2/webhooks' do
post '/v3.3/webhooks' do
json_response(201, 'webhook.json')
end

get '/v3.2/webhooks/:id' do
get '/v3.3/webhooks/:id' do
json_response(200, 'webhook.json')
end

delete '/v3.2/webhooks/:id' do
delete '/v3.3/webhooks/:id' do
status 204
end

get '/v3.2/webhooks' do
get '/v3.3/webhooks' do
json_response(200, 'webhooks.json')
end

get '/v3.2/4xx_response' do
get '/v3.3/4xx_response' do
json_response(422, '4xx_response.json')
end

get '/v3.2/unexpected_error_format' do
get '/v3.3/unexpected_error_format' do
json_response(400, 'unexpected_error_format.json')
end

get '/v3.2/unparseable_response' do
get '/v3.3/unparseable_response' do
content_type :json
status 504
''
Expand Down
2 changes: 1 addition & 1 deletion spec/support/fixtures/applicant.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"last_name":"Bing",
"email":"chandler_bing_6@friends.com",
"dob":"1968-04-08",
"href":"/v3.2/applicants/61f659cb-c90b-4067-808a-6136b5c01351",
"href":"/v3.3/applicants/61f659cb-c90b-4067-808a-6136b5c01351",
"id_numbers":[],
"address": {
"flat_number":"4",
Expand Down
2 changes: 1 addition & 1 deletion spec/support/fixtures/check.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "8546921-123123-123123",
"created_at": "2019-05-23T13:50:33Z",
"href": "/v3.2/checks/8546921-123123-123123",
"href": "/v3.3/checks/8546921-123123-123123",
"applicant_provides_data": "false",
"status": "pending",
"result": "pending",
Expand Down
2 changes: 1 addition & 1 deletion spec/support/fixtures/checks.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"id": "8546921-123123-123123",
"created_at": "2019-11-23T13:50:33Z",
"href": "/v3.2/checks/8546921-123123-123123",
"href": "/v3.3/checks/8546921-123123-123123",
"applicant_provides_data": "false",
"status": "pending",
"result": "pending",
Expand Down
2 changes: 1 addition & 1 deletion spec/support/fixtures/document.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "7568415-123123-123123",
"created_at": "2019-11-23 13:50:33Z",
"href": "/v3.2/documents/7568415-123123-123123",
"href": "/v3.3/documents/7568415-123123-123123",
"file_name": "passport.jpg",
"file_type": "png",
"file_size": 282870,
Expand Down
4 changes: 2 additions & 2 deletions spec/support/fixtures/documents.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"id": "7568415-123123-123123",
"created_at": "2019-11-23 13:50:33Z",
"href": "/v3.2/documents/7568415-123123-123123",
"href": "/v3.3/documents/7568415-123123-123123",
"file_name": "passport.jpg",
"file_type": "png",
"file_size": 282870,
Expand All @@ -12,7 +12,7 @@
{
"id": "121122-123123-123123",
"created_at": "2019-11-23 13:50:40Z",
"href": "/v3.2/documents/7568415-123123-123123",
"href": "/v3.3/documents/7568415-123123-123123",
"file_name": "driving_licence.png",
"file_type": "png",
"file_size": 282870,
Expand Down
4 changes: 2 additions & 2 deletions spec/support/fixtures/live_photo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"file_name": "onfido_captured_image.jpg",
"file_type": "image/jpeg",
"file_size": 47544,
"href": "/v3.2/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1",
"download_href": "/v3.2/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1/download"
"href": "/v3.3/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1",
"download_href": "/v3.3/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1/download"
}
8 changes: 4 additions & 4 deletions spec/support/fixtures/live_photos.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"file_name": "onfido_captured_image.jpg",
"file_type": "image/jpeg",
"file_size": 47544,
"href": "/v3.2/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1",
"download_href": "/v3.2/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1/download"
"href": "/v3.3/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1",
"download_href": "/v3.3/live_photos/3538c8f6-fdce-4745-9d34-fc246bc05aa1/download"
},
{
"id": "5134c12a-555a-1234-5e12-9d34fcbc11ba",
"created_at": "2019-11-23 13:50:33Z",
"file_name": "onfido_captured_image.jpg",
"file_type": "image/jpeg",
"file_size": 47544,
"href": "/v3.2/live_photos/5134c12a-555a-1234-5e12-9d34fcbc11ba",
"download_href": "/v3.2/live_photos/5134c12a-555a-1234-5e12-9d34fcbc11ba/download"
"href": "/v3.3/live_photos/5134c12a-555a-1234-5e12-9d34fcbc11ba",
"download_href": "/v3.3/live_photos/5134c12a-555a-1234-5e12-9d34fcbc11ba/download"
}
]
}
4 changes: 2 additions & 2 deletions spec/support/fixtures/live_video.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
"file_name" : "output-29-05-2018_11_00_24.mov",
"file_type" : "video/quicktime",
"file_size" : 3348421,
"href" : "/v3.2/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01",
"download_href" : "/v3.2/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01/download"
"href" : "/v3.3/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01",
"download_href" : "/v3.3/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01/download"
}
4 changes: 2 additions & 2 deletions spec/support/fixtures/live_videos.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
}
],
"created_at": "2019-11-29T09:00:39Z",
"download_href": "/v3.2/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01/download",
"download_href": "/v3.3/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01/download",
"file_name": "output-29-11-2019_11_00_24.mov",
"file_size": 3348421,
"file_type": "video/quicktime",
"href": "/v3.2/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01",
"href": "/v3.3/live_videos/c9701e9b-83aa-442f-995b-20320ee8fb01",
"id": "c9701e9b-83aa-442f-995b-20320ee8fb01"
}
]
Expand Down
2 changes: 1 addition & 1 deletion spec/support/fixtures/report.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"created_at": "2019-11-23T13:50:45Z",
"status": "in_progress",
"result": "pending",
"href": "/v3.2/reports/6951786-123123-422221",
"href": "/v3.3/reports/6951786-123123-422221",
"breakdown": {},
"properties": {}
}
4 changes: 2 additions & 2 deletions spec/support/fixtures/reports.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"created_at": "2019-11-23T13:50:45Z",
"status": "in_progress",
"result": "pending",
"href": "/v3.2/reports/6951786-123123-422221",
"href": "/v3.3/reports/6951786-123123-422221",
"breakdown": {},
"properties": {}
},
Expand All @@ -16,7 +16,7 @@
"created_at": "2019-11-23T13:50:45Z",
"status": "in_progress",
"result": "pending",
"href": "/v3.2/reports/6951786-123123-316712",
"href": "/v3.3/reports/6951786-123123-316712",
"breakdown": {},
"properties": {}
}
Expand Down
2 changes: 1 addition & 1 deletion spec/support/fixtures/webhook.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"url": "https://webhookendpoint.url",
"token": "yV85IsmuYwmjQGlZ",
"enabled": true,
"href": "/v3.2/webhooks/fcb73186-0733-4f6f-9c57-d9d5ef979443",
"href": "/v3.3/webhooks/fcb73186-0733-4f6f-9c57-d9d5ef979443",
"environments": [
"live"
],
Expand Down
Loading

0 comments on commit be7f709

Please sign in to comment.