addressfinder 1.4.0 → 1.5.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3e898a98cb65edda0b68b91cf7dd80f5b1678618
4
- data.tar.gz: ae753e8e1f56f6aee705b7ee8f7fcb58d6063056
3
+ metadata.gz: cd5b1ce66a9ed764e1e42cb407b2ca8887f17769
4
+ data.tar.gz: d611d57cdf18997cd16118428304d7601caecd75
5
5
  SHA512:
6
- metadata.gz: 6bfb48dfc96843b4000dd91bd9df7e78d443fb271c753457b296bb8d1ddabe3944b4f27bad1b3ef8949a8058073a468189ae8d11116df5fda45b4dbcabb42f7f
7
- data.tar.gz: 24efefe0cfc07c40148605f527d57591b7beff0122448e7e7e16fde443dd9f289d449e05e609b0d7301781adee93e3def00a5c939ff20dcde7a2b880325a926b
6
+ metadata.gz: 7fb527e911f117fae0d47756baf63613c602085014bf9cb2576b6d0d1fd28798ebd45bda55e446c0b7f52126cc006d745d3a8958651cec51640de0de99d727e3
7
+ data.tar.gz: 0dceb57bfa8962fc79ef50405342735814a57e5f39be9d010bec8999e467f05a184f50d77f44a0a93447e3f97988de2b49f54ca54b434a98da0f7c06d4d60374
@@ -1,3 +1,7 @@
1
+ # AddressFinder 1.5.0 (October 19, 2015) #
2
+
3
+ * Add support for supplying `key` and `secret` override values in each API call
4
+
1
5
  # AddressFinder 1.4.0 (October 19, 2015) #
2
6
 
3
7
  * Add support for Address Search API
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
+
@@ -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['key'] = config.api_key
14
- @params['secret'] = config.api_secret
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['key'] = config.api_key
14
- @params['secret'] = config.api_secret
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['key'] = config.api_key
15
- @params['secret'] = config.api_secret
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['key'] = config.api_key
15
- @params['secret'] = config.api_secret
14
+ @params[:key] ||= config.api_key
15
+ @params[:secret] ||= config.api_secret
16
16
  end
17
17
 
18
18
  def perform
@@ -1,3 +1,3 @@
1
1
  module AddressFinder
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
3
3
  end
@@ -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/au/address/info.json?pxid=123&key=XXX&secret=YYY') }
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/au/location/info.json?pxid=123&key=XXX&secret=YYY') }
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.0
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-10-19 00:00:00.000000000 Z
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.7
141
+ rubygems_version: 2.4.8
140
142
  signing_key:
141
143
  specification_version: 4
142
144
  summary: Provides easy access to AddressFinder APIs