addressfinder 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +32 -0
- data/addressfinder.gemspec +2 -2
- data/lib/addressfinder/address_info.rb +2 -2
- data/lib/addressfinder/address_search.rb +2 -2
- data/lib/addressfinder/cleanse.rb +3 -3
- data/lib/addressfinder/location_info.rb +2 -2
- data/lib/addressfinder/location_search.rb +2 -2
- data/lib/addressfinder/version.rb +1 -1
- data/spec/lib/addressfinder/address_info_spec.rb +14 -2
- data/spec/lib/addressfinder/address_search_spec.rb +12 -0
- data/spec/lib/addressfinder/cleanse_spec.rb +12 -0
- data/spec/lib/addressfinder/location_info_spec.rb +14 -2
- data/spec/lib/addressfinder/location_search_spec.rb +12 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd5b1ce66a9ed764e1e42cb407b2ca8887f17769
|
4
|
+
data.tar.gz: d611d57cdf18997cd16118428304d7601caecd75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fb527e911f117fae0d47756baf63613c602085014bf9cb2576b6d0d1fd28798ebd45bda55e446c0b7f52126cc006d745d3a8958651cec51640de0de99d727e3
|
7
|
+
data.tar.gz: 0dceb57bfa8962fc79ef50405342735814a57e5f39be9d010bec8999e467f05a184f50d77f44a0a93447e3f97988de2b49f54ca54b434a98da0f7c06d4d60374
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -171,3 +171,35 @@ AddressFinder.bulk do |af|
|
|
171
171
|
end
|
172
172
|
end
|
173
173
|
```
|
174
|
+
|
175
|
+
## Advanced Usage
|
176
|
+
|
177
|
+
### Key and Secret Override
|
178
|
+
|
179
|
+
What if you want to use another acccount for a specific query using the AddressFinder gem in your ruby app?
|
180
|
+
|
181
|
+
You can override the `api_key` and `api_secret` set in the AddressFinder.configure block in `./config/initializers/addressfinder.rb` when using the AddressFinder gem.
|
182
|
+
|
183
|
+
Those AddressFinder methods accept `:key` and `:secret` arguments:
|
184
|
+
- `#cleanse`,
|
185
|
+
- `#location_search`,
|
186
|
+
- `#location_info`,
|
187
|
+
- `#address_search`
|
188
|
+
- `#address_info`
|
189
|
+
|
190
|
+
Usage example:
|
191
|
+
|
192
|
+
```ruby
|
193
|
+
begin
|
194
|
+
result = AddressFinder.address_info(pxid: '1-.B.3l', key: 'AAAAAAAAAAAAA', secret: 'BBBBBBBBBBBBB')
|
195
|
+
if result
|
196
|
+
$standout.puts "Success: #{result.a}"
|
197
|
+
else
|
198
|
+
$standout.puts "Sorry, can't find that address"
|
199
|
+
end
|
200
|
+
rescue AddressFinder::RequestRejectedError => e
|
201
|
+
response = JSON.parse(e.body)
|
202
|
+
$standout.puts response['message']
|
203
|
+
end
|
204
|
+
```
|
205
|
+
|
data/addressfinder.gemspec
CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |gem|
|
|
5
5
|
gem.name = "addressfinder"
|
6
6
|
gem.version = AddressFinder::VERSION
|
7
7
|
gem.licenses = ['MIT']
|
8
|
-
gem.authors = ["Nigel Ramsay", "Naiki Pohe", "Sean Arnold"]
|
9
|
-
gem.email = ["nigel.ramsay@abletech.co.nz", "naiki.pohe@abletech.co.nz", "seanarnie@gmail.com"]
|
8
|
+
gem.authors = ["Nigel Ramsay", "Naiki Pohe", "Sean Arnold", "Alexandre Barret"]
|
9
|
+
gem.email = ["nigel.ramsay@abletech.co.nz", "naiki.pohe@abletech.co.nz", "seanarnie@gmail.com", "alex@abletech.nz"]
|
10
10
|
gem.description = %q{Ruby client library for AddressFinder}
|
11
11
|
gem.summary = %q{Provides easy access to AddressFinder APIs}
|
12
12
|
gem.homepage = "https://github.com/AbleTech/addressfinder-ruby"
|
@@ -10,8 +10,8 @@ module AddressFinder
|
|
10
10
|
@country = params.delete(:country) || config.default_country
|
11
11
|
|
12
12
|
@params = params
|
13
|
-
@params[
|
14
|
-
@params[
|
13
|
+
@params[:key] ||= config.api_key
|
14
|
+
@params[:secret] ||= config.api_secret
|
15
15
|
end
|
16
16
|
|
17
17
|
def perform
|
@@ -10,8 +10,8 @@ module AddressFinder
|
|
10
10
|
@country = params.delete(:country) || config.default_country
|
11
11
|
|
12
12
|
@params = params
|
13
|
-
@params[
|
14
|
-
@params[
|
13
|
+
@params[:key] ||= config.api_key
|
14
|
+
@params[:secret] ||= config.api_secret
|
15
15
|
end
|
16
16
|
|
17
17
|
def perform
|
@@ -5,7 +5,7 @@ module AddressFinder
|
|
5
5
|
|
6
6
|
attr_reader :result
|
7
7
|
|
8
|
-
def initialize(q:, country: nil, delivered: nil, post_box: nil, rural: nil, region_code: nil, domain: nil, http:)
|
8
|
+
def initialize(q:, country: nil, delivered: nil, post_box: nil, rural: nil, region_code: nil, domain: nil, key: nil, secret: nil, http:)
|
9
9
|
@params = {}
|
10
10
|
@params['q'] = q
|
11
11
|
@params['delivered'] = delivered if delivered
|
@@ -14,8 +14,8 @@ module AddressFinder
|
|
14
14
|
@params['region_code'] = region_code if region_code
|
15
15
|
@params['domain'] = domain || config.domain if (domain || config.domain)
|
16
16
|
@params['format'] = 'json'
|
17
|
-
@params['key'] = config.api_key
|
18
|
-
@params['secret'] = config.api_secret
|
17
|
+
@params['key'] = key || config.api_key
|
18
|
+
@params['secret'] = secret || config.api_secret
|
19
19
|
@country = country || config.default_country
|
20
20
|
@http = http
|
21
21
|
end
|
@@ -11,8 +11,8 @@ module AddressFinder
|
|
11
11
|
|
12
12
|
@params = params
|
13
13
|
@params['domain'] = params['domain'] || config.domain if (params['domain'] || config.domain)
|
14
|
-
@params[
|
15
|
-
@params[
|
14
|
+
@params[:key] ||= config.api_key
|
15
|
+
@params[:secret] ||= config.api_secret
|
16
16
|
end
|
17
17
|
|
18
18
|
def perform
|
@@ -11,8 +11,8 @@ module AddressFinder
|
|
11
11
|
|
12
12
|
@params = params
|
13
13
|
@params['domain'] = params['domain'] || config.domain if (params['domain'] || config.domain)
|
14
|
-
@params[
|
15
|
-
@params[
|
14
|
+
@params[:key] ||= config.api_key
|
15
|
+
@params[:secret] ||= config.api_secret
|
16
16
|
end
|
17
17
|
|
18
18
|
def perform
|
@@ -22,9 +22,21 @@ RSpec.describe AddressFinder::AddressInfo do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'with a country override' do
|
25
|
-
let(:args){ {pxid: '123'} }
|
25
|
+
let(:args){ {pxid: '123', country: 'nz'} }
|
26
26
|
|
27
|
-
it { expect(request_uri).to eq('/api/
|
27
|
+
it { expect(request_uri).to eq('/api/nz/address/info.json?pxid=123&key=XXX&secret=YYY') }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with a key override' do
|
31
|
+
let(:args){ {pxid: '123', key:'AAA'} }
|
32
|
+
|
33
|
+
it { expect(request_uri).to eq('/api/au/address/info.json?pxid=123&key=AAA&secret=YYY') }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with a secret override' do
|
37
|
+
let(:args){ {pxid: '123', secret: 'BBB'} }
|
38
|
+
|
39
|
+
it { expect(request_uri).to eq('/api/au/address/info.json?pxid=123&secret=BBB&key=XXX') }
|
28
40
|
end
|
29
41
|
end
|
30
42
|
|
@@ -32,6 +32,18 @@ RSpec.describe AddressFinder::AddressSearch do
|
|
32
32
|
|
33
33
|
it { expect(request_uri).to eq('/api/au/address.json?q=186%20willis%20st&key=XXX&secret=YYY') }
|
34
34
|
end
|
35
|
+
|
36
|
+
context 'with a key override' do
|
37
|
+
let(:args){ {q: '186 willis st', key: 'AAA'} }
|
38
|
+
|
39
|
+
it { expect(request_uri).to eq('/api/nz/address.json?q=186%20willis%20st&key=AAA&secret=YYY') }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'with a secret override' do
|
43
|
+
let(:args){ {q: '186 willis st', secret: 'BBB'} }
|
44
|
+
|
45
|
+
it { expect(request_uri).to eq('/api/nz/address.json?q=186%20willis%20st&secret=BBB&key=XXX') }
|
46
|
+
end
|
35
47
|
end
|
36
48
|
|
37
49
|
describe '#build_result' do
|
@@ -33,6 +33,18 @@ RSpec.describe AddressFinder::Cleanse do
|
|
33
33
|
it { expect(request_uri).to eq('/api/au/address/cleanse?q=186%20willis%20st&format=json&key=XXX&secret=YYY') }
|
34
34
|
end
|
35
35
|
|
36
|
+
context 'with a key override' do
|
37
|
+
let(:args){ {q: '186 willis st', key: 'AAA', http: http} }
|
38
|
+
|
39
|
+
it { expect(request_uri).to eq('/api/nz/address/cleanse?q=186%20willis%20st&format=json&key=AAA&secret=YYY') }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'with a secret override' do
|
43
|
+
let(:args){ {q: '186 willis st', secret: 'BBB', http: http} }
|
44
|
+
|
45
|
+
it { expect(request_uri).to eq('/api/nz/address/cleanse?q=186%20willis%20st&format=json&key=XXX&secret=BBB') }
|
46
|
+
end
|
47
|
+
|
36
48
|
context 'with a domain given' do
|
37
49
|
let(:args){ {q: '123', domain: 'testdomain.com', http: http} }
|
38
50
|
|
@@ -22,9 +22,21 @@ RSpec.describe AddressFinder::LocationInfo do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'with a country override' do
|
25
|
-
let(:args){ {pxid: '123'} }
|
25
|
+
let(:args){ {pxid: '123', country: 'nz'} }
|
26
26
|
|
27
|
-
it { expect(request_uri).to eq('/api/
|
27
|
+
it { expect(request_uri).to eq('/api/nz/location/info.json?pxid=123&key=XXX&secret=YYY') }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with a key override' do
|
31
|
+
let(:args){ {pxid: '123', key: 'AAA'} }
|
32
|
+
|
33
|
+
it { expect(request_uri).to eq('/api/au/location/info.json?pxid=123&key=AAA&secret=YYY') }
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'with a secret override' do
|
37
|
+
let(:args){ {pxid: '123', secret: 'BBB'} }
|
38
|
+
|
39
|
+
it { expect(request_uri).to eq('/api/au/location/info.json?pxid=123&secret=BBB&key=XXX') }
|
28
40
|
end
|
29
41
|
|
30
42
|
context 'with a domain given' do
|
@@ -33,6 +33,18 @@ RSpec.describe AddressFinder::LocationSearch do
|
|
33
33
|
it { expect(request_uri).to eq('/api/au/location.json?q=willis%20st&key=XXX&secret=YYY') }
|
34
34
|
end
|
35
35
|
|
36
|
+
context 'with a key override' do
|
37
|
+
let(:args){ {q: 'willis st', key: 'AAA'} }
|
38
|
+
|
39
|
+
it { expect(request_uri).to eq('/api/nz/location.json?q=willis%20st&key=AAA&secret=YYY') }
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'with a secret override' do
|
43
|
+
let(:args){ {q: 'willis st', secret: 'BBB'} }
|
44
|
+
|
45
|
+
it { expect(request_uri).to eq('/api/nz/location.json?q=willis%20st&secret=BBB&key=XXX') }
|
46
|
+
end
|
47
|
+
|
36
48
|
context 'with a domain given' do
|
37
49
|
let(:args){ {q: '123', domain: 'testdomain.com'} }
|
38
50
|
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: addressfinder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nigel Ramsay
|
8
8
|
- Naiki Pohe
|
9
9
|
- Sean Arnold
|
10
|
+
- Alexandre Barret
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2015-
|
14
|
+
date: 2015-11-24 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: multi_json
|
@@ -87,6 +88,7 @@ email:
|
|
87
88
|
- nigel.ramsay@abletech.co.nz
|
88
89
|
- naiki.pohe@abletech.co.nz
|
89
90
|
- seanarnie@gmail.com
|
91
|
+
- alex@abletech.nz
|
90
92
|
executables: []
|
91
93
|
extensions: []
|
92
94
|
extra_rdoc_files: []
|
@@ -136,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
138
|
version: '0'
|
137
139
|
requirements: []
|
138
140
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.4.
|
141
|
+
rubygems_version: 2.4.8
|
140
142
|
signing_key:
|
141
143
|
specification_version: 4
|
142
144
|
summary: Provides easy access to AddressFinder APIs
|