onfido 0.14.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/.travis.yml +3 -7
  4. data/CHANGELOG.md +21 -0
  5. data/LICENSE +2 -1
  6. data/README.md +59 -73
  7. data/lib/onfido.rb +1 -1
  8. data/lib/onfido/api.rb +4 -4
  9. data/lib/onfido/configuration.rb +4 -4
  10. data/lib/onfido/resource.rb +3 -6
  11. data/lib/onfido/resources/address.rb +1 -4
  12. data/lib/onfido/resources/applicant.rb +6 -6
  13. data/lib/onfido/resources/check.rb +10 -14
  14. data/lib/onfido/resources/document.rb +11 -11
  15. data/lib/onfido/resources/extraction.rb +9 -0
  16. data/lib/onfido/resources/live_photo.rb +9 -14
  17. data/lib/onfido/resources/live_video.rb +5 -8
  18. data/lib/onfido/resources/report.rb +8 -9
  19. data/lib/onfido/resources/sdk_token.rb +3 -5
  20. data/lib/onfido/resources/webhook.rb +11 -9
  21. data/lib/onfido/version.rb +1 -1
  22. data/onfido.gemspec +6 -7
  23. data/spec/integrations/address_spec.rb +1 -0
  24. data/spec/integrations/applicant_spec.rb +21 -37
  25. data/spec/integrations/check_spec.rb +13 -23
  26. data/spec/integrations/document_spec.rb +16 -17
  27. data/spec/integrations/exceptions_spec.rb +12 -14
  28. data/spec/integrations/extraction_spec.rb +19 -0
  29. data/spec/integrations/live_photo_spec.rb +12 -13
  30. data/spec/integrations/live_video_spec.rb +7 -10
  31. data/spec/integrations/report_spec.rb +11 -13
  32. data/spec/integrations/sdk_token_spec.rb +5 -5
  33. data/spec/integrations/webhook_spec.rb +35 -20
  34. data/spec/onfido/resource_spec.rb +10 -14
  35. data/spec/onfido_spec.rb +9 -10
  36. data/spec/support/fake_onfido_api.rb +53 -78
  37. data/spec/support/fixtures/applicant.json +21 -42
  38. data/spec/support/fixtures/check.json +4 -4
  39. data/spec/support/fixtures/checks.json +4 -4
  40. data/spec/support/fixtures/document.json +2 -2
  41. data/spec/support/fixtures/documents.json +8 -8
  42. data/spec/support/fixtures/extraction.json +23 -0
  43. data/spec/support/fixtures/live_photo.json +3 -3
  44. data/spec/support/fixtures/live_photos.json +6 -6
  45. data/spec/support/fixtures/live_video.json +3 -3
  46. data/spec/support/fixtures/live_videos.json +4 -4
  47. data/spec/support/fixtures/not_scheduled_for_deletion_error.json +7 -0
  48. data/spec/support/fixtures/report.json +4 -4
  49. data/spec/support/fixtures/reports.json +8 -8
  50. data/spec/support/fixtures/webhook.json +6 -5
  51. data/spec/support/fixtures/webhooks.json +17 -12
  52. metadata +19 -40
  53. data/lib/onfido/resources/report_type_group.rb +0 -11
  54. data/spec/integrations/report_type_group_spec.rb +0 -19
  55. data/spec/support/fixtures/check_with_expanded_reports.json +0 -30
  56. data/spec/support/fixtures/checks_with_expanded_reports.json +0 -34
  57. data/spec/support/fixtures/report_type_group.json +0 -25
  58. 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: 27279800cfff5a840ce97b9e8de9dc74a5083ea1c57f8a10b87e5bc2950f1067
4
- data.tar.gz: 922fdbde05fe24981a5e2cf6d6be173f6db0c8966521e07a7271c15df3849440
3
+ metadata.gz: 5402f96702de9c0251f8c92ac14739b1cf54ad9a5336cf63c7088e4cc45dc0ae
4
+ data.tar.gz: 89c7091cf1059f7eb4db9d96ae6c8ace2ca7176961524ba886b12ba3969cf462
5
5
  SHA512:
6
- metadata.gz: 0982bae64d5589a5909f03f92904445ea0f1912c554912a46893b61647756794522b11dbc46bb8e562712572c5459bd8f1a819e3e10d539bbbf6e5e7c077b5be
7
- data.tar.gz: 8b741438cefff280b5ad6c1c6a7db958910f78553fd3e7315943a00247b6badc993154991c6866242dd2342eb31f8bc937904672fd4a01594f5feb1f454664d0
6
+ metadata.gz: 6dce59eeee514ce3371b8c03367f7e2c772d26dfe57231b4f49c13a3073ca233b4089798ee7e3a7e451b2e0b7e64d035f7ee4307bb902876b160053107652664
7
+ data.tar.gz: 92dd31829e491e612556caaf098dba388d701dfade3e755625e2199d2fbb58eaa5f621f1bdc9b8a8c95adf4753b22bb740430933e7c6b4789ed9ff8388485d44
data/.rubocop.yml CHANGED
@@ -51,3 +51,7 @@ Layout/DotPosition:
51
51
  # Allow class and message or instance raises
52
52
  Style/RaiseArgs:
53
53
  Enabled: false
54
+
55
+ Lint/AmbiguousBlockAssociation:
56
+ Exclude:
57
+ - "spec/**/*"
data/.travis.yml CHANGED
@@ -1,17 +1,13 @@
1
1
  language: ruby
2
-
3
- matrix:
4
- allow_failures:
5
- - rvm: jruby
6
- - rvm: rbx-2
2
+ cache: bundler
7
3
 
8
4
  rvm:
9
5
  - 2.2
10
6
  - 2.3
11
7
  - 2.4
12
8
  - 2.5
13
- - jruby
14
- - rbx-2
9
+ - 2.6
10
+ - 2.7
15
11
 
16
12
  script:
17
13
  - bundle exec rubocop
data/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ ## v1.1.1, 12 March 2021
2
+
3
+ - Send the postcode in the query string for the address picker endpoint
4
+
5
+ ## v1.1.0, 14 Aug 2020
6
+
7
+ - Add User-Agent header
8
+ - Add support for CA region
9
+ - Add extractions endpoint
10
+ - Add webhook deletion endpoint
11
+
12
+ ## v1.0.0, 13 Jan 2020
13
+
14
+ - Support Onfido API version 3
15
+ - Drop support for Onfido API version 2
16
+ - To upgrade from 0.15.0 see the v2 to v3 migration [guide](https://developers.onfido.com/guide/v2-to-v3-migration-guide)
17
+
18
+ ## v0.15.0, 4 Feb 2019
19
+
20
+ - Add Check#find_by_url method (@ctrlaltdylan)
21
+
1
22
  ## v0.14.0, 28 Jan 2019
2
23
 
3
24
  - Add support for applicant deletion and restore endpoints
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,29 @@
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/hvssle/onfido.svg?branch=master)](https://travis-ci.org/hvssle/onfido)
6
+ [![Build Status](https://travis-ci.org/onfido/onfido-ruby.svg?branch=master)](https://travis-ci.org/onfido/onfido-ruby)
7
7
 
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.
8
+ This gem supports only `v3` of Onfido's API from version `1.0.0` onwards. The latest version that supports `v2` of Onfido's API is `0.15.0`. `v1` of Onfido's API is deprecated.
9
+
10
+ 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.
11
+
12
+ Refer to Onfido's [API documentation](https://documentation.onfido.com) for details of the expected requests and responses.
9
13
 
10
14
  ## Installation
11
15
 
12
16
  Add this line to your application's Gemfile:
13
17
 
14
18
  ```ruby
15
- gem 'onfido', '~> 0.13.0'
19
+ gem 'onfido', '~> 1.1.1'
16
20
  ```
17
21
 
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.
19
-
20
22
  ## Configuration
21
23
 
22
- There are 6 configuration options:
24
+ There are 5 configuration options:
23
25
 
24
26
  ```ruby
25
27
  Onfido.configure do |config|
26
- config.api_key = 'MY_API_KEY'
27
- config.api_version = 'v2'
28
+ config.api_key = '<YOUR_API_KEY>'
28
29
  config.logger = Logger.new(STDOUT)
29
30
  config.open_timeout = 30
30
31
  config.read_timeout = 80
@@ -39,6 +40,9 @@ The gem will use the default region if no region is specified.
39
40
  To specify the US region do:
40
41
  `config.region = :us`
41
42
 
43
+ To specify the CA region do:
44
+ `config.region = :ca`
45
+
42
46
  See https://documentation.onfido.com/#regions for supported regions.
43
47
 
44
48
  ## Usage
@@ -46,46 +50,46 @@ See https://documentation.onfido.com/#regions for supported regions.
46
50
  You can make API calls by using an instance of the `API` class:
47
51
 
48
52
  ```ruby
49
- api = Onfido::API.new
53
+ onfido = Onfido::API.new
50
54
  ```
51
55
 
52
- Alternatively, you can set an API key here instead of in the initializer:
56
+ You can also set an API key as follows, instead of in the initializer configuration:
53
57
 
54
58
  ```ruby
55
- api = Onfido::API.new(api_key: 'API_KEY')
59
+ onfido = Onfido::API.new(api_key: '<YOUR_API_KEY>')
56
60
  ```
57
61
 
58
62
  ### Resources
59
63
 
60
64
  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
65
 
62
- **Note:** *All param keys should be a symbol e.g. `{ type: 'express', reports: [{ name: 'identity' }] }`*
66
+ **Note:** *All param keys should be symbols e.g. `{ report_names: ['document'] }`*
63
67
 
64
68
  #### Applicants
65
69
 
66
70
  Applicants are the object upon which Onfido checks are performed.
67
71
 
68
72
  ```ruby
69
- api.applicant.create(params) # => Creates an applicant
70
- api.applicant.update('applicant_id', params) # => Updates an applicant
71
- api.applicant.destroy('applicant_id') # => Schedule an applicant for deletion
72
- api.applicant.restore('applicant_id') # => Restore an applicant scheduled for deletion
73
- api.applicant.find('applicant_id') # => Finds a single applicant
74
- api.applicant.all # => Returns all applicants
73
+ onfido.applicant.create(params) # => Creates an applicant
74
+ onfido.applicant.update('<APPLICANT_ID>', params) # => Updates an applicant
75
+ onfido.applicant.destroy('<APPLICANT_ID>') # => Schedule an applicant for deletion
76
+ onfido.applicant.restore('<APPLICANT_ID>') # => Restore an applicant scheduled for deletion
77
+ onfido.applicant.find('<APPLICANT_ID>') # => Finds a single applicant
78
+ onfido.applicant.all # => Returns all applicants
75
79
  ```
76
80
 
77
- **Note:** Calling api.applicant.destroy adds the applicant and all associated documents, photos, videos, checks, and reports to the deletion queue. They will be deleted 20 days after the request is made. An applicant that is scheduled for deletion can be restored but applicants that have been permanently deleted cannot be restored.
81
+ **Note:** Calling `onfido.applicant.destroy` adds the applicant and all associated documents, photos, videos, checks, and reports to the deletion queue. They will be deleted 20 days after the request is made. An applicant that is scheduled for deletion can be restored but applicants that have been permanently deleted cannot.
78
82
  See https://documentation.onfido.com/#delete-applicant for more information.
79
83
 
80
84
  #### Documents
81
85
 
82
- Documents provide supporting evidence for Onfido checks.
86
+ Some report types require identity documents (passport, driving licence etc.) in order to be processed.
83
87
 
84
88
  ```ruby
85
- api.document.create('applicant_id', file: 'http://example.com', type: 'passport') # => Creates a document
86
- api.document.find('applicant_id', 'document_id') # => Finds a document
87
- api.document.download('applicant_id', 'document_id') # => Downloads a document as a binary data
88
- api.document.all('applicant_id') # => Returns all applicant's documents
89
+ onfido.document.create(applicant_id: '<APPLICANT_ID>', file: <FILE>, type: 'passport') # => Creates a document
90
+ onfido.document.find('<DOCUMENT_ID>') # => Finds a document
91
+ onfido.document.download('<DOCUMENT_ID>') # => Downloads a document as a binary data
92
+ onfido.document.all('<APPLICANT_ID>') # => Returns all documents belonging to an applicant
89
93
  ```
90
94
 
91
95
  **Note:** The file parameter must be a `File`-like object which responds to `#read` and `#path`.
@@ -93,15 +97,17 @@ Previous versions of this gem supported providing a URL to a file accessible ove
93
97
  to a file in the local filesystem. You should instead load the file yourself and then pass it in
94
98
  to `#create`.
95
99
 
100
+ See https://documentation.onfido.com/#document-types for example document types.
101
+
96
102
  #### Live Photos
97
103
 
98
- Live Photos, like documents, can provide supporting evidence for Onfido checks.
104
+ Live photos are images of the applicant’s face, typically taken at the same time as documents are provided. These photos are used to perform Facial Similarity Photo reports on the applicant.
99
105
 
100
106
  ```ruby
101
- api.live_photo.create('applicant_id', file: 'http://example.com')
102
- api.live_photo.find(applicant_id, live_photo_id) # => Finds a live photo
103
- api.live_photo.download(applicant_id, live_photo_id) # => Downloads a live photo as binary data
104
- api.live_photo.all(applicant_id) # => Returns all applicant's live photos
107
+ onfido.live_photo.create(applicant_id: '<APPLICANT_ID>', file: <FILE>) # => Creates a live photo
108
+ onfido.live_photo.find('<LIVE_PHOTO_ID>') # => Finds a live photo
109
+ onfido.live_photo.download('<LIVE_PHOTO_ID>') # => Downloads a live photo as binary data
110
+ onfido.live_photo.all('<APPLICANT_ID>') # => Returns all live photos belonging to an applicant
105
111
  ```
106
112
 
107
113
  **Note:** The file parameter must be a `File`-like object which responds to `#read` and `#path`.
@@ -111,48 +117,37 @@ to `#create`.
111
117
 
112
118
  #### Checks
113
119
 
114
- Checks are requests for Onfido to check an applicant, by commissioning one or
115
- more "reports" on them.
120
+ Checks are performed on an applicant. Depending on the type of check you wish to perform, different information will be required when you create an applicant. A check consists of one or more reports.
116
121
 
117
122
  ```ruby
118
- api.check.create('applicant_id', type: 'express', reports: [{ name: 'identity' }])
119
- api.check.find('applicant_id', 'check_id')
120
- api.check.resume('check_id')
121
- api.check.all('applicant_id')
123
+ onfido.check.create(applicant_id: '<APPLICANT_ID>', report_names: ['document', 'facial_similarity_photo']) # => Creates a check
124
+ onfido.check.find('<CHECK_ID>') # => Finds a check
125
+ onfido.check.resume('<CHECK_ID>') # => Resumes a paused check
126
+ onfido.check.all('<APPLICANT_ID>') # => Returns all an applicant's checks
122
127
  ```
123
128
 
124
129
  #### Reports
125
130
 
126
- Reports provide details of the results of some part of a "check". They are
131
+ Reports provide details of the results of some part of a check. They are
127
132
  created when a check is created, so the Onfido API only provides support for
128
133
  finding and listing them. For paused reports specifically, additional support for resuming and
129
134
  cancelling reports is also available.
130
135
 
131
136
  ```ruby
132
- api.report.find('check_id', 'report_id')
133
- api.report.all('check_id')
134
- api.report.resume('check_id', 'report_id')
135
- api.report.cancel('check_id', 'report_id')
136
- ```
137
-
138
- #### Report Type Groups
139
-
140
- Report type groups provide a convenient way to group and organize different types of reports.
141
- The Onfido API only provides support for finding and listing them.
142
-
143
- ```ruby
144
- api.report_type_group.find('report_type_group_id')
145
- api.report_type_group.all()
137
+ onfido.report.find('<REPORT_ID>') # => Finds a report
138
+ onfido.report.all('<CHECK_ID>') # => Returns all the reports in a check
139
+ onfido.report.resume('<REPORT_ID>') # => Resumes a paused report
140
+ onfido.report.cancel('<REPORT_ID>') # => Cancels a paused report
146
141
  ```
147
142
 
148
143
  #### Address Lookups
149
144
 
150
145
  Onfido provides an address lookup service, to help ensure well-formatted
151
- addresses are provided when creating "applicants". To search for addresses
146
+ addresses are provided when creating applicants. To search for addresses
152
147
  by postcode, use:
153
148
 
154
149
  ```ruby
155
- api.address.all('SE1 4NG')
150
+ onfido.address.all('SE1 4NG') # => Returns all addresses in a given postcode
156
151
  ```
157
152
 
158
153
  #### Webhook Endpoints
@@ -161,9 +156,9 @@ Onfido allows you to set up and view your webhook endpoints via the API, as well
161
156
  as through the dashboard.
162
157
 
163
158
  ```ruby
164
- api.webhook.create(params) # => Creates a webhook endpoint
165
- api.webhook.find('webhook_id') # => Finds a single webhook endpoint
166
- api.webhook.all # => Returns all webhook endpoints
159
+ onfido.webhook.create(url: "https://webhook.url", events: ['report.completed', 'check.completed']) # => Registers a webhook endpoint
160
+ onfido.webhook.find('<WEBHOOK_ID>') # => Finds a single webhook endpoint
161
+ onfido.webhook.all # => Returns all webhook endpoints
167
162
  ```
168
163
 
169
164
  #### SDK Tokens
@@ -172,26 +167,21 @@ Onfido allows you to generate JSON Web Tokens via the API in order to authentica
172
167
  with Onfido's [JavaScript SDK](https://github.com/onfido/onfido-sdk-ui).
173
168
 
174
169
  ```ruby
175
- api.sdk_token.create(applicant_id: 'applicant_id', referrer: 'referrer')
170
+ onfido.sdk_token.create(applicant_id: 'applicant_id', referrer: 'referrer') # => Creates a JWT
176
171
  ```
177
172
 
178
- ### Pagination
179
-
180
- All resources that support an `all` method also support pagination. By default,
181
- the first 20 records are fetched.
182
-
183
173
  ### Error Handling
184
174
 
185
- There are three classes of errors raised by the library, all of which subclass `Onfido::OnfidoError`:
175
+ There are 3 classes of errors raised by the library, all of which subclass `Onfido::OnfidoError`:
186
176
  - `Onfido::ServerError` is raised whenever Onfido returns a `5xx` response
187
177
  - `Onfido::RequestError` is raised whenever Onfido returns any other kind of error
188
178
  - `Onfido::ConnectionError` is raised whenever a network error occurs (e.g., a timeout)
189
179
 
190
- All three error classes provide the `response_code`, `response_body`, `json_body`, `type` and `fields` of the error (although for `Onfido::ServerError` and `Onfido::ConnectionError` the last three are likely to be `nil`).
180
+ All 3 error classes provide the `response_code`, `response_body`, `json_body`, `type` and `fields` of the error (although for `Onfido::ServerError` and `Onfido::ConnectionError` the last 3 are likely to be `nil`).
191
181
 
192
182
  ```ruby
193
183
  def create_applicant
194
- api.applicant.create(params)
184
+ onfido.applicant.create(params)
195
185
  rescue Onfido::RequestError => e
196
186
  e.type # => 'validation_error'
197
187
  e.fields # => { "email": { "messages": ["invalid format"] } }
@@ -201,13 +191,13 @@ end
201
191
 
202
192
  ## Webhooks
203
193
 
204
- Each webhook endpoint has a secret token, generated automatically and [exposed](https://onfido.com/documentation#register-webhook) in the API. When sending a request, Onfido includes a signature computed using the request body and this token in the `X-Signature` header.
194
+ Each webhook endpoint has a secret token, generated automatically and [exposed](https://onfido.com/documentation#register-webhook) in the API. When sending a request, Onfido includes a signature computed using the request body and this token in the `X-SHA2-Signature` header.
205
195
 
206
- This provided signature [should](https://onfido.com/documentation#webhook-security) be compared to one you generate yourself with the token to check that a webhook is a genuine request from Onfido.
196
+ You should compare this provided signature to one you generate yourself with the token to verify that a webhook is a genuine request from Onfido.
207
197
 
208
198
  ```ruby
209
199
  if Onfido::Webhook.valid?(request.raw_post,
210
- request.headers["X-Signature"],
200
+ request.headers["X-SHA2-Signature"],
211
201
  ENV['ONFIDO_WEBHOOK_TOKEN'])
212
202
  process_webhook
213
203
  else
@@ -215,15 +205,11 @@ else
215
205
  end
216
206
  ```
217
207
 
218
- ## Roadmap
219
-
220
- - Improve test coverage with more scenarios
221
- - Add custom errors based on the response code
222
- - Improve pagination handling (use information passed in link header)
208
+ Read more at https://onfido.com/documentation#webhook-security
223
209
 
224
210
  ## Contributing
225
211
 
226
- 1. Fork it ( https://github.com/hvssle/onfido/fork )
212
+ 1. Fork it ( https://github.com/onfido/onfido-ruby/fork )
227
213
  2. Create your feature branch (`git checkout -b my-new-feature`)
228
214
  3. Commit your changes (`git commit -am 'Add some feature'`)
229
215
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/onfido.rb CHANGED
@@ -16,10 +16,10 @@ require 'onfido/resources/address'
16
16
  require 'onfido/resources/applicant'
17
17
  require 'onfido/resources/check'
18
18
  require 'onfido/resources/document'
19
+ require 'onfido/resources/extraction'
19
20
  require 'onfido/resources/live_photo'
20
21
  require 'onfido/resources/live_video'
21
22
  require 'onfido/resources/report'
22
- require 'onfido/resources/report_type_group'
23
23
  require 'onfido/resources/sdk_token'
24
24
  require 'onfido/resources/webhook'
25
25
 
data/lib/onfido/api.rb CHANGED
@@ -28,10 +28,6 @@ module Onfido
28
28
  Onfido::Report.new(@api_key)
29
29
  end
30
30
 
31
- def report_type_group
32
- Onfido::ReportTypeGroup.new(@api_key)
33
- end
34
-
35
31
  def sdk_token
36
32
  Onfido::SdkToken.new(@api_key)
37
33
  end
@@ -43,5 +39,9 @@ module Onfido
43
39
  def address
44
40
  Onfido::Address.new(@api_key)
45
41
  end
42
+
43
+ def extraction
44
+ Onfido::Extraction.new(@api_key)
45
+ end
46
46
  end
47
47
  end
@@ -1,10 +1,11 @@
1
1
  module Onfido
2
2
  module Configuration
3
3
  REGION_HOSTS = {
4
- us: "api.us.onfido.com"
4
+ us: "api.us.onfido.com",
5
+ ca: "api.ca.onfido.com"
5
6
  }.freeze
6
7
 
7
- attr_accessor :api_key, :region, :open_timeout, :read_timeout, :api_version
8
+ attr_accessor :api_key, :region, :open_timeout, :read_timeout
8
9
 
9
10
  def self.extended(base)
10
11
  base.reset
@@ -19,7 +20,6 @@ module Onfido
19
20
  self.region = nil
20
21
  self.open_timeout = 30
21
22
  self.read_timeout = 80
22
- self.api_version = 'v2'
23
23
  RestClient.log = nil
24
24
  end
25
25
 
@@ -41,7 +41,7 @@ module Onfido
41
41
  raise "The region \"#{region.downcase}\" is not currently supported"
42
42
  end
43
43
 
44
- "https://#{region_host}/#{api_version}/"
44
+ "https://#{region_host}/v3/"
45
45
  end
46
46
  end
47
47
  end
@@ -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(:url),
14
+ url: Onfido.endpoint + args.first.fetch(:path),
19
15
  payload: build_query(args.first.fetch(:payload, {}))
20
16
  )
21
17
  end
@@ -69,7 +65,8 @@ module Onfido
69
65
  def headers
70
66
  {
71
67
  'Authorization' => "Token token=#{@api_key}",
72
- 'Accept' => "application/json"
68
+ 'Accept' => "application/json",
69
+ 'User-Agent' => "onfido-ruby/#{Onfido::VERSION}"
73
70
  }
74
71
  end
75
72
 
@@ -1,10 +1,7 @@
1
1
  module Onfido
2
2
  class Address < Resource
3
3
  def all(postcode)
4
- get(
5
- url: url_for('addresses/pick'),
6
- payload: { postcode: postcode.delete(' ') }
7
- )
4
+ get(path: "addresses/pick?postcode=#{postcode.delete(' ')}")
8
5
  end
9
6
  end
10
7
  end