onfido 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3230fbefefe2fe6a65813be33aa6025503aebea8d2959290702d18874d265d0e
4
- data.tar.gz: 12bcea5a6c837d30aa1c5ea9ba2e62c4d1d5a7d6c65824fbec55943d941f572c
3
+ metadata.gz: 25182eb1c80a27c7f3fbd914c640e277e973e71d0f24f8760c4c28894b243622
4
+ data.tar.gz: 9f2a71605568b28890ac8ad6113050a9f6e2a947e19964a70a2144fe51571e93
5
5
  SHA512:
6
- metadata.gz: 8e179be06571269bba33d62efb85523f26cd43a1df4b1f43dc90bf6b430c68d40d5140d6141686efcd90a5898a285ade72ac51a5215a48dd6115e5232e69658e
7
- data.tar.gz: 15a6b1d68484a3174c8fabb49a4f097ba1c3f82766865707351eac513c7c617423468824758f976070bfd0a42f47cb78fdbc135d20984ecf1ec3bfde0f293c72
6
+ metadata.gz: 16f99cd52f76371e5fee1aef34d0c33752eb772ae6ffbd514644ee84eb5baf50fb126d4a00726fe7b15f802f8efbc7f3ff3a654bae875a0af992cfac6663d63b
7
+ data.tar.gz: e1df5fd7ca79a84cd33942d59271b68ccedaca41d49dfdf1ef107a07d199e8688299da824c7d32722a1350f6137c7bfd5ad3907449e5a93ec28f2d288d137edd
@@ -1,3 +1,8 @@
1
+ ## v0.11.0, 18 April 2018
2
+
3
+ - Automatically detect the correct Onfido API region to use based on the provided API
4
+ key (#49) (@tpinto)
5
+
1
6
  ## v0.10.0, 3 April 2018
2
7
 
3
8
  - Add support for download, find and retrieve all for live_photo resource (@kirsis)
data/README.md CHANGED
@@ -12,7 +12,7 @@ This gem supports both `v1` and `v2` of the Onfido API. Refer to Onfido's [API d
12
12
  Add this line to your application's Gemfile:
13
13
 
14
14
  ```ruby
15
- gem 'onfido', '~> 0.10.0'
15
+ gem 'onfido', '~> 0.11.0'
16
16
  ```
17
17
 
18
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.
@@ -30,8 +30,22 @@ module Onfido
30
30
  RestClient.log ||= NullLogger.new
31
31
  end
32
32
 
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
+
33
43
  def endpoint
34
- "https://api.onfido.com/#{api_version}/"
44
+ if region
45
+ "https://api.#{region}.onfido.com/#{api_version}/"
46
+ else
47
+ "https://api.onfido.com/#{api_version}/"
48
+ end
35
49
  end
36
50
  end
37
51
  end
@@ -1,3 +1,3 @@
1
1
  module Onfido
2
- VERSION = '0.10.0'.freeze
2
+ VERSION = '0.11.0'.freeze
3
3
  end
@@ -35,6 +35,27 @@ describe Onfido do
35
35
  end
36
36
  end
37
37
 
38
+ describe 'using a US API token' do
39
+ it 'should change endpoint' do
40
+ onfido.api_key = "us_live_asdfghjkl1234567890qwertyuiop"
41
+ expect(onfido.endpoint).to eq('https://api.us.onfido.com/v2/')
42
+ end
43
+ end
44
+
45
+ describe 'using a EU API token' do
46
+ it 'should change endpoint' do
47
+ onfido.api_key = "eu_live_asdfghjkl1234567890qwertyuiop"
48
+ expect(onfido.endpoint).to eq('https://api.eu.onfido.com/v2/')
49
+ end
50
+ end
51
+
52
+ describe 'using an old API token' do
53
+ it 'should use old endpoint' do
54
+ onfido.api_key = "live_asdfghjkl1234567890qwertyuiop"
55
+ expect(onfido.endpoint).to eq('https://api.onfido.com/v2/')
56
+ end
57
+ end
58
+
38
59
  describe '.logger' do
39
60
  context 'when an option is passed' do
40
61
  context 'when the option passed behaves like a logger' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onfido
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pericles Theodorou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-04-03 00:00:00.000000000 Z
12
+ date: 2018-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler