addressfinder 1.7.1 → 1.8.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: a2191b3d7090b6eb2c2001f080427cc917c5af00262520c907b401a2a3d7c82e
4
- data.tar.gz: bd35444c4cb2a31a47130ded4dae80596718a4d6998006ffc34b92512cf729dd
3
+ metadata.gz: 472a6d05ac8dfbfd58b7a6b3203848d3f133c0dad187a096e70820e89b1915b0
4
+ data.tar.gz: 710a21c33cd0d14533a1292e3a847be537fa1a906df75d91d5ca6337d9df6e38
5
5
  SHA512:
6
- metadata.gz: '08384b27d66dd5397f8e07dc550b86ea0befa4eaae6f8f294dcb8f01e4372739bebfe0484a6874fd0f3f05b6f19ed21108e7923fd8416379532d5b799bb5c60f'
7
- data.tar.gz: aadab0cc138ef723af46bd2e6baf1ac6571f51ecaba2dcfa2aedd34ff44b3a5c44b78f39ca5c2828edea29ae3329f1e22ec8ddfdc787482c24142202ece4b749
6
+ metadata.gz: 47797fa15c8aba466c4bda510479dac8e82b2c64120f2c1b549710e22199e01087028b97b2b640f90538f28931b1a0490ed48a18d1d1faeede9f73a7c153f4bd
7
+ data.tar.gz: 0c252011d9a9df47448c2e3a4e3e7115665361ec31dd0b394d899b8b7052542f00976ca8aa117ac7a0f59a9e9044b0beccb95a4da2d24b0717dff0b2b036ecfb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # AddressFinder 1.8.0 (October 2021) #
2
+
3
+ * Create a V2 API for verification (Australia)
4
+ * Remove PAF support from V1 verification API (Australia)
5
+ * Include API version number in configuration
6
+
1
7
  # AddressFinder 1.7.1 (June 2, 2021) #
2
8
 
3
9
  * Add support for PAF verification
data/README.md CHANGED
@@ -31,6 +31,7 @@ AddressFinder.configure do |af|
31
31
 
32
32
  # Optional
33
33
  af.default_country = 'nz' # default: nz
34
+ af.verification_version = 'v2' # default: v1
34
35
  af.timeout = 10 # default: 10 seconds
35
36
  af.retries = 12 # default: 12
36
37
  af.retry_delay = 5 # default: 5 seconds
@@ -1,22 +1,24 @@
1
1
  module AddressFinder
2
2
  class Bulk
3
- def initialize(http:, &block)
3
+ def initialize(http:, verification_version:, &block)
4
4
  @block = block
5
+ @verification_version = verification_version
5
6
  @http_config = http
6
7
  end
7
8
 
8
9
  def perform
9
10
  http_config.start do |http|
10
- block.call ClientProxy.new(http: http)
11
+ block.call ClientProxy.new(http: http, verification_version: verification_version)
11
12
  end
12
13
  end
13
14
 
14
15
  private
15
16
 
16
- attr_reader :block, :http_config
17
+ attr_reader :block, :verification_version, :http_config
17
18
 
18
19
  class ClientProxy
19
- def initialize(http:)
20
+ def initialize(http:, verification_version:)
21
+ @verification_version = verification_version
20
22
  @http = http
21
23
  end
22
24
 
@@ -25,12 +27,16 @@ module AddressFinder
25
27
  end
26
28
 
27
29
  def verification(args={})
28
- AddressFinder::Verification.new(args.merge(http: http)).perform.result
30
+ if verification_version&.downcase == "v2"
31
+ AddressFinder::V2::Au::Verification.new(args.merge(http: http)).perform.result
32
+ else
33
+ AddressFinder::Verification.new(args.merge(http: http)).perform.result
34
+ end
29
35
  end
30
36
 
31
37
  private
32
38
 
33
- attr_reader :http
39
+ attr_reader :http, :verification_version
34
40
  end
35
41
  end
36
42
  end
@@ -2,6 +2,7 @@ module AddressFinder
2
2
  class Configuration
3
3
  attr_accessor :api_key
4
4
  attr_accessor :api_secret
5
+ attr_accessor :verification_version
5
6
  attr_accessor :hostname
6
7
  attr_accessor :port
7
8
  attr_accessor :proxy_host
@@ -21,6 +22,7 @@ module AddressFinder
21
22
  self.retries = 12
22
23
  self.retry_delay = 5
23
24
  self.default_country = 'nz'
25
+ self.verification_version = 'v1'
24
26
  end
25
27
  end
26
28
  end
@@ -0,0 +1,96 @@
1
+ require 'ostruct'
2
+
3
+ module AddressFinder
4
+ module V2
5
+ module Au
6
+ class Verification
7
+
8
+ attr_reader :result
9
+
10
+ # V2 AU expected attributes:
11
+ # params[:q] --> the address query,
12
+ # params[:post_box] --> nil or '0'
13
+ # params[:census] --> '2011' or '2016' or nil,
14
+ # params[:domain] --> used for reporting does not affect query results
15
+ # params[:key] --> unique AddressFinder public key
16
+ # params[:secret] --> unique AddressFinder secret key
17
+ # params[:paf] --> nil or '1',
18
+ # params[:gnaf] --> nil or '1',
19
+ # params[:gps] --> nil or '1',
20
+ # params[:extended] --> nil or '1',
21
+ # params[:state_codes] --> string or array of strings: i.e.,['ACT', 'NSW'],
22
+ def initialize(q:, post_box: nil, census: nil, domain: nil, key: nil, secret: nil, paf: nil, gnaf: nil, gps: nil, state_codes: nil, extended: nil, http:, country: nil)
23
+ @params = {}
24
+ @params['q'] = q
25
+ @params['post_box'] = post_box if post_box
26
+ @params['census'] = census if census
27
+ @params['domain'] = domain || config.domain if (domain || config.domain)
28
+ @params['key'] = key || config.api_key
29
+ @params['secret'] = secret || config.api_secret
30
+ @params['paf'] = paf if paf
31
+ @params['gnaf'] = gnaf if gnaf
32
+ @params['gps'] = gps if gps
33
+ @params['extended'] = extended if extended
34
+ @params['state_codes'] = state_codes if state_codes
35
+
36
+ @params['format'] = 'json'
37
+ @http = http
38
+ end
39
+
40
+ def perform
41
+ build_request
42
+ execute_request
43
+ build_result
44
+
45
+ self
46
+ end
47
+
48
+ private
49
+
50
+ attr_reader :request_uri, :params, :country, :http
51
+ attr_accessor :response_body, :response_status
52
+ attr_writer :result
53
+
54
+ def build_request
55
+ @request_uri = "/api/au/address/v2/verification?#{encoded_params}"
56
+ end
57
+
58
+ def execute_request
59
+ request = Net::HTTP::Get.new(request_uri)
60
+
61
+ response = http.request(request)
62
+
63
+ self.response_body = response.body
64
+ self.response_status = response.code
65
+ end
66
+
67
+ def build_result
68
+ if response_status != '200'
69
+ raise AddressFinder::RequestRejectedError.new(@response_status, @response_body)
70
+ end
71
+
72
+ if response_hash['matched']
73
+ self.result = Result.new(response_hash['address'] || response_hash)
74
+ else
75
+ self.result = nil
76
+ end
77
+ end
78
+
79
+ def encoded_params
80
+ Util.encode_and_join_params(params)
81
+ end
82
+
83
+ def response_hash
84
+ @_response_hash ||= MultiJson.load(response_body)
85
+ end
86
+
87
+ def config
88
+ @_config ||= AddressFinder.configuration
89
+ end
90
+
91
+ class Result < OpenStruct
92
+ end
93
+ end
94
+ end
95
+ end
96
+ end
@@ -5,21 +5,40 @@ module AddressFinder
5
5
 
6
6
  attr_reader :result
7
7
 
8
- def initialize(q:, country: nil, delivered: nil, post_box: nil, paf: nil, rural: nil, region_code: nil, state_codes: nil, census: nil, domain: nil, key: nil, secret: nil, http:)
8
+ # AU V1 expected attributes:
9
+ # params[:state_codes] --> string or array of strings: i.e.,['ACT', 'NSW'],
10
+ # params[:census] --> '2011' or '2016' or nil,
11
+
12
+ # NZ expected attributes:
13
+ # params[:delivered] --> '0', '1', or nil,
14
+ # params[:post_box] --> '0', '1', or nil,
15
+ # params[:rural] --> '0', '1', or nil,
16
+ # params[:region_code] --> string, see options on addressfinder.nz or nil,
17
+ # params[:census] --> '2013', '2018' or nil
18
+
19
+ # Combined attributes
20
+ # params[:q] --> the address query,
21
+ # params[:domain] --> used for reporting does not affect query results
22
+ # params[:key] --> unique AddressFinder public key
23
+ # params[:secret] --> unique AddressFinder secret key
24
+ def initialize(q:, post_box: nil, census: nil, domain: nil, key: nil, secret: nil, state_codes: nil, delivered: nil, rural: nil, region_code: nil, country: nil, http:)
9
25
  @params = {}
26
+ # Common to AU and NZ
10
27
  @params['q'] = q
11
- @params['delivered'] = delivered if delivered
12
28
  @params['post_box'] = post_box if post_box
13
- @params['paf'] = paf if paf
14
- @params['rural'] = rural if rural
15
- @params['region_code'] = region_code if region_code
16
- @params['state_codes'] = state_codes if state_codes
17
29
  @params['census'] = census if census
18
30
  @params['domain'] = domain || config.domain if (domain || config.domain)
19
- @params['format'] = 'json'
20
31
  @params['key'] = key || config.api_key
21
32
  @params['secret'] = secret || config.api_secret
33
+ # AU params
34
+ @params['state_codes'] = state_codes if state_codes
35
+ # NZ params
36
+ @params['delivered'] = delivered if delivered
37
+ @params['rural'] = rural if rural
38
+ @params['region_code'] = region_code if region_code
22
39
  @country = country || config.default_country
40
+
41
+ @params['format'] = 'json'
23
42
  @http = http
24
43
  end
25
44
 
@@ -1,3 +1,3 @@
1
1
  module AddressFinder
2
- VERSION = '1.7.1'
2
+ VERSION = '1.8.0'
3
3
  end
data/lib/addressfinder.rb CHANGED
@@ -2,6 +2,7 @@ require 'multi_json'
2
2
  require 'addressfinder/version'
3
3
  require 'addressfinder/configuration'
4
4
  require 'addressfinder/verification'
5
+ require 'addressfinder/v2/au/verification'
5
6
  require 'addressfinder/location_info'
6
7
  require 'addressfinder/location_search'
7
8
  require 'addressfinder/address_info'
@@ -33,7 +34,11 @@ module AddressFinder
33
34
  end
34
35
 
35
36
  def verification(args={})
36
- AddressFinder::Verification.new(args.merge(http: AddressFinder::HTTP.new(configuration))).perform.result
37
+ if configuration.verification_version&.downcase == "v2"
38
+ AddressFinder::V2::Au::Verification.new(args.merge(http: AddressFinder::HTTP.new(configuration))).perform.result
39
+ else
40
+ AddressFinder::Verification.new(args.merge(http: AddressFinder::HTTP.new(configuration))).perform.result
41
+ end
37
42
  end
38
43
 
39
44
  def location_search(args={})
@@ -57,7 +62,7 @@ module AddressFinder
57
62
  end
58
63
 
59
64
  def bulk(&block)
60
- AddressFinder::Bulk.new(http: AddressFinder::HTTP.new(configuration), &block).perform
65
+ AddressFinder::Bulk.new(http: AddressFinder::HTTP.new(configuration), verification_version: configuration.verification_version, &block).perform
61
66
  end
62
67
  end
63
68
  end
@@ -38,7 +38,7 @@ 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, &block).perform
41
+ AddressFinder::Bulk.new(http: http, verification_version: 'v2', &block).perform
42
42
  end
43
43
 
44
44
  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 +50,7 @@ RSpec.describe AddressFinder::Bulk do
50
50
  expect(net_http).to receive(:transport_request).once.and_raise(SocketError) # Retry 2 Willis (error)
51
51
  expect(net_http).to receive(:transport_request).exactly(2).and_return(response) # Retry 2 Willis (success) & 3 Willis (success)
52
52
  expect(net_http).to receive(:do_finish).exactly(4).times.and_call_original
53
- AddressFinder::Bulk.new(http: http, &block).perform
53
+ AddressFinder::Bulk.new(http: http, verification_version: 'v2', &block).perform
54
54
  end
55
55
  end
56
56
 
@@ -66,7 +66,7 @@ RSpec.describe AddressFinder::Bulk do
66
66
  expect(net_http).to receive(:do_start).once.and_call_original
67
67
  expect(net_http).to receive(:transport_request).once.and_return(response)
68
68
  expect(net_http).to receive(:do_finish).once.and_call_original
69
- AddressFinder::Bulk.new(http: http, &block).perform
69
+ AddressFinder::Bulk.new(http: http, verification_version: 'v2', &block).perform
70
70
  end
71
71
  end
72
72
  end
@@ -0,0 +1,187 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe AddressFinder::V2::Au::Verification do
4
+ before do
5
+ AddressFinder.configure do |af|
6
+ af.api_key = 'XXX'
7
+ af.api_secret = 'YYY'
8
+ af.timeout = 5
9
+ af.retries = 3
10
+ end
11
+ end
12
+
13
+ let(:verification_module){ AddressFinder::V2::Au::Verification.new(args) }
14
+ let(:http){ AddressFinder::HTTP.new(AddressFinder.configuration) }
15
+ let(:net_http){ http.send(:net_http) }
16
+
17
+ describe '#execute_request' do
18
+ let(:args){ {q: "186 Willis Street", http: http} }
19
+
20
+ before do
21
+ WebMock.allow_net_connect!(net_http_connect_on_start: true)
22
+ allow(http).to receive(:sleep)
23
+ allow(verification_module).to receive(:request_uri).and_return("/test/path")
24
+ expect(http).to_not receive(:re_establish_connection)
25
+ end
26
+
27
+ after do
28
+ WebMock.disable_net_connect!
29
+ end
30
+
31
+ subject(:execute_request){ verification_module.send(:execute_request) }
32
+
33
+ it "retries an errored request another time before succeeding" do
34
+ expect(net_http).to receive(:do_start).twice.and_call_original
35
+ expect(net_http).to receive(:transport_request).once.and_raise(Net::OpenTimeout)
36
+ expect(net_http).to receive(:transport_request).once.and_return(double(:response, body: "OK", code: "200"))
37
+ expect(net_http).to receive(:do_finish).twice.and_call_original
38
+ execute_request
39
+ end
40
+
41
+ it "re-raises a Net::OpenTimeout error after 3 retries" do
42
+ expect(net_http).to receive(:do_start).exactly(4).times.and_call_original
43
+ expect(net_http).to receive(:transport_request).exactly(4).times.and_raise(Net::OpenTimeout)
44
+ expect(net_http).to receive(:do_finish).exactly(4).times.and_call_original
45
+ expect{execute_request}.to raise_error(Net::OpenTimeout)
46
+ end
47
+
48
+ it "re-raises a Net::ReadTimeout error after 3 retries" do
49
+ expect(net_http).to receive(:do_start).exactly(4).times.and_call_original
50
+ expect(net_http).to receive(:transport_request).exactly(4).times.and_raise(Net::ReadTimeout)
51
+ expect(net_http).to receive(:do_finish).exactly(4).times.and_call_original
52
+ expect{execute_request}.to raise_error(Net::ReadTimeout)
53
+ end
54
+
55
+ it "re-raises a SocketError error after 3 retries" do
56
+ expect(net_http).to receive(:do_start).exactly(4).times.and_call_original
57
+ expect(net_http).to receive(:transport_request).exactly(4).times.and_raise(SocketError)
58
+ expect(net_http).to receive(:do_finish).exactly(4).times.and_call_original
59
+ expect{execute_request}.to raise_error(SocketError)
60
+ end
61
+ end
62
+
63
+ describe '#build_request' do
64
+ subject(:request_uri){ verification_module.send(:build_request) }
65
+
66
+ context 'with minimal arguments' do
67
+ let(:args){ {q: '186 willis st', http: http} }
68
+
69
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186+willis+st&key=XXX&secret=YYY&format=json') }
70
+ end
71
+
72
+ context 'with more arguments' do
73
+ let(:args){ {q: '186 willis st', census: '2011', http: http} }
74
+
75
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186+willis+st&census=2011&key=XXX&secret=YYY&format=json') }
76
+ end
77
+
78
+ context 'with a state codes as an array' do
79
+ let(:args){ {q: '186 willis st', state_codes: ['ACT','NSW'], http: http} }
80
+
81
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186+willis+st&key=XXX&secret=YYY&state_codes[]=ACT&state_codes[]=NSW&format=json') }
82
+ end
83
+
84
+ context 'with a reserved character in the query' do
85
+ let(:args){ {q: '186=willis st', state_codes: ['ACT','NSW'], http: http} }
86
+
87
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186%3Dwillis+st&key=XXX&secret=YYY&state_codes[]=ACT&state_codes[]=NSW&format=json') }
88
+ end
89
+
90
+ context 'with a state codes as a string' do
91
+ let(:args){ {q: '186 willis st', state_codes: 'ACT,NSW', http: http} }
92
+
93
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186+willis+st&key=XXX&secret=YYY&state_codes=ACT%2CNSW&format=json') }
94
+ end
95
+
96
+ context 'with a key override' do
97
+ let(:args){ {q: '186 willis st', key: 'AAA', http: http} }
98
+
99
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186+willis+st&key=AAA&secret=YYY&format=json') }
100
+ end
101
+
102
+ context 'with a secret override' do
103
+ let(:args){ {q: '186 willis st', secret: 'BBB', http: http} }
104
+
105
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186+willis+st&key=XXX&secret=BBB&format=json') }
106
+ end
107
+
108
+ context 'with a domain given' do
109
+ let(:args){ {q: '123', domain: 'testdomain.com', http: http} }
110
+
111
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=123&domain=testdomain.com&key=XXX&secret=YYY&format=json') }
112
+
113
+ context 'given in the AF configuration' do
114
+
115
+ let(:args){ {q: '123', http: http} }
116
+
117
+ it 'should use the config domain if set' do
118
+ AddressFinder.configuration.domain = 'anotherdomain.com'
119
+ # expect(request_uri).to eq('/api/au/address/v2/verification?q=123&domain=anotherdomain.com&key=XXX&secret=YYY&format=json')
120
+ AddressFinder.configuration.domain = nil # set back to nil after
121
+ end
122
+ end
123
+ end
124
+
125
+ context 'with a post_box exclusion' do
126
+ let(:args){ {q: '186 willis st', post_box: '0', http: http} }
127
+
128
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186+willis+st&post_box=0&key=XXX&secret=YYY&format=json') }
129
+ end
130
+
131
+ context 'with a gnaf request' do
132
+ let(:args){ {q: '186 willis st', gnaf: '1', http: http} }
133
+
134
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186+willis+st&key=XXX&secret=YYY&gnaf=1&format=json') }
135
+ end
136
+
137
+ context 'with a paf request' do
138
+ let(:args){ {q: '186 willis st', paf: '1', http: http} }
139
+
140
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186+willis+st&key=XXX&secret=YYY&paf=1&format=json') }
141
+ end
142
+
143
+ context 'with a all args included request' do
144
+ let(:args){ {q: '186 willis st', paf: '1', gnaf:'1', post_box:'0', state_codes:'ACT', census: '2016', domain: 'mysite.com', gps: '1', extended: '1', http: http} }
145
+
146
+ it { expect(request_uri).to eq('/api/au/address/v2/verification?q=186+willis+st&post_box=0&census=2016&domain=mysite.com&key=XXX&secret=YYY&paf=1&gnaf=1&gps=1&extended=1&state_codes=ACT&format=json') }
147
+ end
148
+ end
149
+
150
+ describe '#build_result' do
151
+ let(:args){ {q: 'ignored', http: nil} }
152
+
153
+ before do
154
+ verification_module.send('response_body=', body)
155
+ verification_module.send('response_status=', status)
156
+ end
157
+
158
+ subject(:result){ verification_module.send(:build_result) }
159
+
160
+ context 'with a successful nz result' do
161
+ let(:body){ '{"matched": true, "postal_address": "Texas"}' }
162
+ let(:status){ '200' }
163
+
164
+ it { expect(result.class).to eq(AddressFinder::V2::Au::Verification::Result) }
165
+
166
+ it { expect(result.matched).to eq(true) }
167
+
168
+ it { expect(result.postal_address).to eq("Texas") }
169
+ end
170
+
171
+ context 'with a successful au result' do
172
+ let(:body){ %Q({"matched": true, "success": true, "address": {"full_address": "Texas"}}) }
173
+ let(:status){ '200' }
174
+
175
+ it { expect(result.class).to eq(AddressFinder::V2::Au::Verification::Result) }
176
+
177
+ it { expect(result.full_address).to eq("Texas") }
178
+ end
179
+
180
+ context 'with an unfound result' do
181
+ let(:body){ '{"matched": false}' }
182
+ let(:status){ '200' }
183
+
184
+ it { expect(result).to eq(nil) }
185
+ end
186
+ end
187
+ end
@@ -67,55 +67,55 @@ RSpec.describe AddressFinder::Verification do
67
67
  context 'with minimal arguments' do
68
68
  let(:args){ {q: '186 willis st', http: http} }
69
69
 
70
- it { expect(request_uri).to eq('/api/nz/address/verification?q=186+willis+st&format=json&key=XXX&secret=YYY') }
70
+ it { expect(request_uri).to eq('/api/nz/address/verification?q=186+willis+st&key=XXX&secret=YYY&format=json') }
71
71
  end
72
72
 
73
73
  context 'with more arguments' do
74
- let(:args){ {q: '186 willis st', delivered: true, region_code: 'A', paf: '1', census: '2013', http: http} }
74
+ let(:args){ {q: '186 willis st', delivered: true, region_code: 'A', census: '2013', http: http} }
75
75
 
76
- it { expect(request_uri).to eq('/api/nz/address/verification?q=186+willis+st&delivered=true&paf=1&region_code=A&census=2013&format=json&key=XXX&secret=YYY') }
76
+ it { expect(request_uri).to eq('/api/nz/address/verification?q=186+willis+st&census=2013&key=XXX&secret=YYY&delivered=true&region_code=A&format=json') }
77
77
  end
78
78
 
79
79
  context 'with a country override' do
80
80
  let(:args){ {q: '186 willis st', country: 'au', http: http} }
81
81
 
82
- it { expect(request_uri).to eq('/api/au/address/verification?q=186+willis+st&format=json&key=XXX&secret=YYY') }
82
+ it { expect(request_uri).to eq('/api/au/address/verification?q=186+willis+st&key=XXX&secret=YYY&format=json') }
83
83
  end
84
84
 
85
85
  context 'with a state codes as an array' do
86
86
  let(:args){ {q: '186 willis st', country: 'au', state_codes: ['ACT','NSW'], http: http} }
87
87
 
88
- it { expect(request_uri).to eq('/api/au/address/verification?q=186+willis+st&state_codes[]=ACT&state_codes[]=NSW&format=json&key=XXX&secret=YYY') }
88
+ it { expect(request_uri).to eq('/api/au/address/verification?q=186+willis+st&key=XXX&secret=YYY&state_codes[]=ACT&state_codes[]=NSW&format=json') }
89
89
  end
90
90
 
91
91
  context 'with a reserved character in the query' do
92
92
  let(:args){ {q: '186=willis st', country: 'au', state_codes: ['ACT','NSW'], http: http} }
93
93
 
94
- it { expect(request_uri).to eq('/api/au/address/verification?q=186%3Dwillis+st&state_codes[]=ACT&state_codes[]=NSW&format=json&key=XXX&secret=YYY') }
94
+ it { expect(request_uri).to eq('/api/au/address/verification?q=186%3Dwillis+st&key=XXX&secret=YYY&state_codes[]=ACT&state_codes[]=NSW&format=json') }
95
95
  end
96
96
 
97
97
  context 'with a state codes as a string' do
98
98
  let(:args){ {q: '186 willis st', country: 'au', state_codes: 'ACT,NSW', http: http} }
99
99
 
100
- it { expect(request_uri).to eq('/api/au/address/verification?q=186+willis+st&state_codes=ACT%2CNSW&format=json&key=XXX&secret=YYY') }
100
+ it { expect(request_uri).to eq('/api/au/address/verification?q=186+willis+st&key=XXX&secret=YYY&state_codes=ACT%2CNSW&format=json') }
101
101
  end
102
102
 
103
103
  context 'with a key override' do
104
104
  let(:args){ {q: '186 willis st', key: 'AAA', http: http} }
105
105
 
106
- it { expect(request_uri).to eq('/api/nz/address/verification?q=186+willis+st&format=json&key=AAA&secret=YYY') }
106
+ it { expect(request_uri).to eq('/api/nz/address/verification?q=186+willis+st&key=AAA&secret=YYY&format=json') }
107
107
  end
108
108
 
109
109
  context 'with a secret override' do
110
110
  let(:args){ {q: '186 willis st', secret: 'BBB', http: http} }
111
111
 
112
- it { expect(request_uri).to eq('/api/nz/address/verification?q=186+willis+st&format=json&key=XXX&secret=BBB') }
112
+ it { expect(request_uri).to eq('/api/nz/address/verification?q=186+willis+st&key=XXX&secret=BBB&format=json') }
113
113
  end
114
114
 
115
115
  context 'with a domain given' do
116
116
  let(:args){ {q: '123', domain: 'testdomain.com', http: http} }
117
117
 
118
- it { expect(request_uri).to eq('/api/nz/address/verification?q=123&domain=testdomain.com&format=json&key=XXX&secret=YYY') }
118
+ it { expect(request_uri).to eq('/api/nz/address/verification?q=123&domain=testdomain.com&key=XXX&secret=YYY&format=json') }
119
119
 
120
120
  context 'given in the AF configuration' do
121
121
 
@@ -123,7 +123,7 @@ RSpec.describe AddressFinder::Verification do
123
123
 
124
124
  it 'should use the config domain if set' do
125
125
  AddressFinder.configuration.domain = 'anotherdomain.com'
126
- expect(request_uri).to eq('/api/nz/address/verification?q=123&domain=anotherdomain.com&format=json&key=XXX&secret=YYY')
126
+ expect(request_uri).to eq('/api/nz/address/verification?q=123&domain=anotherdomain.com&key=XXX&secret=YYY&format=json')
127
127
  AddressFinder.configuration.domain = nil # set back to nil after
128
128
  end
129
129
  end
data/spec/spec_helper.rb CHANGED
@@ -12,6 +12,9 @@ require 'addressfinder'
12
12
 
13
13
  RSpec.configure do |config|
14
14
  config.mock_with :rspec
15
+
16
+ config.filter_run :focus => true
17
+ config.run_all_when_everything_filtered = true
15
18
  end
16
19
 
17
20
  WebMock.disable_net_connect!
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.7.1
4
+ version: 1.8.0
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-07-02 00:00:00.000000000 Z
15
+ date: 2021-10-25 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: multi_json
@@ -131,6 +131,7 @@ files:
131
131
  - lib/addressfinder/location_info.rb
132
132
  - lib/addressfinder/location_search.rb
133
133
  - lib/addressfinder/util.rb
134
+ - lib/addressfinder/v2/au/verification.rb
134
135
  - lib/addressfinder/verification.rb
135
136
  - lib/addressfinder/version.rb
136
137
  - spec/lib/addressfinder/address_autocomplete_spec.rb
@@ -140,6 +141,7 @@ files:
140
141
  - spec/lib/addressfinder/location_info_spec.rb
141
142
  - spec/lib/addressfinder/location_search_spec.rb
142
143
  - spec/lib/addressfinder/util_spec.rb
144
+ - spec/lib/addressfinder/v2/au/verification_spec.rb
143
145
  - spec/lib/addressfinder/verification_spec.rb
144
146
  - spec/spec_helper.rb
145
147
  homepage: https://github.com/AddressFinder/addressfinder-ruby
@@ -173,5 +175,6 @@ test_files:
173
175
  - spec/lib/addressfinder/location_info_spec.rb
174
176
  - spec/lib/addressfinder/location_search_spec.rb
175
177
  - spec/lib/addressfinder/util_spec.rb
178
+ - spec/lib/addressfinder/v2/au/verification_spec.rb
176
179
  - spec/lib/addressfinder/verification_spec.rb
177
180
  - spec/spec_helper.rb