smartystreets_ruby_sdk 5.2.2 → 5.3.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.
- data/examples/international_example.rb +7 -2
- data/examples/us_autocomplete_example.rb +7 -2
- data/examples/us_extract_example.rb +7 -2
- data/examples/us_street_multiple_address_example.rb +7 -2
- data/examples/us_street_single_address_example.rb +8 -3
- data/examples/us_zipcode_multiple_lookup_example.rb +7 -2
- data/examples/us_zipcode_single_lookup_example.rb +8 -3
- data/lib/smartystreets_ruby_sdk/client_builder.rb +2 -3
- data/lib/smartystreets_ruby_sdk/international_street/components.rb +2 -1
- data/lib/smartystreets_ruby_sdk/native_sender.rb +1 -1
- data/lib/smartystreets_ruby_sdk/us_street/client.rb +7 -2
- data/lib/smartystreets_ruby_sdk/us_zipcode/client.rb +7 -2
- data/lib/smartystreets_ruby_sdk/version.rb +1 -1
- metadata +2 -2
@@ -6,8 +6,13 @@ class InternationalExample
|
|
6
6
|
Lookup = SmartyStreets::InternationalStreet::Lookup
|
7
7
|
|
8
8
|
def run
|
9
|
-
auth_id =
|
10
|
-
auth_token =
|
9
|
+
auth_id = 'Your SmartyStreets Auth ID here'
|
10
|
+
auth_token = 'Your SmartyStreets Auth Token here'
|
11
|
+
|
12
|
+
# We recommend storing your secret keys in environment variables instead---it's safer!
|
13
|
+
# auth_id = ENV['SMARTY_AUTH_ID']
|
14
|
+
# auth_token = ENV['SMARTY_AUTH_TOKEN']
|
15
|
+
|
11
16
|
credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
|
12
17
|
client = SmartyStreets::ClientBuilder.new(credentials).build_international_street_api_client
|
13
18
|
|
@@ -6,8 +6,13 @@ class USAutocompleteExample
|
|
6
6
|
Lookup = SmartyStreets::USAutocomplete::Lookup
|
7
7
|
|
8
8
|
def run
|
9
|
-
auth_id =
|
10
|
-
auth_token =
|
9
|
+
auth_id = 'Your SmartyStreets Auth ID here'
|
10
|
+
auth_token = 'Your SmartyStreets Auth Token here'
|
11
|
+
|
12
|
+
# We recommend storing your secret keys in environment variables instead---it's safer!
|
13
|
+
# auth_id = ENV['SMARTY_AUTH_ID']
|
14
|
+
# auth_token = ENV['SMARTY_AUTH_TOKEN']
|
15
|
+
|
11
16
|
credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
|
12
17
|
client = SmartyStreets::ClientBuilder.new(credentials).build_us_autocomplete_api_client
|
13
18
|
lookup = Lookup.new('4770 Lincoln Ave O')
|
@@ -6,8 +6,13 @@ class USExtractExample
|
|
6
6
|
Lookup = SmartyStreets::USExtract::Lookup
|
7
7
|
|
8
8
|
def run
|
9
|
-
auth_id =
|
10
|
-
auth_token =
|
9
|
+
auth_id = 'Your SmartyStreets Auth ID here'
|
10
|
+
auth_token = 'Your SmartyStreets Auth Token here'
|
11
|
+
|
12
|
+
# We recommend storing your secret keys in environment variables instead---it's safer!
|
13
|
+
# auth_id = ENV['SMARTY_AUTH_ID']
|
14
|
+
# auth_token = ENV['SMARTY_AUTH_TOKEN']
|
15
|
+
|
11
16
|
credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
|
12
17
|
|
13
18
|
client = SmartyStreets::ClientBuilder.new(credentials).build_us_extract_api_client
|
@@ -7,8 +7,13 @@ class USStreetMultipleAddressExample
|
|
7
7
|
Lookup = SmartyStreets::USStreet::Lookup
|
8
8
|
|
9
9
|
def run
|
10
|
-
auth_id =
|
11
|
-
auth_token =
|
10
|
+
auth_id = 'Your SmartyStreets Auth ID here'
|
11
|
+
auth_token = 'Your SmartyStreets Auth Token here'
|
12
|
+
|
13
|
+
# We recommend storing your secret keys in environment variables instead---it's safer!
|
14
|
+
# auth_id = ENV['SMARTY_AUTH_ID']
|
15
|
+
# auth_token = ENV['SMARTY_AUTH_TOKEN']
|
16
|
+
|
12
17
|
credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
|
13
18
|
|
14
19
|
client = SmartyStreets::ClientBuilder.new(credentials).build_us_street_api_client
|
@@ -4,8 +4,13 @@ require 'smartystreets_ruby_sdk/us_street/lookup'
|
|
4
4
|
|
5
5
|
class USStreetSingleAddressExample
|
6
6
|
def run
|
7
|
-
auth_id =
|
8
|
-
auth_token =
|
7
|
+
auth_id = 'Your SmartyStreets Auth ID here'
|
8
|
+
auth_token = 'Your SmartyStreets Auth Token here'
|
9
|
+
|
10
|
+
# We recommend storing your secret keys in environment variables instead---it's safer!
|
11
|
+
# auth_id = ENV['SMARTY_AUTH_ID']
|
12
|
+
# auth_token = ENV['SMARTY_AUTH_TOKEN']
|
13
|
+
|
9
14
|
credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
|
10
15
|
|
11
16
|
client = SmartyStreets::ClientBuilder.new(credentials).
|
@@ -26,7 +31,7 @@ class USStreetSingleAddressExample
|
|
26
31
|
|
27
32
|
result = lookup.result
|
28
33
|
|
29
|
-
if result.
|
34
|
+
if result.empty?
|
30
35
|
puts 'No candidates. This means the address is not valid.'
|
31
36
|
return
|
32
37
|
end
|
@@ -7,8 +7,13 @@ class USZipcodeMultipleLookupExample
|
|
7
7
|
Lookup = SmartyStreets::USZipcode::Lookup
|
8
8
|
|
9
9
|
def run
|
10
|
-
auth_id =
|
11
|
-
auth_token =
|
10
|
+
auth_id = 'Your SmartyStreets Auth ID here'
|
11
|
+
auth_token = 'Your SmartyStreets Auth Token here'
|
12
|
+
|
13
|
+
# We recommend storing your secret keys in environment variables instead---it's safer!
|
14
|
+
# auth_id = ENV['SMARTY_AUTH_ID']
|
15
|
+
# auth_token = ENV['SMARTY_AUTH_TOKEN']
|
16
|
+
|
12
17
|
credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
|
13
18
|
|
14
19
|
client = SmartyStreets::ClientBuilder.new(credentials).build_us_zipcode_api_client
|
@@ -4,8 +4,13 @@ require 'smartystreets_ruby_sdk/us_zipcode/lookup'
|
|
4
4
|
|
5
5
|
class UsZipcodeSingleLookupExample
|
6
6
|
def run
|
7
|
-
auth_id =
|
8
|
-
auth_token =
|
7
|
+
auth_id = 'Your SmartyStreets Auth ID here'
|
8
|
+
auth_token = 'Your SmartyStreets Auth Token here'
|
9
|
+
|
10
|
+
# We recommend storing your secret keys in environment variables instead---it's safer!
|
11
|
+
# auth_id = ENV['SMARTY_AUTH_ID']
|
12
|
+
# auth_token = ENV['SMARTY_AUTH_TOKEN']
|
13
|
+
|
9
14
|
credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
|
10
15
|
|
11
16
|
client = SmartyStreets::ClientBuilder.new(credentials).build_us_zipcode_api_client
|
@@ -16,7 +21,7 @@ class UsZipcodeSingleLookupExample
|
|
16
21
|
|
17
22
|
begin
|
18
23
|
client.send_lookup(lookup)
|
19
|
-
rescue SmartyError => err
|
24
|
+
rescue SmartyStreets::SmartyError => err
|
20
25
|
puts err
|
21
26
|
return
|
22
27
|
end
|
@@ -29,7 +29,7 @@ module SmartyStreets
|
|
29
29
|
@serializer = NativeSerializer.new
|
30
30
|
@http_sender = nil
|
31
31
|
@max_retries = 5
|
32
|
-
@max_timeout =
|
32
|
+
@max_timeout = 10
|
33
33
|
@url_prefix = nil
|
34
34
|
@proxy = nil
|
35
35
|
end
|
@@ -42,8 +42,7 @@ module SmartyStreets
|
|
42
42
|
self
|
43
43
|
end
|
44
44
|
|
45
|
-
# The maximum time (in
|
46
|
-
# the response to be read. (Default is 10000)
|
45
|
+
# The maximum time (in seconds) to wait for the response to be read. (Default is 10)
|
47
46
|
#
|
48
47
|
# Returns self to accommodate method chaining.
|
49
48
|
def with_max_timeout(max_timeout)
|
@@ -3,7 +3,7 @@ module SmartyStreets
|
|
3
3
|
# See "https://smartystreets.com/docs/cloud/international-street-api#components"
|
4
4
|
class Components
|
5
5
|
attr_reader :premise, :thoroughfare_trailing_type, :sub_building, :locality, :post_box_number,
|
6
|
-
:thoroughfare_name, :thoroughfare_postdirection, :dependent_thoroughfare,
|
6
|
+
:thoroughfare_name, :thoroughfare_postdirection, :dependent_thoroughfare, :premise_prefix_number,
|
7
7
|
:thoroughfare, :dependent_thoroughfare_name, :postal_code_short, :dependent_thoroughfare_trailing_type,
|
8
8
|
:administrative_area, :post_box, :building_leading_type, :dependent_locality_name, :thoroughfare_type,
|
9
9
|
:dependent_thoroughfare_postdirection, :double_dependent_locality, :premise_number,
|
@@ -27,6 +27,7 @@ module SmartyStreets
|
|
27
27
|
@premise = obj.fetch('premise', nil)
|
28
28
|
@premise_extra = obj.fetch('premise_extra', nil)
|
29
29
|
@premise_number = obj.fetch('premise_number', nil)
|
30
|
+
@premise_prefix_number = obj.fetch('premise_prefix_number', nil)
|
30
31
|
@premise_type = obj.fetch('premise_type', nil)
|
31
32
|
@thoroughfare = obj.fetch('thoroughfare', nil)
|
32
33
|
@thoroughfare_predirection = obj.fetch('thoroughfare_predirection', nil)
|
@@ -26,14 +26,19 @@ module SmartyStreets
|
|
26
26
|
return if batch.empty?
|
27
27
|
|
28
28
|
converted_lookups = remap_keys(batch.all_lookups)
|
29
|
-
|
29
|
+
|
30
|
+
if batch.size > 1
|
31
|
+
smarty_request.payload = @serializer.serialize(converted_lookups)
|
32
|
+
else
|
33
|
+
smarty_request.parameters = converted_lookups[0]
|
34
|
+
end
|
30
35
|
|
31
36
|
response = @sender.send(smarty_request)
|
32
37
|
|
33
38
|
raise response.error if response.error
|
34
39
|
|
35
40
|
candidates = @serializer.deserialize(response.payload)
|
36
|
-
candidates = [] if candidates
|
41
|
+
candidates = [] if candidates.nil?
|
37
42
|
|
38
43
|
assign_candidates_to_lookups(batch, candidates)
|
39
44
|
end
|
@@ -26,14 +26,19 @@ module SmartyStreets
|
|
26
26
|
return if batch.empty?
|
27
27
|
|
28
28
|
converted_lookups = remap_keys(batch.all_lookups)
|
29
|
-
|
29
|
+
|
30
|
+
if batch.size > 1
|
31
|
+
smarty_request.payload = @serializer.serialize(converted_lookups)
|
32
|
+
else
|
33
|
+
smarty_request.parameters = converted_lookups[0]
|
34
|
+
end
|
30
35
|
|
31
36
|
response = @sender.send(smarty_request)
|
32
37
|
|
33
38
|
raise response.error if response.error
|
34
39
|
|
35
40
|
results = @serializer.deserialize(response.payload)
|
36
|
-
results = [] if results
|
41
|
+
results = [] if results.nil?
|
37
42
|
assign_results_to_lookups(batch, results)
|
38
43
|
end
|
39
44
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartystreets_ruby_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|