addressfinder 1.12.0 → 1.13.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: b7560a344ccda446dd9416a1bdd2a46b2e78a4c01fdbd84a17336ce7afa02f23
4
- data.tar.gz: 1b1a9d50c4a624663f9aa16a783634257ddec64677c45ab2c6108059709d2636
3
+ metadata.gz: 8e9d77bd22770090ef74d02d1b2135dd3504130442b4a5dfd0de17b90661c468
4
+ data.tar.gz: 91f162b6b301ff9f86c3253f8a37c89c5d5f9f8781dd8e674f49a8f6624cd2ff
5
5
  SHA512:
6
- metadata.gz: 860546a06124a3e95c1c34a357c323a6500e8f9950c1d87a1963f05fdbbe3405f804f1392b0d62380ed87405e44ae1b196dc426c807ff21c527b2aaa9b36e353
7
- data.tar.gz: 4a954a4bd36d77ac017daa151182a0e7801dcc9c87883c01945993cab90ecd51162826af42cbee427c547e061b84fe0c4fc61d7c9c075a136d47bafc2001ab41
6
+ metadata.gz: 076b5eb2c9d1200713f7952a631b70852071db5e31321c89c31264b134fd2e4ebb8e40f5820fa97fb9a4c3b43fa0c71b714c656018458a6aa02d5e0d92c20ae6
7
+ data.tar.gz: 651f98846af6d9d31ab6cb135775f6e0cae3855e8d6031aeef342e1a4d7983bd3389432123bd4b7b01b207029632e325fbb73c703e15ba27da2a471e5099a40d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # Addressfinder 1.13.0 (September 2024) #
2
+
3
+ * Add client agent versioning
4
+
1
5
  # Addressfinder 1.12.0 (May 2024) #
2
6
 
3
7
  * Add a batch capability with concurrency for Address Verification
data/README.md CHANGED
@@ -61,10 +61,10 @@ For available parameters and example responses, see the API documentation pages
61
61
  To verify a single New Zealand address, use the following method:
62
62
 
63
63
  ```ruby
64
- result = AddressFinder.address_verification(q: '186 Willis St, Wellington', country: 'nz')
64
+ result = AddressFinder.address_verification(q: "186 Willis St, Wellington", country: "nz")
65
65
 
66
66
  if result
67
- $stdout.puts "Success: #{result.postal}"
67
+ $stdout.puts "Success: '#{result.a}'"
68
68
  else
69
69
  $stdout.puts "Sorry, can't find that address"
70
70
  end
@@ -74,15 +74,16 @@ You can also verify a batch of New Zealand addresses using the following method.
74
74
  We suggest that you send up to 100 addresses in each batch.
75
75
 
76
76
  ```ruby
77
- result = AddressFinder.address_verification_nz_batch(addresses: [
78
- "186 Willis St, Wellington",
79
- "1 Ghuznee St, Te Aro, Wellington 6011"
80
- ], concurrency: 5)
77
+ addresses = ["186 Willis St, Wellington", "1 Ghuznee St, Te Aro, Wellington 6011", "bad address"]
81
78
 
82
- if result
83
- $stdout.puts "Success: #{result.postal}"
84
- else
85
- $stdout.puts "Sorry, can't find that address"
79
+ results = AddressFinder.address_verification_nz_batch(addresses: addresses, concurrency: 10)
80
+
81
+ results.each_with_index do |result, index|
82
+ if result
83
+ $stdout.puts "Success: matched '#{addresses[index]}' with '#{result.a}'"
84
+ else
85
+ $stdout.puts "Sorry, can't find address: '#{addresses[index]}'"
86
+ end
86
87
  end
87
88
  ```
88
89
 
@@ -106,15 +107,16 @@ You can also verify a batch of Australian addresses using the following method:
106
107
  We suggest that you send up to 100 addresses in each batch.
107
108
 
108
109
  ```ruby
109
- result = AddressFinder.address_verification_au_batch(addresses: [
110
- "10/274 Harbour Drive, Coffs Harbour NSW 2450",
111
- "49 CORNISH ST, COBAR NSW 2835"
112
- ], gnaf: "1", concurrency: 5)
110
+ addresses = ["10/274 Harbour Drive, Coffs Harbour NSW 2450", "49 CORNISH ST, COBAR NSW 2835", "bad address"]
113
111
 
114
- if result
115
- $stdout.puts "Success: #{result.full_address}"
116
- else
117
- $stdout.puts "Sorry, can't find that address"
112
+ results = AddressFinder.address_verification_au_batch(addresses: addresses, gnaf: "1", concurrency: 10)
113
+
114
+ results.each_with_index do |result, index|
115
+ if result
116
+ $stdout.puts "Success: matched '#{addresses[index]}' with '#{result.a}'"
117
+ else
118
+ $stdout.puts "Sorry, can't find address: '#{addresses[index]}'"
119
+ end
118
120
  end
119
121
  ```
120
122
 
@@ -29,10 +29,12 @@ You can obtain an API key by registering for a free trial account at https://add
29
29
 
30
30
  ## Example execution
31
31
 
32
- > `export AF_KEY=XXXXXXXXXXXXXXX`
33
- > `bundle exec ruby process_nz_address_csv.rb sample_addresses_nz.csv`
32
+ Processing a CSV file of New Zealand address records:
34
33
 
35
34
  ```
35
+ > export AF_KEY=XXXXXXXXXXXXXXX
36
+ > export AF_SECRET=YYYYYYYYYYYYYYY
37
+ > bundle exec ruby process_nz_address_csv.rb sample_addresses_nz.csv
36
38
  address_id,address_query,address_query_length,full_address,address_id
37
39
  1,133 wilton road wilton wellington,33,"133 Wilton Road, Wilton, Wellington 6012",2-.F.1W.v.Torm
38
40
  2,1 ghuznee st te aro wellington 6011,35,"1 Ghuznee Street, Te Aro, Wellington 6011",2-2eNwG1oBJExni2nUFJm1cW
@@ -43,9 +45,10 @@ address_id,address_query,address_query_length,full_address,address_id
43
45
  # ...
44
46
  ```
45
47
 
46
- > `bundle exec ruby process_au_address_csv.rb sample_addresses_au.csv`
48
+ Processing a CSV file of Australian address records:
47
49
 
48
50
  ```
51
+ > bundle exec ruby process_au_address_csv.rb sample_addresses_au.csv
49
52
  address_id,address_query,address_query_length,full_address,address_id
50
53
  1,"10/274 harbour drive, coffs harbour NSW 2450",44,"Unit 10, 274 Harbour Drive, COFFS HARBOUR NSW 2450",670cd8c3-b883-ee24-2874-74440e515b80
51
54
  2,"9/274 harbour drive, coffs harbour NSW 2450",43,"Unit 9, 274 Harbour Drive, COFFS HARBOUR NSW 2450",42ae5625-d679-266b-5d66-5ece6bbfb179
@@ -44,9 +44,7 @@ module AddressFinder
44
44
  end
45
45
 
46
46
  def execute_request
47
- request = Net::HTTP::Get.new(request_uri)
48
-
49
- response = http.request(request)
47
+ response = http.request(request_uri)
50
48
 
51
49
  self.response_body = response.body
52
50
  self.response_status = response.code
@@ -37,9 +37,7 @@ module AddressFinder
37
37
  end
38
38
 
39
39
  def execute_request
40
- request = Net::HTTP::Get.new(request_uri)
41
-
42
- response = http.request(request)
40
+ response = http.request(request_uri)
43
41
 
44
42
  self.response_body = response.body
45
43
  self.response_status = response.code
@@ -37,9 +37,7 @@ module AddressFinder
37
37
  end
38
38
 
39
39
  def execute_request
40
- request = Net::HTTP::Get.new(request_uri)
41
-
42
- response = http.request(request)
40
+ response = http.request(request_uri)
43
41
 
44
42
  self.response_body = response.body
45
43
  self.response_status = response.code
@@ -14,6 +14,7 @@ module AddressFinder
14
14
  attr_accessor :domain
15
15
  attr_accessor :retries
16
16
  attr_accessor :retry_delay
17
+ attr_accessor :ca
17
18
 
18
19
  def initialize
19
20
  self.hostname = 'api.addressfinder.io'
@@ -23,6 +24,7 @@ module AddressFinder
23
24
  self.retry_delay = 5
24
25
  self.default_country = 'nz'
25
26
  self.verification_version = 'v1'
27
+ self.ca = "Ruby/#{AddressFinder::VERSION}"
26
28
  end
27
29
  end
28
30
  end
@@ -15,11 +15,15 @@ module AddressFinder
15
15
  end
16
16
  end
17
17
 
18
- def request(args)
18
+ def request(request_uri)
19
19
  retries = 0
20
20
  begin
21
21
  re_establish_connection if @connection_is_bad
22
- net_http.request(args)
22
+
23
+ uri = build_uri(request_uri)
24
+ request = Net::HTTP::Get.new(uri)
25
+
26
+ net_http.request(request)
23
27
  rescue Net::ReadTimeout, Net::OpenTimeout, SocketError => error
24
28
  if retries < config.retries
25
29
  retries += 1
@@ -40,6 +44,19 @@ module AddressFinder
40
44
  net_http.start
41
45
  end
42
46
 
47
+ def build_uri(request_uri)
48
+ uri = URI(request_uri)
49
+ encoded_ca = URI.encode_www_form_component(config.ca)
50
+
51
+ if uri.query
52
+ uri.query += "&ca=#{encoded_ca}"
53
+ else
54
+ uri.query = "ca=#{encoded_ca}"
55
+ end
56
+
57
+ uri.to_s
58
+ end
59
+
43
60
  def net_http
44
61
  @net_http ||= begin
45
62
  http = Net::HTTP.new(config.hostname, config.port, config.proxy_host,
@@ -38,9 +38,7 @@ module AddressFinder
38
38
  end
39
39
 
40
40
  def execute_request
41
- request = Net::HTTP::Get.new(request_uri)
42
-
43
- response = http.request(request)
41
+ response = http.request(request_uri)
44
42
 
45
43
  self.response_body = response.body
46
44
  self.response_status = response.code
@@ -38,9 +38,7 @@ module AddressFinder
38
38
  end
39
39
 
40
40
  def execute_request
41
- request = Net::HTTP::Get.new(request_uri)
42
-
43
- response = http.request(request)
41
+ response = http.request(request_uri)
44
42
 
45
43
  self.response_body = response.body
46
44
  self.response_status = response.code
@@ -20,12 +20,12 @@ module AddressFinder
20
20
  build_request
21
21
  execute_request
22
22
  build_result
23
-
23
+
24
24
  self
25
25
  end
26
26
 
27
27
  private
28
-
28
+
29
29
  attr_reader :request_uri, :params, :http, :path
30
30
  attr_accessor :response_body, :response_status
31
31
  attr_writer :result
@@ -33,20 +33,18 @@ module AddressFinder
33
33
  def build_request
34
34
  @request_uri = "#{path}?#{encoded_params}"
35
35
  end
36
-
36
+
37
37
  def encoded_params
38
38
  Util.encode_and_join_params(params)
39
39
  end
40
-
40
+
41
41
  def execute_request
42
- request = Net::HTTP::Get.new(request_uri)
43
-
44
- response = http.request(request)
45
-
42
+ response = http.request(request_uri)
43
+
46
44
  self.response_body = response.body
47
45
  self.response_status = response.code
48
46
  end
49
-
47
+
50
48
  def build_result
51
49
  case response_status
52
50
  when '200'
@@ -55,15 +53,15 @@ module AddressFinder
55
53
  raise AddressFinder::RequestRejectedError.new(response_status, response_body)
56
54
  end
57
55
  end
58
-
56
+
59
57
  def response_hash
60
58
  @_response_hash ||= MultiJson.load(response_body)
61
59
  end
62
-
60
+
63
61
  def config
64
62
  @_config ||= AddressFinder.configuration
65
63
  end
66
-
64
+
67
65
  class Result < OpenStruct
68
66
  end
69
67
  end
@@ -56,9 +56,7 @@ module AddressFinder
56
56
  end
57
57
 
58
58
  def execute_request
59
- request = Net::HTTP::Get.new(request_uri)
60
-
61
- response = http.request(request)
59
+ response = http.request(request_uri)
62
60
 
63
61
  self.response_body = response.body
64
62
  self.response_status = response.code
@@ -61,9 +61,7 @@ module AddressFinder
61
61
  end
62
62
 
63
63
  def execute_request
64
- request = Net::HTTP::Get.new(request_uri)
65
-
66
- response = http.request(request)
64
+ response = http.request(request_uri)
67
65
 
68
66
  self.response_body = response.body
69
67
  self.response_status = response.code
@@ -1,3 +1,3 @@
1
1
  module AddressFinder
2
- VERSION = "1.12.0"
2
+ VERSION = "1.13.0"
3
3
  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.12.0
4
+ version: 1.13.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: 2024-05-09 00:00:00.000000000 Z
15
+ date: 2024-09-04 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: multi_json
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  - !ruby/object:Gem::Version
196
196
  version: '0'
197
197
  requirements: []
198
- rubygems_version: 3.4.6
198
+ rubygems_version: 3.4.13
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: Provides easy access to Addressfinder APIs