smartystreets_ruby_sdk 5.15.4 → 5.16.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 +4 -4
- data/examples/international_autocomplete_example.rb +5 -3
- data/lib/smartystreets_ruby_sdk/client_builder.rb +1 -1
- data/lib/smartystreets_ruby_sdk/international_autocomplete/client.rb +6 -9
- data/lib/smartystreets_ruby_sdk/international_autocomplete/lookup.rb +3 -7
- data/lib/smartystreets_ruby_sdk/international_autocomplete/suggestion.rb +5 -3
- data/lib/smartystreets_ruby_sdk/url_prefix_sender.rb +5 -1
- data/lib/smartystreets_ruby_sdk/version.rb +1 -1
- metadata +2 -3
- data/lib/smartystreets_ruby_sdk/international_autocomplete/international_geolocation_type.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3420356d8cdd87a995c6fae44cdfa26549322163bc1ebe767a181aca029280b5
|
4
|
+
data.tar.gz: 3c63162a19e7abd5841df9ee8699e40b27edcd0d9fe0c1615221f41844e289ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31df562ca6a0e07e80d90c74bf0713da88c8491dc9112afd76209fcc97f2038cb61af0cbba0bf3ec3f1c23913f4f09c14c8f1fc8d140c392a70f5e3e9ee20dfc
|
7
|
+
data.tar.gz: 6de7192ed4b3a9f803aa8c7526ed6186bcb34aef24698b65d4665714112464504f9bda7e7caa2be38dffa964c4b8bf888ba3235a7176aefb54323587467ee41c
|
@@ -3,7 +3,6 @@ require '../lib/smartystreets_ruby_sdk/static_credentials'
|
|
3
3
|
require '../lib/smartystreets_ruby_sdk/client_builder'
|
4
4
|
require '../lib/smartystreets_ruby_sdk/international_autocomplete/lookup'
|
5
5
|
require '../lib/smartystreets_ruby_sdk/international_autocomplete/client'
|
6
|
-
require '../lib/smartystreets_ruby_sdk/international_autocomplete/international_geolocation_type'
|
7
6
|
|
8
7
|
class InternationalAutocompleteExample
|
9
8
|
Lookup = SmartyStreets::InternationalAutocomplete::Lookup
|
@@ -32,7 +31,6 @@ class InternationalAutocompleteExample
|
|
32
31
|
lookup = Lookup.new('Louis')
|
33
32
|
lookup.country = "FRA"
|
34
33
|
lookup.locality = "Paris"
|
35
|
-
lookup.geolocation = SmartyStreets::InternationalAutocomplete::InternationalGeolocationType::NONE
|
36
34
|
|
37
35
|
suggestions = client.send(lookup) # The client will also return the suggestions directly
|
38
36
|
|
@@ -41,7 +39,11 @@ class InternationalAutocompleteExample
|
|
41
39
|
puts
|
42
40
|
|
43
41
|
suggestions.each do |suggestion|
|
44
|
-
|
42
|
+
if suggestion.address_text
|
43
|
+
puts "#{suggestion.entries} #{suggestion.address_text}, #{suggestion.address_id}"
|
44
|
+
else
|
45
|
+
puts "#{suggestion.street} #{suggestion.locality}, #{suggestion.country_iso3}"
|
46
|
+
end
|
45
47
|
end
|
46
48
|
|
47
49
|
end
|
@@ -24,7 +24,7 @@ module SmartyStreets
|
|
24
24
|
# These methods are chainable, so you can usually get set up with one line of code.
|
25
25
|
class ClientBuilder
|
26
26
|
INTERNATIONAL_STREET_API_URL = 'https://international-street.api.smarty.com/verify'.freeze
|
27
|
-
INTERNATIONAL_AUTOCOMPLETE_API_URL = "https://international-autocomplete.api.smarty.com/lookup".freeze
|
27
|
+
INTERNATIONAL_AUTOCOMPLETE_API_URL = "https://international-autocomplete.api.smarty.com/v2/lookup".freeze
|
28
28
|
US_AUTOCOMPLETE_API_URL = 'https://us-autocomplete.api.smarty.com/suggest'.freeze
|
29
29
|
US_AUTOCOMPLETE_PRO_API_URL = 'https://us-autocomplete-pro.api.smarty.com/lookup'.freeze
|
30
30
|
US_EXTRACT_API_URL = 'https://us-extract.api.smarty.com/'.freeze
|
@@ -13,8 +13,8 @@ module SmartyStreets
|
|
13
13
|
|
14
14
|
# Sends a Lookup object to the International Autocomplete API and stores the result in the Lookup's result field.
|
15
15
|
def send(lookup)
|
16
|
-
if
|
17
|
-
raise SmartyStreets::SmartyError, 'Send() must be passed a Lookup with
|
16
|
+
if !lookup || (!lookup.search && !lookup.address_id)
|
17
|
+
raise SmartyStreets::SmartyError, 'Send() must be passed a Lookup with country set, and search or address_id set.'
|
18
18
|
end
|
19
19
|
|
20
20
|
request = build_request(lookup)
|
@@ -32,18 +32,15 @@ module SmartyStreets
|
|
32
32
|
def build_request(lookup)
|
33
33
|
request = Request.new
|
34
34
|
|
35
|
+
unless lookup.address_id.nil?
|
36
|
+
request.url_prefix = '/' + lookup.address_id
|
37
|
+
end
|
38
|
+
|
35
39
|
add_parameter(request, 'search', lookup.search)
|
36
40
|
add_parameter(request, 'country', lookup.country)
|
37
41
|
add_parameter(request, 'max_results', lookup.max_results.to_s)
|
38
|
-
add_parameter(request, 'distance', lookup.distance.to_s)
|
39
|
-
if lookup.geolocation != InternationalGeolocationType::NONE && lookup.geolocation != nil
|
40
|
-
add_parameter(request, 'geolocation', lookup.geolocation)
|
41
|
-
end
|
42
|
-
add_parameter(request, 'include_only_administrative_area', lookup.administrative_area)
|
43
42
|
add_parameter(request, 'include_only_locality', lookup.locality)
|
44
43
|
add_parameter(request, 'include_only_postal_code', lookup.postal_code)
|
45
|
-
add_parameter(request, 'latitude', lookup.latitude.to_s)
|
46
|
-
add_parameter(request, 'longitude', lookup.longitude.to_s)
|
47
44
|
|
48
45
|
request
|
49
46
|
end
|
@@ -6,20 +6,16 @@ module SmartyStreets
|
|
6
6
|
# of the lookup after it comes back from the API.
|
7
7
|
class Lookup < JSONAble
|
8
8
|
|
9
|
-
attr_accessor :result, :search, :
|
9
|
+
attr_accessor :result, :search, :address_id, :country, :max_results, :locality, :postal_code
|
10
10
|
|
11
|
-
def initialize(search = nil,
|
11
|
+
def initialize(search = nil, address_id = nil, country = nil, max_results = nil, locality = nil, postal_code = nil)
|
12
12
|
@result = []
|
13
13
|
@search = search
|
14
|
+
@address_id = address_id
|
14
15
|
@country = country
|
15
16
|
@max_results = max_results
|
16
|
-
@distance = distance
|
17
|
-
@geolocation = geolocation
|
18
|
-
@administrative_area = administrative_area
|
19
17
|
@locality = locality
|
20
18
|
@postal_code = postal_code
|
21
|
-
@latitude = latitude
|
22
|
-
@longitude = longitude
|
23
19
|
end
|
24
20
|
end
|
25
21
|
end
|
@@ -2,16 +2,18 @@ module SmartyStreets
|
|
2
2
|
module InternationalAutocomplete
|
3
3
|
class Suggestion
|
4
4
|
|
5
|
-
attr_reader :street, :locality, :administrative_area, :
|
5
|
+
attr_reader :street, :locality, :administrative_area, :postal_code, :country_iso3, :entries, :address_text, :address_id
|
6
6
|
|
7
7
|
def initialize(obj)
|
8
8
|
@street = obj.fetch('street', nil)
|
9
9
|
@locality = obj.fetch('locality', nil)
|
10
10
|
@administrative_area = obj.fetch('administrative_area', nil)
|
11
|
-
@super_administrative_area = obj.fetch('super_administrative_area', nil)
|
12
|
-
@sub_administrative_area = obj.fetch('sub_administrative_area', nil)
|
13
11
|
@postal_code = obj.fetch('postal_code', nil)
|
14
12
|
@country_iso3 = obj.fetch('country_iso3', nil)
|
13
|
+
# v2 fields
|
14
|
+
@entries = obj.fetch('entries', nil)
|
15
|
+
@address_text = obj.fetch('address_text', nil)
|
16
|
+
@address_id = obj.fetch('address_id', nil)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.16.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SmartyStreets SDK Team
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-11-
|
11
|
+
date: 2023-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,7 +108,6 @@ files:
|
|
108
108
|
- lib/smartystreets_ruby_sdk/exceptions.rb
|
109
109
|
- lib/smartystreets_ruby_sdk/international_autocomplete.rb
|
110
110
|
- lib/smartystreets_ruby_sdk/international_autocomplete/client.rb
|
111
|
-
- lib/smartystreets_ruby_sdk/international_autocomplete/international_geolocation_type.rb
|
112
111
|
- lib/smartystreets_ruby_sdk/international_autocomplete/lookup.rb
|
113
112
|
- lib/smartystreets_ruby_sdk/international_autocomplete/suggestion.rb
|
114
113
|
- lib/smartystreets_ruby_sdk/international_street.rb
|