smartystreets_ruby_sdk 6.1.1 → 6.2.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/Makefile +1 -1
- data/examples/us_street_component_analysis_example.rb +54 -0
- data/lib/smartystreets_ruby_sdk/client_builder.rb +29 -0
- data/lib/smartystreets_ruby_sdk/custom_query_sender.rb +13 -0
- data/lib/smartystreets_ruby_sdk/us_street/analysis.rb +4 -1
- data/lib/smartystreets_ruby_sdk/us_street/component_analysis.rb +36 -0
- data/lib/smartystreets_ruby_sdk/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 004ff7e3e907b690ae90319ec80fc5ae0a39e0110811271d0b5af96078d97a13
|
|
4
|
+
data.tar.gz: 7f4ff64365804d28130f2714583e211f9c7051849a435c35e7ad36e22c3f822a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b18e712ed2d5a5bfd113fe220295a732185ddaac9ce37ef25d1e088b3b9f7d3bc9b55d9a72b9baa185548c3206c62d9a5da8b2ef77213d225c945dab406f2559
|
|
7
|
+
data.tar.gz: f78011e0d4fe74231f60534f79a967b88beb85cdeb279f59ad028cf5430fc5b264b6662d165d6dfc82fad4ccd85613c565ecd8886befd1e9ba58f82b6d3a43bc
|
data/Makefile
CHANGED
|
@@ -43,7 +43,7 @@ us_reverse_geo_api:
|
|
|
43
43
|
cd examples && ruby us_reverse_geo_example.rb
|
|
44
44
|
|
|
45
45
|
us_street_api:
|
|
46
|
-
cd examples && ruby us_street_single_address_example.rb && ruby us_street_multiple_address_example.rb
|
|
46
|
+
cd examples && ruby us_street_single_address_example.rb && ruby us_street_multiple_address_example.rb && ruby us_street_component_analysis.rb && ruby us_street_component_analysis_example.rb
|
|
47
47
|
|
|
48
48
|
us_zipcode_api:
|
|
49
49
|
cd examples && ruby us_zipcode_single_lookup_example.rb && ruby us_zipcode_multiple_lookup_example.rb
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
require '../lib/smartystreets_ruby_sdk/static_credentials'
|
|
2
|
+
require '../lib/smartystreets_ruby_sdk/shared_credentials'
|
|
3
|
+
require '../lib/smartystreets_ruby_sdk/client_builder'
|
|
4
|
+
require '../lib/smartystreets_ruby_sdk/us_street/lookup'
|
|
5
|
+
require '../lib/smartystreets_ruby_sdk/us_street/match_type'
|
|
6
|
+
|
|
7
|
+
class USStreetComponentAnalysisExample
|
|
8
|
+
def run
|
|
9
|
+
# For client-side requests (browser/mobile), use this code:
|
|
10
|
+
# key = ENV['SMARTY_AUTH_WEB']
|
|
11
|
+
# referer = ENV['SMARTY_AUTH_REFERER']
|
|
12
|
+
# credentials = SmartyStreets::SharedCredentials.new(key, referer)
|
|
13
|
+
|
|
14
|
+
# For server-to-server requests, use this code:
|
|
15
|
+
id = ENV['SMARTY_AUTH_ID']
|
|
16
|
+
token = ENV['SMARTY_AUTH_TOKEN']
|
|
17
|
+
credentials = SmartyStreets::StaticCredentials.new(id, token)
|
|
18
|
+
|
|
19
|
+
client = SmartyStreets::ClientBuilder.new(credentials)
|
|
20
|
+
.with_feature_component_analysis() # To add component analysis feature you need to specify when you create the client.
|
|
21
|
+
.build_us_street_api_client
|
|
22
|
+
|
|
23
|
+
lookup = SmartyStreets::USStreet::Lookup.new
|
|
24
|
+
lookup.street = "1 Rosedale"
|
|
25
|
+
lookup.secondary = "APT 2"
|
|
26
|
+
lookup.city = "Baltimore"
|
|
27
|
+
lookup.state = "MD"
|
|
28
|
+
lookup.zipcode = "21229"
|
|
29
|
+
lookup.match = SmartyStreets::USStreet::MatchType::ENHANCED # Enhanced matching is required to return component analysis results.
|
|
30
|
+
|
|
31
|
+
begin
|
|
32
|
+
client.send_lookup(lookup)
|
|
33
|
+
rescue SmartyStreets::SmartyError => err
|
|
34
|
+
puts err
|
|
35
|
+
return
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
result = lookup.result
|
|
39
|
+
|
|
40
|
+
if result.empty?
|
|
41
|
+
return
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
first_candidate = result[0]
|
|
45
|
+
|
|
46
|
+
# Here is an example of how to access the result of component analysis.
|
|
47
|
+
puts "Primary Number: "
|
|
48
|
+
puts "\tStatus: #{first_candidate.analysis.components.secondary_number.status}"
|
|
49
|
+
puts "\tChange: #{first_candidate.analysis.components.secondary_number.change}"
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
example = USStreetComponentAnalysisExample.new
|
|
54
|
+
example.run
|
|
@@ -9,6 +9,7 @@ require_relative 'sleeper'
|
|
|
9
9
|
require_relative 'logger'
|
|
10
10
|
require_relative 'proxy'
|
|
11
11
|
require_relative 'custom_header_sender'
|
|
12
|
+
require_relative 'custom_query_sender'
|
|
12
13
|
require_relative 'us_street/client'
|
|
13
14
|
require_relative 'us_zipcode/client'
|
|
14
15
|
require_relative 'us_extract/client'
|
|
@@ -43,6 +44,7 @@ module SmartyStreets
|
|
|
43
44
|
@header = nil
|
|
44
45
|
@licenses = %w()
|
|
45
46
|
@debug = nil
|
|
47
|
+
@queries = {}
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
# Sets the maximum number of times to retry sending the request to the API. (Default is 5)
|
|
@@ -112,6 +114,31 @@ module SmartyStreets
|
|
|
112
114
|
self
|
|
113
115
|
end
|
|
114
116
|
|
|
117
|
+
# Allows the caller to specify key and value pair that is added to the request query.
|
|
118
|
+
#
|
|
119
|
+
# Returns self to accommodate method chaining.
|
|
120
|
+
def with_custom_query(key, value)
|
|
121
|
+
@queries[key] = value
|
|
122
|
+
self
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Allows the caller to specify key and value pair and appends the value to the current
|
|
126
|
+
# value associated with the key, separated by a comma.
|
|
127
|
+
#
|
|
128
|
+
# Returns self to accommodate method chaining.
|
|
129
|
+
def with_custom_comma_separated_query(key, value)
|
|
130
|
+
@queries[key] = [@queries[key], value].compact.join(',')
|
|
131
|
+
self
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Adds to the request query to use the component analysis feature.
|
|
135
|
+
#
|
|
136
|
+
# Returns self to accommodate method chaining.
|
|
137
|
+
def with_feature_component_analysis()
|
|
138
|
+
self.with_custom_comma_separated_query("features", "component-analysis")
|
|
139
|
+
self
|
|
140
|
+
end
|
|
141
|
+
|
|
115
142
|
# Enables debug mode, which will print information about the HTTP request and response to $stdout.
|
|
116
143
|
#
|
|
117
144
|
# Returns self to accommodate method chaining.
|
|
@@ -179,6 +206,8 @@ module SmartyStreets
|
|
|
179
206
|
|
|
180
207
|
sender = LicenseSender.new(sender, @licenses)
|
|
181
208
|
|
|
209
|
+
sender = CustomQuerySender.new(sender, @queries)
|
|
210
|
+
|
|
182
211
|
URLPrefixSender.new(@url_prefix, sender)
|
|
183
212
|
end
|
|
184
213
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
require_relative 'component_analysis'
|
|
2
|
+
|
|
1
3
|
module SmartyStreets
|
|
2
4
|
module USStreet
|
|
3
5
|
# See "https://smartystreets.com/docs/cloud/us-street-api#analysis"
|
|
4
6
|
class Analysis
|
|
5
7
|
attr_reader :lacs_link_code, :active, :footnotes, :lacs_link_indicator, :dpv_match_code, :is_suite_link_match,
|
|
6
|
-
:is_ews_match, :dpv_footnotes, :cmra, :vacant, :no_stat, :enhanced_match
|
|
8
|
+
:is_ews_match, :dpv_footnotes, :cmra, :vacant, :no_stat, :enhanced_match, :components
|
|
7
9
|
|
|
8
10
|
def initialize(obj)
|
|
9
11
|
@dpv_match_code = obj['dpv_match_code']
|
|
@@ -18,6 +20,7 @@ module SmartyStreets
|
|
|
18
20
|
@lacs_link_indicator = obj['lacslink_indicator']
|
|
19
21
|
@is_suite_link_match = obj['suitelink_match']
|
|
20
22
|
@enhanced_match = obj['enhanced_match']
|
|
23
|
+
@components = ComponentAnalysis.new(obj.fetch('components', {}))
|
|
21
24
|
end
|
|
22
25
|
end
|
|
23
26
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module SmartyStreets
|
|
2
|
+
module USStreet
|
|
3
|
+
class MatchInfo
|
|
4
|
+
attr_reader :status, :change
|
|
5
|
+
|
|
6
|
+
def initialize(obj = {})
|
|
7
|
+
@status = obj['status']
|
|
8
|
+
@change = obj['change'] || []
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class ComponentAnalysis
|
|
13
|
+
attr_reader :primary_number, :street_predirection, :street_name, :street_postdirection,
|
|
14
|
+
:street_suffix, :secondary_number, :secondary_designator, :extra_secondary_number,
|
|
15
|
+
:extra_secondary_designator, :city_name, :state_abbreviation, :zipcode,
|
|
16
|
+
:plus4_code, :urbanization
|
|
17
|
+
|
|
18
|
+
def initialize(obj = {})
|
|
19
|
+
@primary_number = MatchInfo.new(obj.fetch('primary_number', {}))
|
|
20
|
+
@street_predirection = MatchInfo.new(obj.fetch('street_predirection', {}))
|
|
21
|
+
@street_name = MatchInfo.new(obj.fetch('street_name', {}))
|
|
22
|
+
@street_postdirection = MatchInfo.new(obj.fetch('street_postdirection', {}))
|
|
23
|
+
@street_suffix = MatchInfo.new(obj.fetch('street_suffix', {}))
|
|
24
|
+
@secondary_number = MatchInfo.new(obj.fetch('secondary_number', {}))
|
|
25
|
+
@secondary_designator = MatchInfo.new(obj.fetch('secondary_designator', {}))
|
|
26
|
+
@extra_secondary_number = MatchInfo.new(obj.fetch('extra_secondary_number', {}))
|
|
27
|
+
@extra_secondary_designator = MatchInfo.new(obj.fetch('extra_secondary_designator', {}))
|
|
28
|
+
@city_name = MatchInfo.new(obj.fetch('city_name', {}))
|
|
29
|
+
@state_abbreviation = MatchInfo.new(obj.fetch('state_abbreviation', {}))
|
|
30
|
+
@zipcode = MatchInfo.new(obj.fetch('zipcode', {}))
|
|
31
|
+
@plus4_code = MatchInfo.new(obj.fetch('plus4_code', {}))
|
|
32
|
+
@urbanization = MatchInfo.new(obj.fetch('urbanization', {}))
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
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: 6.
|
|
4
|
+
version: 6.2.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: 2025-
|
|
11
|
+
date: 2025-10-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -97,6 +97,7 @@ files:
|
|
|
97
97
|
- examples/us_enrichment_example.rb
|
|
98
98
|
- examples/us_extract_example.rb
|
|
99
99
|
- examples/us_reverse_geo_example.rb
|
|
100
|
+
- examples/us_street_component_analysis_example.rb
|
|
100
101
|
- examples/us_street_multiple_address_example.rb
|
|
101
102
|
- examples/us_street_single_address_example.rb
|
|
102
103
|
- examples/us_zipcode_multiple_lookup_example.rb
|
|
@@ -105,6 +106,7 @@ files:
|
|
|
105
106
|
- lib/smartystreets_ruby_sdk/batch.rb
|
|
106
107
|
- lib/smartystreets_ruby_sdk/client_builder.rb
|
|
107
108
|
- lib/smartystreets_ruby_sdk/custom_header_sender.rb
|
|
109
|
+
- lib/smartystreets_ruby_sdk/custom_query_sender.rb
|
|
108
110
|
- lib/smartystreets_ruby_sdk/errors.rb
|
|
109
111
|
- lib/smartystreets_ruby_sdk/exceptions.rb
|
|
110
112
|
- lib/smartystreets_ruby_sdk/international_autocomplete.rb
|
|
@@ -181,6 +183,7 @@ files:
|
|
|
181
183
|
- lib/smartystreets_ruby_sdk/us_street/analysis.rb
|
|
182
184
|
- lib/smartystreets_ruby_sdk/us_street/candidate.rb
|
|
183
185
|
- lib/smartystreets_ruby_sdk/us_street/client.rb
|
|
186
|
+
- lib/smartystreets_ruby_sdk/us_street/component_analysis.rb
|
|
184
187
|
- lib/smartystreets_ruby_sdk/us_street/components.rb
|
|
185
188
|
- lib/smartystreets_ruby_sdk/us_street/lookup.rb
|
|
186
189
|
- lib/smartystreets_ruby_sdk/us_street/match_type.rb
|