onfido 0.12.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +4 -3
- data/.travis.yml +8 -7
- data/CHANGELOG.md +23 -0
- data/LICENSE +2 -1
- data/README.md +70 -70
- data/lib/onfido.rb +1 -1
- data/lib/onfido/api.rb +4 -4
- data/lib/onfido/configuration.rb +12 -16
- data/lib/onfido/resource.rb +3 -6
- data/lib/onfido/resources/address.rb +1 -1
- data/lib/onfido/resources/applicant.rb +9 -5
- data/lib/onfido/resources/check.rb +10 -14
- data/lib/onfido/resources/document.rb +11 -11
- data/lib/onfido/resources/extraction.rb +9 -0
- data/lib/onfido/resources/live_photo.rb +9 -14
- data/lib/onfido/resources/live_video.rb +5 -8
- data/lib/onfido/resources/report.rb +8 -9
- data/lib/onfido/resources/sdk_token.rb +3 -5
- data/lib/onfido/resources/webhook.rb +11 -9
- data/lib/onfido/version.rb +1 -1
- data/onfido.gemspec +8 -9
- data/spec/integrations/address_spec.rb +1 -0
- data/spec/integrations/applicant_spec.rb +38 -32
- data/spec/integrations/check_spec.rb +13 -23
- data/spec/integrations/document_spec.rb +16 -17
- data/spec/integrations/exceptions_spec.rb +12 -13
- data/spec/integrations/extraction_spec.rb +19 -0
- data/spec/integrations/live_photo_spec.rb +12 -13
- data/spec/integrations/live_video_spec.rb +7 -10
- data/spec/integrations/report_spec.rb +11 -13
- data/spec/integrations/sdk_token_spec.rb +5 -5
- data/spec/integrations/webhook_spec.rb +35 -20
- data/spec/onfido/resource_spec.rb +10 -14
- data/spec/onfido_spec.rb +13 -13
- data/spec/support/fake_onfido_api.rb +60 -77
- data/spec/support/fixtures/applicant.json +21 -42
- data/spec/support/fixtures/check.json +4 -4
- data/spec/support/fixtures/checks.json +4 -4
- data/spec/support/fixtures/document.json +2 -2
- data/spec/support/fixtures/documents.json +8 -8
- data/spec/support/fixtures/extraction.json +23 -0
- data/spec/support/fixtures/live_photo.json +3 -3
- data/spec/support/fixtures/live_photos.json +6 -6
- data/spec/support/fixtures/live_video.json +3 -3
- data/spec/support/fixtures/live_videos.json +4 -4
- data/spec/support/fixtures/not_scheduled_for_deletion_error.json +7 -0
- data/spec/support/fixtures/report.json +4 -4
- data/spec/support/fixtures/reports.json +8 -8
- data/spec/support/fixtures/webhook.json +6 -5
- data/spec/support/fixtures/webhooks.json +17 -12
- metadata +22 -42
- data/lib/onfido/resources/report_type_group.rb +0 -11
- data/spec/integrations/report_type_group_spec.rb +0 -19
- data/spec/support/fixtures/check_with_expanded_reports.json +0 -30
- data/spec/support/fixtures/checks_with_expanded_reports.json +0 -34
- data/spec/support/fixtures/report_type_group.json +0 -25
- data/spec/support/fixtures/report_type_groups.json +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8749aa43cbc394686f1ff769f0b0ada44c541a9c
|
4
|
+
data.tar.gz: f6e314d3f734e8eb315f97daa6765c0904bec8db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2db07995e16031cb9b04da83497400f082fb1fdac289761b46481ab83d283efbdf7bc12ac61508fa50583f081c53311c4dce8aa7cf90efda97d5c6bc4244435
|
7
|
+
data.tar.gz: 3e41ed2d4988192d230b67382e78b19209684a059aec2af1ca875234b3bf7787f17dbcdbd6004ca1ad0df12b051061d9413afffc85a6739c519d9eccfc89c1a9
|
data/.rubocop.yml
CHANGED
@@ -2,9 +2,6 @@
|
|
2
2
|
|
3
3
|
AllCops:
|
4
4
|
DisplayCopNames: true
|
5
|
-
Include:
|
6
|
-
- Rakefile
|
7
|
-
- lib/tasks/*.rake
|
8
5
|
Exclude:
|
9
6
|
- vendor/**/*
|
10
7
|
- .*/**
|
@@ -54,3 +51,7 @@ Layout/DotPosition:
|
|
54
51
|
# Allow class and message or instance raises
|
55
52
|
Style/RaiseArgs:
|
56
53
|
Enabled: false
|
54
|
+
|
55
|
+
Lint/AmbiguousBlockAssociation:
|
56
|
+
Exclude:
|
57
|
+
- "spec/**/*"
|
data/.travis.yml
CHANGED
@@ -1,18 +1,19 @@
|
|
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
|
-
-
|
14
|
-
-
|
9
|
+
- 2.6
|
10
|
+
- 2.7
|
15
11
|
|
16
12
|
script:
|
17
13
|
- bundle exec rubocop
|
18
14
|
- bundle exec rspec spec
|
15
|
+
|
16
|
+
# safelist
|
17
|
+
branches:
|
18
|
+
only:
|
19
|
+
- master
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
## v1.1.0, 6 Aug 2020
|
2
|
+
|
3
|
+
- Add User-Agent header
|
4
|
+
- Add support for CA region
|
5
|
+
|
6
|
+
## v1.0.0, 13 Jan 2020
|
7
|
+
|
8
|
+
- Support Onfido API version 3
|
9
|
+
- Drop support for Onfido API version 2
|
10
|
+
- To upgrade from 0.15.0 see the v2 to v3 migration [guide](https://developers.onfido.com/guide/v2-to-v3-migration-guide)
|
11
|
+
|
12
|
+
## v0.15.0, 4 Feb 2019
|
13
|
+
|
14
|
+
- Add Check#find_by_url method (@ctrlaltdylan)
|
15
|
+
|
16
|
+
## v0.14.0, 28 Jan 2019
|
17
|
+
|
18
|
+
- Add support for applicant deletion and restore endpoints
|
19
|
+
|
20
|
+
## v0.13.0, 5 Nov 2018
|
21
|
+
|
22
|
+
- Add support for region-specific environments (@stephencookdev)
|
23
|
+
|
1
24
|
## v0.12.0, 29 May 2018
|
2
25
|
|
3
26
|
- Add support for the Live Video resource (#55) (@Intrepidd)
|
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,75 +3,93 @@
|
|
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/
|
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
|
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', '~>
|
19
|
+
gem 'onfido', '~> 1.1.0'
|
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
24
|
There are 5 configuration options:
|
23
25
|
|
24
26
|
```ruby
|
25
27
|
Onfido.configure do |config|
|
26
|
-
config.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
|
32
|
+
config.region = nil
|
31
33
|
end
|
32
34
|
```
|
33
35
|
|
36
|
+
### Regions
|
37
|
+
|
38
|
+
The gem will use the default region if no region is specified.
|
39
|
+
|
40
|
+
To specify the US region do:
|
41
|
+
`config.region = :us`
|
42
|
+
|
43
|
+
To specify the CA region do:
|
44
|
+
`config.region = :ca`
|
45
|
+
|
46
|
+
See https://documentation.onfido.com/#regions for supported regions.
|
47
|
+
|
34
48
|
## Usage
|
35
49
|
|
36
50
|
You can make API calls by using an instance of the `API` class:
|
37
51
|
|
38
52
|
```ruby
|
39
|
-
|
53
|
+
onfido = Onfido::API.new
|
40
54
|
```
|
41
55
|
|
42
|
-
|
56
|
+
You can also set an API key as follows, instead of in the initializer configuration:
|
43
57
|
|
44
58
|
```ruby
|
45
|
-
|
59
|
+
onfido = Onfido::API.new(api_key: '<YOUR_API_KEY>')
|
46
60
|
```
|
47
61
|
|
48
62
|
### Resources
|
49
63
|
|
50
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.
|
51
65
|
|
52
|
-
**Note:** *All param keys should be
|
66
|
+
**Note:** *All param keys should be symbols e.g. `{ report_names: ['document'] }`*
|
53
67
|
|
54
68
|
#### Applicants
|
55
69
|
|
56
70
|
Applicants are the object upon which Onfido checks are performed.
|
57
71
|
|
58
72
|
```ruby
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
64
79
|
```
|
65
80
|
|
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.
|
82
|
+
See https://documentation.onfido.com/#delete-applicant for more information.
|
83
|
+
|
66
84
|
#### Documents
|
67
85
|
|
68
|
-
|
86
|
+
Some report types require identity documents (passport, driving licence etc.) in order to be processed.
|
69
87
|
|
70
88
|
```ruby
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
75
93
|
```
|
76
94
|
|
77
95
|
**Note:** The file parameter must be a `File`-like object which responds to `#read` and `#path`.
|
@@ -79,15 +97,17 @@ Previous versions of this gem supported providing a URL to a file accessible ove
|
|
79
97
|
to a file in the local filesystem. You should instead load the file yourself and then pass it in
|
80
98
|
to `#create`.
|
81
99
|
|
100
|
+
See https://documentation.onfido.com/#document-types for example document types.
|
101
|
+
|
82
102
|
#### Live Photos
|
83
103
|
|
84
|
-
Live
|
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.
|
85
105
|
|
86
106
|
```ruby
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
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
|
91
111
|
```
|
92
112
|
|
93
113
|
**Note:** The file parameter must be a `File`-like object which responds to `#read` and `#path`.
|
@@ -97,48 +117,37 @@ to `#create`.
|
|
97
117
|
|
98
118
|
#### Checks
|
99
119
|
|
100
|
-
Checks are
|
101
|
-
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.
|
102
121
|
|
103
122
|
```ruby
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
108
127
|
```
|
109
128
|
|
110
129
|
#### Reports
|
111
130
|
|
112
|
-
Reports provide details of the results of some part of a
|
131
|
+
Reports provide details of the results of some part of a check. They are
|
113
132
|
created when a check is created, so the Onfido API only provides support for
|
114
133
|
finding and listing them. For paused reports specifically, additional support for resuming and
|
115
134
|
cancelling reports is also available.
|
116
135
|
|
117
136
|
```ruby
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
```
|
123
|
-
|
124
|
-
#### Report Type Groups
|
125
|
-
|
126
|
-
Report type groups provide a convenient way to group and organize different types of reports.
|
127
|
-
The Onfido API only provides support for finding and listing them.
|
128
|
-
|
129
|
-
```ruby
|
130
|
-
api.report_type_group.find('report_type_group_id')
|
131
|
-
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
|
132
141
|
```
|
133
142
|
|
134
143
|
#### Address Lookups
|
135
144
|
|
136
145
|
Onfido provides an address lookup service, to help ensure well-formatted
|
137
|
-
addresses are provided when creating
|
146
|
+
addresses are provided when creating applicants. To search for addresses
|
138
147
|
by postcode, use:
|
139
148
|
|
140
149
|
```ruby
|
141
|
-
|
150
|
+
onfido.address.all('SE1 4NG') # => Returns all addresses in a given postcode
|
142
151
|
```
|
143
152
|
|
144
153
|
#### Webhook Endpoints
|
@@ -147,9 +156,9 @@ Onfido allows you to set up and view your webhook endpoints via the API, as well
|
|
147
156
|
as through the dashboard.
|
148
157
|
|
149
158
|
```ruby
|
150
|
-
|
151
|
-
|
152
|
-
|
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
|
153
162
|
```
|
154
163
|
|
155
164
|
#### SDK Tokens
|
@@ -158,26 +167,21 @@ Onfido allows you to generate JSON Web Tokens via the API in order to authentica
|
|
158
167
|
with Onfido's [JavaScript SDK](https://github.com/onfido/onfido-sdk-ui).
|
159
168
|
|
160
169
|
```ruby
|
161
|
-
|
170
|
+
onfido.sdk_token.create(applicant_id: 'applicant_id', referrer: 'referrer') # => Creates a JWT
|
162
171
|
```
|
163
172
|
|
164
|
-
### Pagination
|
165
|
-
|
166
|
-
All resources that support an `all` method also support pagination. By default,
|
167
|
-
the first 20 records are fetched.
|
168
|
-
|
169
173
|
### Error Handling
|
170
174
|
|
171
|
-
There are
|
175
|
+
There are 3 classes of errors raised by the library, all of which subclass `Onfido::OnfidoError`:
|
172
176
|
- `Onfido::ServerError` is raised whenever Onfido returns a `5xx` response
|
173
177
|
- `Onfido::RequestError` is raised whenever Onfido returns any other kind of error
|
174
178
|
- `Onfido::ConnectionError` is raised whenever a network error occurs (e.g., a timeout)
|
175
179
|
|
176
|
-
All
|
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`).
|
177
181
|
|
178
182
|
```ruby
|
179
183
|
def create_applicant
|
180
|
-
|
184
|
+
onfido.applicant.create(params)
|
181
185
|
rescue Onfido::RequestError => e
|
182
186
|
e.type # => 'validation_error'
|
183
187
|
e.fields # => { "email": { "messages": ["invalid format"] } }
|
@@ -187,13 +191,13 @@ end
|
|
187
191
|
|
188
192
|
## Webhooks
|
189
193
|
|
190
|
-
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.
|
191
195
|
|
192
|
-
|
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.
|
193
197
|
|
194
198
|
```ruby
|
195
199
|
if Onfido::Webhook.valid?(request.raw_post,
|
196
|
-
request.headers["X-Signature"],
|
200
|
+
request.headers["X-SHA2-Signature"],
|
197
201
|
ENV['ONFIDO_WEBHOOK_TOKEN'])
|
198
202
|
process_webhook
|
199
203
|
else
|
@@ -201,15 +205,11 @@ else
|
|
201
205
|
end
|
202
206
|
```
|
203
207
|
|
204
|
-
|
205
|
-
|
206
|
-
- Improve test coverage with more scenarios
|
207
|
-
- Add custom errors based on the response code
|
208
|
-
- Improve pagination handling (use information passed in link header)
|
208
|
+
Read more at https://onfido.com/documentation#webhook-security
|
209
209
|
|
210
210
|
## Contributing
|
211
211
|
|
212
|
-
1. Fork it ( https://github.com/
|
212
|
+
1. Fork it ( https://github.com/onfido/onfido-ruby/fork )
|
213
213
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
214
214
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
215
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
|
data/lib/onfido/configuration.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module Onfido
|
2
2
|
module Configuration
|
3
|
-
|
3
|
+
REGION_HOSTS = {
|
4
|
+
us: "api.us.onfido.com",
|
5
|
+
ca: "api.ca.onfido.com"
|
6
|
+
}.freeze
|
7
|
+
|
8
|
+
attr_accessor :api_key, :region, :open_timeout, :read_timeout
|
4
9
|
|
5
10
|
def self.extended(base)
|
6
11
|
base.reset
|
@@ -12,9 +17,9 @@ module Onfido
|
|
12
17
|
|
13
18
|
def reset
|
14
19
|
self.api_key = nil
|
20
|
+
self.region = nil
|
15
21
|
self.open_timeout = 30
|
16
22
|
self.read_timeout = 80
|
17
|
-
self.api_version = 'v2'
|
18
23
|
RestClient.log = nil
|
19
24
|
end
|
20
25
|
|
@@ -30,22 +35,13 @@ module Onfido
|
|
30
35
|
RestClient.log ||= NullLogger.new
|
31
36
|
end
|
32
37
|
|
33
|
-
def region
|
34
|
-
return unless api_key
|
35
|
-
|
36
|
-
first_bit = api_key.split("_")[0]
|
37
|
-
|
38
|
-
return if %w(live test).include?(first_bit)
|
39
|
-
|
40
|
-
first_bit
|
41
|
-
end
|
42
|
-
|
43
38
|
def endpoint
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
"https://api.onfido.com/#{api_version}/"
|
39
|
+
region_host = region ? REGION_HOSTS[region.downcase.to_sym] : "api.onfido.com"
|
40
|
+
unless region_host
|
41
|
+
raise "The region \"#{region.downcase}\" is not currently supported"
|
48
42
|
end
|
43
|
+
|
44
|
+
"https://#{region_host}/v3/"
|
49
45
|
end
|
50
46
|
end
|
51
47
|
end
|