addressfinder 1.8.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/addressfinder/bulk.rb +8 -6
- data/lib/addressfinder/v2/au/verification.rb +1 -1
- data/lib/addressfinder/version.rb +1 -1
- data/lib/addressfinder.rb +2 -2
- data/spec/lib/addressfinder/bulk_spec.rb +45 -3
- data/spec/lib/addressfinder_spec.rb +64 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 939c60d3f251b84c6fc378148d6d8d3480e2dcf2f171c27b7edef470d9b5a5b8
|
|
4
|
+
data.tar.gz: '07988c8cbbe65632d5551a11d9a02618360589c43ef2b3f3112159141b0a290d'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 14d93058d16682693bf237678aed85bb496d71447ff16457c30a32785e2fde1ad263c0063eb3da5a54ce96df3d88733afcef9452eb97e9a0a3483a56cfc86083
|
|
7
|
+
data.tar.gz: 19825d8fefac06180ee9c8d7a62eb81ec1ee8a06b753272f2dace02620a6e07c231e062d2af4f39285baafae1b00c232fd5c8034332d5f522452dae10e842145
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
# AddressFinder 1.8.1 (October 2021) #
|
|
2
|
+
|
|
3
|
+
* Prevent NZ bulk and verification calls from using V2 module
|
|
4
|
+
|
|
1
5
|
# AddressFinder 1.8.0 (October 2021) #
|
|
2
6
|
|
|
3
|
-
* Create a V2
|
|
7
|
+
* Create a V2 Module for verification (Australia)
|
|
4
8
|
* Remove PAF support from V1 verification API (Australia)
|
|
5
9
|
* Include API version number in configuration
|
|
6
10
|
|
data/lib/addressfinder/bulk.rb
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
module AddressFinder
|
|
2
2
|
class Bulk
|
|
3
|
-
def initialize(http:, verification_version:, &block)
|
|
3
|
+
def initialize(http:, verification_version:, default_country:, &block)
|
|
4
4
|
@block = block
|
|
5
5
|
@verification_version = verification_version
|
|
6
|
+
@default_country = default_country
|
|
6
7
|
@http_config = http
|
|
7
8
|
end
|
|
8
9
|
|
|
9
10
|
def perform
|
|
10
11
|
http_config.start do |http|
|
|
11
|
-
block.call ClientProxy.new(http: http, verification_version: verification_version)
|
|
12
|
+
block.call ClientProxy.new(http: http, verification_version: verification_version, default_country: default_country)
|
|
12
13
|
end
|
|
13
14
|
end
|
|
14
15
|
|
|
15
16
|
private
|
|
16
17
|
|
|
17
|
-
attr_reader :block, :verification_version, :http_config
|
|
18
|
+
attr_reader :block, :verification_version, :default_country, :http_config
|
|
18
19
|
|
|
19
20
|
class ClientProxy
|
|
20
|
-
def initialize(http:, verification_version:)
|
|
21
|
+
def initialize(http:, verification_version:, default_country:)
|
|
21
22
|
@verification_version = verification_version
|
|
23
|
+
@default_country = default_country
|
|
22
24
|
@http = http
|
|
23
25
|
end
|
|
24
26
|
|
|
@@ -27,7 +29,7 @@ module AddressFinder
|
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def verification(args={})
|
|
30
|
-
|
|
32
|
+
if verification_version&.downcase == "v2" && (args[:country] || default_country) == 'au'
|
|
31
33
|
AddressFinder::V2::Au::Verification.new(args.merge(http: http)).perform.result
|
|
32
34
|
else
|
|
33
35
|
AddressFinder::Verification.new(args.merge(http: http)).perform.result
|
|
@@ -36,7 +38,7 @@ module AddressFinder
|
|
|
36
38
|
|
|
37
39
|
private
|
|
38
40
|
|
|
39
|
-
attr_reader :http, :verification_version
|
|
41
|
+
attr_reader :http, :verification_version, :default_country
|
|
40
42
|
end
|
|
41
43
|
end
|
|
42
44
|
end
|
data/lib/addressfinder.rb
CHANGED
|
@@ -34,7 +34,7 @@ module AddressFinder
|
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def verification(args={})
|
|
37
|
-
if configuration.verification_version&.downcase == "v2"
|
|
37
|
+
if (args[:country] || configuration.default_country) == 'au' && configuration.verification_version&.downcase == "v2"
|
|
38
38
|
AddressFinder::V2::Au::Verification.new(args.merge(http: AddressFinder::HTTP.new(configuration))).perform.result
|
|
39
39
|
else
|
|
40
40
|
AddressFinder::Verification.new(args.merge(http: AddressFinder::HTTP.new(configuration))).perform.result
|
|
@@ -62,7 +62,7 @@ module AddressFinder
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def bulk(&block)
|
|
65
|
-
AddressFinder::Bulk.new(http: AddressFinder::HTTP.new(configuration), verification_version: configuration.verification_version, &block).perform
|
|
65
|
+
AddressFinder::Bulk.new(http: AddressFinder::HTTP.new(configuration), verification_version: configuration.verification_version, default_country: configuration.default_country, &block).perform
|
|
66
66
|
end
|
|
67
67
|
end
|
|
68
68
|
end
|
|
@@ -38,7 +38,31 @@ RSpec.describe AddressFinder::Bulk do
|
|
|
38
38
|
expect(net_http).to receive(:do_start).once.and_call_original
|
|
39
39
|
expect(net_http).to receive(:transport_request).exactly(3).times.and_return(response)
|
|
40
40
|
expect(net_http).to receive(:do_finish).once.and_call_original
|
|
41
|
-
AddressFinder::Bulk.new(http: http, verification_version: 'v2', &block).perform
|
|
41
|
+
AddressFinder::Bulk.new(http: http, verification_version: 'v2', default_country: 'au', &block).perform
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "calls the correct class with v2 verification and au default" do
|
|
45
|
+
allow(net_http).to receive(:do_start).once.and_call_original
|
|
46
|
+
allow(net_http).to receive(:transport_request).exactly(3).times.and_return(response)
|
|
47
|
+
allow(net_http).to receive(:do_finish).once.and_call_original
|
|
48
|
+
expect(AddressFinder::V2::Au::Verification).to receive(:new).exactly(3).times.and_call_original
|
|
49
|
+
AddressFinder::Bulk.new(http: http, verification_version: 'v2', default_country: 'au', &block).perform
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it "calls the correct class with v2 verification and nz default" do
|
|
53
|
+
allow(net_http).to receive(:do_start).once.and_call_original
|
|
54
|
+
allow(net_http).to receive(:transport_request).exactly(3).times.and_return(response)
|
|
55
|
+
allow(net_http).to receive(:do_finish).once.and_call_original
|
|
56
|
+
expect(AddressFinder::Verification).to receive(:new).exactly(3).times.and_call_original
|
|
57
|
+
AddressFinder::Bulk.new(http: http, verification_version: 'v2', default_country: 'nz', &block).perform
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "calls the correct class without a verification version" do
|
|
61
|
+
allow(net_http).to receive(:do_start).once.and_call_original
|
|
62
|
+
allow(net_http).to receive(:transport_request).exactly(3).times.and_return(response)
|
|
63
|
+
allow(net_http).to receive(:do_finish).once.and_call_original
|
|
64
|
+
expect(AddressFinder::Verification).to receive(:new).exactly(3).times.and_call_original
|
|
65
|
+
AddressFinder::Bulk.new(http: http, verification_version: nil, default_country: 'au', &block).perform
|
|
42
66
|
end
|
|
43
67
|
|
|
44
68
|
it "re-establishes the http connection and continues where we left off when a Net::OpenTimeout, Net::ReadTimeout or SocketError is raised" do
|
|
@@ -50,7 +74,7 @@ RSpec.describe AddressFinder::Bulk do
|
|
|
50
74
|
expect(net_http).to receive(:transport_request).once.and_raise(SocketError) # Retry 2 Willis (error)
|
|
51
75
|
expect(net_http).to receive(:transport_request).exactly(2).and_return(response) # Retry 2 Willis (success) & 3 Willis (success)
|
|
52
76
|
expect(net_http).to receive(:do_finish).exactly(4).times.and_call_original
|
|
53
|
-
AddressFinder::Bulk.new(http: http, verification_version: 'v2', &block).perform
|
|
77
|
+
AddressFinder::Bulk.new(http: http, verification_version: 'v2', default_country: 'au', &block).perform
|
|
54
78
|
end
|
|
55
79
|
end
|
|
56
80
|
|
|
@@ -66,7 +90,25 @@ RSpec.describe AddressFinder::Bulk do
|
|
|
66
90
|
expect(net_http).to receive(:do_start).once.and_call_original
|
|
67
91
|
expect(net_http).to receive(:transport_request).once.and_return(response)
|
|
68
92
|
expect(net_http).to receive(:do_finish).once.and_call_original
|
|
69
|
-
AddressFinder::
|
|
93
|
+
expect(AddressFinder::Verification).to receive(:new).exactly(1).times.and_call_original
|
|
94
|
+
AddressFinder::Bulk.new(http: http, verification_version: nil, default_country: 'au', &block).perform
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
context "with a country override and v2 in the config" do
|
|
99
|
+
let(:response){ double(:response, body: %Q({"success": true}), code: "200") }
|
|
100
|
+
let(:block){
|
|
101
|
+
Proc.new do |proxy|
|
|
102
|
+
proxy.verification(q: "1 Willis", country: "au")
|
|
103
|
+
end
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
it "has the same behaviour as the verification method" do
|
|
107
|
+
expect(net_http).to receive(:do_start).once.and_call_original
|
|
108
|
+
expect(net_http).to receive(:transport_request).once.and_return(response)
|
|
109
|
+
expect(net_http).to receive(:do_finish).once.and_call_original
|
|
110
|
+
expect(AddressFinder::V2::Au::Verification).to receive(:new).exactly(1).times.and_call_original
|
|
111
|
+
AddressFinder::Bulk.new(http: http, verification_version: "v2", default_country: 'nz', &block).perform
|
|
70
112
|
end
|
|
71
113
|
end
|
|
72
114
|
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
|
|
4
|
+
RSpec.describe AddressFinder do
|
|
5
|
+
before do
|
|
6
|
+
AddressFinder.configure do |af|
|
|
7
|
+
af.api_key = 'XXX'
|
|
8
|
+
af.api_secret = 'YYY'
|
|
9
|
+
af.default_country = 'nz'
|
|
10
|
+
af.timeout = 5
|
|
11
|
+
af.retries = 5
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe '#verification with verification_version configured to "v2"' do
|
|
16
|
+
before do
|
|
17
|
+
AddressFinder.configuration.verification_version = "v2"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
after do
|
|
21
|
+
AddressFinder.configuration.verification_version = nil # set back to nil after
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
subject(:verification){ AddressFinder.verification(args) }
|
|
25
|
+
|
|
26
|
+
context "with country set to nz" do
|
|
27
|
+
let(:args){ {country: "nz", q: "12 high street sydney"} }
|
|
28
|
+
it "calls the old class" do
|
|
29
|
+
expect(AddressFinder::Verification).to receive_message_chain(:new, :perform, :result)
|
|
30
|
+
subject
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
context "with country set to au" do
|
|
35
|
+
let(:args){ {country: "au", q: "12 high street sydney"} }
|
|
36
|
+
it "calls the v2::Au class" do
|
|
37
|
+
expect(AddressFinder::V2::Au::Verification).to receive_message_chain(:new, :perform, :result)
|
|
38
|
+
subject
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe '#verification with verification_version not configured' do
|
|
44
|
+
subject(:verification){ AddressFinder.verification(args) }
|
|
45
|
+
|
|
46
|
+
context "with country set to nz" do
|
|
47
|
+
let(:args){ {country: "nz", q: "12 high street sydney"} }
|
|
48
|
+
|
|
49
|
+
it "calls the old class" do
|
|
50
|
+
expect(AddressFinder::Verification).to receive_message_chain(:new, :perform, :result)
|
|
51
|
+
subject
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
context "with country set to au" do
|
|
56
|
+
let(:args){ {country: "au", q: "12 high street sydney"} }
|
|
57
|
+
|
|
58
|
+
it "calls the old class" do
|
|
59
|
+
expect(AddressFinder::Verification).to receive_message_chain(:new, :perform, :result)
|
|
60
|
+
subject
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: addressfinder
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.8.
|
|
4
|
+
version: 1.8.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nigel Ramsay
|
|
@@ -12,7 +12,7 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date: 2021-10-
|
|
15
|
+
date: 2021-10-28 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: multi_json
|
|
@@ -143,6 +143,7 @@ files:
|
|
|
143
143
|
- spec/lib/addressfinder/util_spec.rb
|
|
144
144
|
- spec/lib/addressfinder/v2/au/verification_spec.rb
|
|
145
145
|
- spec/lib/addressfinder/verification_spec.rb
|
|
146
|
+
- spec/lib/addressfinder_spec.rb
|
|
146
147
|
- spec/spec_helper.rb
|
|
147
148
|
homepage: https://github.com/AddressFinder/addressfinder-ruby
|
|
148
149
|
licenses:
|
|
@@ -177,4 +178,5 @@ test_files:
|
|
|
177
178
|
- spec/lib/addressfinder/util_spec.rb
|
|
178
179
|
- spec/lib/addressfinder/v2/au/verification_spec.rb
|
|
179
180
|
- spec/lib/addressfinder/verification_spec.rb
|
|
181
|
+
- spec/lib/addressfinder_spec.rb
|
|
180
182
|
- spec/spec_helper.rb
|