addressfinder 1.5.1 → 1.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +2 -1
- data/lib/addressfinder.rb +1 -0
- data/lib/addressfinder/address_info.rb +1 -2
- data/lib/addressfinder/address_search.rb +1 -2
- data/lib/addressfinder/cleanse.rb +2 -6
- data/lib/addressfinder/location_info.rb +1 -2
- data/lib/addressfinder/location_search.rb +1 -2
- data/lib/addressfinder/util.rb +12 -0
- data/lib/addressfinder/version.rb +1 -1
- data/spec/lib/addressfinder/address_search_spec.rb +5 -5
- data/spec/lib/addressfinder/cleanse_spec.rb +14 -33
- data/spec/lib/addressfinder/location_search_spec.rb +4 -4
- data/spec/lib/addressfinder/util_spec.rb +37 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05ba956f56eb4abdf67174b1c8dc8fa60e429855
|
4
|
+
data.tar.gz: 473d3c098ab85f3255409d42fc114dbbddd278bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9056caa0b3632c4069dc0f78fea84c876fa3fda0438af6cd771bee2a09aab93087e912decf5eabf923b442994360ec09c063f62d014ea86dd959be1dbf031082
|
7
|
+
data.tar.gz: 0d20f2503daaeed9e724231973414731e65bfa4aa468f37ad7dadd059b226832bdf0f1ac3eadd49fbc395dc746cf5887e092e98691e9aa09ff4473764c1cba24
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# AddressFinder 1.5.2 (December 21, 2015) #
|
2
|
+
|
3
|
+
* Update for the nested response format used in Address Cleanse Australia
|
4
|
+
* Add an encoding helper which uses CGI::escape
|
5
|
+
|
1
6
|
# AddressFinder 1.5.1 (November 25, 2015) #
|
2
7
|
|
3
8
|
* Update the ClientProxy #cleanse method to return result instead of an AddressFinder::Cleanse instance
|
data/README.md
CHANGED
@@ -50,11 +50,12 @@ You can obtain your API key and secret from the AddressFinder Portal.
|
|
50
50
|
See the documentation on the available parameters and expected response here:
|
51
51
|
|
52
52
|
https://addressfinder.nz/docs/address_cleanse_api/
|
53
|
+
https://addressfinder.com.au/docs/address_cleanse_api/
|
53
54
|
|
54
55
|
Usage example:
|
55
56
|
|
56
57
|
```ruby
|
57
|
-
result = AddressFinder.cleanse(q: '186 Willis St, Wellington')
|
58
|
+
result = AddressFinder.cleanse(q: '186 Willis St, Wellington', country: 'nz')
|
58
59
|
|
59
60
|
if result
|
60
61
|
$stdout.puts "Success: #{result.postal}"
|
data/lib/addressfinder.rb
CHANGED
@@ -53,18 +53,14 @@ module AddressFinder
|
|
53
53
|
end
|
54
54
|
|
55
55
|
if response_hash['matched']
|
56
|
-
self.result = Result.new(response_hash)
|
56
|
+
self.result = Result.new(response_hash['address'] || response_hash)
|
57
57
|
else
|
58
58
|
self.result = nil
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
def encoded_params
|
63
|
-
|
64
|
-
"#{k}=#{ERB::Util.url_encode(v)}"
|
65
|
-
end
|
66
|
-
|
67
|
-
query_params.join('&')
|
63
|
+
Util.encode_and_join_params(params)
|
68
64
|
end
|
69
65
|
|
70
66
|
def response_hash
|
@@ -18,31 +18,31 @@ RSpec.describe AddressFinder::AddressSearch do
|
|
18
18
|
context 'with minimal arguments' do
|
19
19
|
let(:args){ {q: '186 willis'} }
|
20
20
|
|
21
|
-
it { expect(request_uri).to eq('/api/nz/address.json?q=186
|
21
|
+
it { expect(request_uri).to eq('/api/nz/address.json?q=186+willis&key=XXX&secret=YYY') }
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'with more arguments' do
|
25
25
|
let(:args){ {q: '186 willis st', delivered: 1, max: 10} }
|
26
26
|
|
27
|
-
it { expect(request_uri).to eq('/api/nz/address.json?q=186
|
27
|
+
it { expect(request_uri).to eq('/api/nz/address.json?q=186+willis+st&delivered=1&max=10&key=XXX&secret=YYY') }
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'with a country override' do
|
31
31
|
let(:args){ {q: '186 willis st', country: 'au'} }
|
32
32
|
|
33
|
-
it { expect(request_uri).to eq('/api/au/address.json?q=186
|
33
|
+
it { expect(request_uri).to eq('/api/au/address.json?q=186+willis+st&key=XXX&secret=YYY') }
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'with a key override' do
|
37
37
|
let(:args){ {q: '186 willis st', key: 'AAA'} }
|
38
38
|
|
39
|
-
it { expect(request_uri).to eq('/api/nz/address.json?q=186
|
39
|
+
it { expect(request_uri).to eq('/api/nz/address.json?q=186+willis+st&key=AAA&secret=YYY') }
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'with a secret override' do
|
43
43
|
let(:args){ {q: '186 willis st', secret: 'BBB'} }
|
44
44
|
|
45
|
-
it { expect(request_uri).to eq('/api/nz/address.json?q=186
|
45
|
+
it { expect(request_uri).to eq('/api/nz/address.json?q=186+willis+st&secret=BBB&key=XXX') }
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -18,31 +18,31 @@ RSpec.describe AddressFinder::Cleanse do
|
|
18
18
|
context 'with minimal arguments' do
|
19
19
|
let(:args){ {q: '186 willis st', http: http} }
|
20
20
|
|
21
|
-
it { expect(request_uri).to eq('/api/nz/address/cleanse?q=186
|
21
|
+
it { expect(request_uri).to eq('/api/nz/address/cleanse?q=186+willis+st&format=json&key=XXX&secret=YYY') }
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'with more arguments' do
|
25
25
|
let(:args){ {q: '186 willis st', delivered: true, region_code: 'A', http: http} }
|
26
26
|
|
27
|
-
it { expect(request_uri).to eq('/api/nz/address/cleanse?q=186
|
27
|
+
it { expect(request_uri).to eq('/api/nz/address/cleanse?q=186+willis+st&delivered=true®ion_code=A&format=json&key=XXX&secret=YYY') }
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'with a country override' do
|
31
31
|
let(:args){ {q: '186 willis st', country: 'au', http: http} }
|
32
32
|
|
33
|
-
it { expect(request_uri).to eq('/api/au/address/cleanse?q=186
|
33
|
+
it { expect(request_uri).to eq('/api/au/address/cleanse?q=186+willis+st&format=json&key=XXX&secret=YYY') }
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'with a key override' do
|
37
37
|
let(:args){ {q: '186 willis st', key: 'AAA', http: http} }
|
38
38
|
|
39
|
-
it { expect(request_uri).to eq('/api/nz/address/cleanse?q=186
|
39
|
+
it { expect(request_uri).to eq('/api/nz/address/cleanse?q=186+willis+st&format=json&key=AAA&secret=YYY') }
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'with a secret override' do
|
43
43
|
let(:args){ {q: '186 willis st', secret: 'BBB', http: http} }
|
44
44
|
|
45
|
-
it { expect(request_uri).to eq('/api/nz/address/cleanse?q=186
|
45
|
+
it { expect(request_uri).to eq('/api/nz/address/cleanse?q=186+willis+st&format=json&key=XXX&secret=BBB') }
|
46
46
|
end
|
47
47
|
|
48
48
|
context 'with a domain given' do
|
@@ -73,7 +73,7 @@ RSpec.describe AddressFinder::Cleanse do
|
|
73
73
|
|
74
74
|
subject(:result){ cleanser.send(:build_result) }
|
75
75
|
|
76
|
-
context 'with a successful result' do
|
76
|
+
context 'with a successful nz result' do
|
77
77
|
let(:body){ '{"matched": true, "postal_address": "Texas"}' }
|
78
78
|
let(:status){ '200' }
|
79
79
|
|
@@ -84,39 +84,20 @@ RSpec.describe AddressFinder::Cleanse do
|
|
84
84
|
it { expect(result.postal_address).to eq("Texas") }
|
85
85
|
end
|
86
86
|
|
87
|
-
context 'with
|
88
|
-
let(:body){
|
87
|
+
context 'with a successful au result' do
|
88
|
+
let(:body){ %Q({"matched": true, "success": true, "address": {"full_address": "Texas"}}) }
|
89
89
|
let(:status){ '200' }
|
90
90
|
|
91
|
-
it { expect(result).to eq(
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
describe '#encoded_params' do
|
96
|
-
subject(:encoded_params){ AddressFinder::Cleanse.new(q: q, http: nil).send(:encoded_params) }
|
97
|
-
|
98
|
-
context 'with a question mark value' do
|
99
|
-
let(:q){ '?' }
|
100
|
-
|
101
|
-
it { expect(encoded_params).to eq('q=%3F&format=json&key=XXX&secret=YYY') }
|
102
|
-
end
|
103
|
-
|
104
|
-
context 'with a normal address value' do
|
105
|
-
let(:q){ '12 high' }
|
106
|
-
|
107
|
-
it { expect(encoded_params).to eq('q=12%20high&format=json&key=XXX&secret=YYY') }
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'with a blank value' do
|
111
|
-
let(:q){ '' }
|
91
|
+
it { expect(result.class).to eq(AddressFinder::Cleanse::Result) }
|
112
92
|
|
113
|
-
it { expect(
|
93
|
+
it { expect(result.full_address).to eq("Texas") }
|
114
94
|
end
|
115
95
|
|
116
|
-
context 'with
|
117
|
-
let(:
|
96
|
+
context 'with an unfound result' do
|
97
|
+
let(:body){ '{"matched": false}' }
|
98
|
+
let(:status){ '200' }
|
118
99
|
|
119
|
-
it { expect(
|
100
|
+
it { expect(result).to eq(nil) }
|
120
101
|
end
|
121
102
|
end
|
122
103
|
end
|
@@ -24,25 +24,25 @@ RSpec.describe AddressFinder::LocationSearch do
|
|
24
24
|
context 'with more arguments' do
|
25
25
|
let(:args){ {q: 'willis st', street: 1, max: 10} }
|
26
26
|
|
27
|
-
it { expect(request_uri).to eq('/api/nz/location.json?q=willis
|
27
|
+
it { expect(request_uri).to eq('/api/nz/location.json?q=willis+st&street=1&max=10&key=XXX&secret=YYY') }
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'with a country override' do
|
31
31
|
let(:args){ {q: 'willis st', country: 'au'} }
|
32
32
|
|
33
|
-
it { expect(request_uri).to eq('/api/au/location.json?q=willis
|
33
|
+
it { expect(request_uri).to eq('/api/au/location.json?q=willis+st&key=XXX&secret=YYY') }
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'with a key override' do
|
37
37
|
let(:args){ {q: 'willis st', key: 'AAA'} }
|
38
38
|
|
39
|
-
it { expect(request_uri).to eq('/api/nz/location.json?q=willis
|
39
|
+
it { expect(request_uri).to eq('/api/nz/location.json?q=willis+st&key=AAA&secret=YYY') }
|
40
40
|
end
|
41
41
|
|
42
42
|
context 'with a secret override' do
|
43
43
|
let(:args){ {q: 'willis st', secret: 'BBB'} }
|
44
44
|
|
45
|
-
it { expect(request_uri).to eq('/api/nz/location.json?q=willis
|
45
|
+
it { expect(request_uri).to eq('/api/nz/location.json?q=willis+st&secret=BBB&key=XXX') }
|
46
46
|
end
|
47
47
|
|
48
48
|
context 'with a domain given' do
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'addressfinder/util'
|
2
|
+
|
3
|
+
RSpec.describe AddressFinder::Util do
|
4
|
+
describe '.encode_and_join_params' do
|
5
|
+
subject { AddressFinder::Util.encode_and_join_params(params) }
|
6
|
+
|
7
|
+
context 'with a question mark value' do
|
8
|
+
let(:params){ {q:'?',format:'json',key:'XXX',secret:'YYY'} }
|
9
|
+
|
10
|
+
it { is_expected.to eq('q=%3F&format=json&key=XXX&secret=YYY') }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'with an ampersand value' do
|
14
|
+
let(:params){ {q:'&',format:'json',key:'XXX',secret:'YYY'} }
|
15
|
+
|
16
|
+
it { is_expected.to eq('q=%26&format=json&key=XXX&secret=YYY') }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'with a normal address value' do
|
20
|
+
let(:params){ {q:'12 high',format:'json',key:'XXX',secret:'YYY'} }
|
21
|
+
|
22
|
+
it { is_expected.to eq('q=12+high&format=json&key=XXX&secret=YYY') }
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with a blank value' do
|
26
|
+
let(:params){ {q:'',format:'json',key:'XXX',secret:'YYY'} }
|
27
|
+
|
28
|
+
it { is_expected.to eq('q=&format=json&key=XXX&secret=YYY') }
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'with a nil value' do
|
32
|
+
let(:params){ {q:nil,format:'json',key:'XXX',secret:'YYY'} }
|
33
|
+
|
34
|
+
it { is_expected.to eq('q=&format=json&key=XXX&secret=YYY') }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
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.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nigel Ramsay
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-12-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: multi_json
|
@@ -111,12 +111,14 @@ files:
|
|
111
111
|
- lib/addressfinder/errors.rb
|
112
112
|
- lib/addressfinder/location_info.rb
|
113
113
|
- lib/addressfinder/location_search.rb
|
114
|
+
- lib/addressfinder/util.rb
|
114
115
|
- lib/addressfinder/version.rb
|
115
116
|
- spec/lib/addressfinder/address_info_spec.rb
|
116
117
|
- spec/lib/addressfinder/address_search_spec.rb
|
117
118
|
- spec/lib/addressfinder/cleanse_spec.rb
|
118
119
|
- spec/lib/addressfinder/location_info_spec.rb
|
119
120
|
- spec/lib/addressfinder/location_search_spec.rb
|
121
|
+
- spec/lib/addressfinder/util_spec.rb
|
120
122
|
- spec/spec_helper.rb
|
121
123
|
homepage: https://github.com/AbleTech/addressfinder-ruby
|
122
124
|
licenses:
|
@@ -148,4 +150,5 @@ test_files:
|
|
148
150
|
- spec/lib/addressfinder/cleanse_spec.rb
|
149
151
|
- spec/lib/addressfinder/location_info_spec.rb
|
150
152
|
- spec/lib/addressfinder/location_search_spec.rb
|
153
|
+
- spec/lib/addressfinder/util_spec.rb
|
151
154
|
- spec/spec_helper.rb
|