smartystreets_ruby_sdk 6.1.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 954bacc17a899a815959f93e7c44494e7514305cfb64cf96df12816c8397ab12
4
- data.tar.gz: 05e7e0e7544e5eddbc31de48e7d1f94a1187dbd9399aa2e957d20b6da93276cb
3
+ metadata.gz: 004ff7e3e907b690ae90319ec80fc5ae0a39e0110811271d0b5af96078d97a13
4
+ data.tar.gz: 7f4ff64365804d28130f2714583e211f9c7051849a435c35e7ad36e22c3f822a
5
5
  SHA512:
6
- metadata.gz: 61e551343736810efdb5d1d0f35811523551280bda4b633a0b6607f3c66b43485e35b1d4b5b652d8d28a7603eb4e78df8cc622c9587ea673b87b4be92945e6af
7
- data.tar.gz: 9e30ec67d9f24d9d2f5c667ef493e0433d1838a3a73131cf1223a3347fb9a141d88eb075a7e55514b6ca34498acdca2bad12ec18ab09991ce6d639d52a9cabd7
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module SmartyStreets
2
- VERSION = '6.1.2' # DO NOT EDIT (this is updated by a build job when a new release is published)
2
+ VERSION = '6.2.0' # DO NOT EDIT (this is updated by a build job when a new release is published)
3
3
  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.1.2
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-10-21 00:00:00.000000000 Z
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
@@ -182,6 +183,7 @@ files:
182
183
  - lib/smartystreets_ruby_sdk/us_street/analysis.rb
183
184
  - lib/smartystreets_ruby_sdk/us_street/candidate.rb
184
185
  - lib/smartystreets_ruby_sdk/us_street/client.rb
186
+ - lib/smartystreets_ruby_sdk/us_street/component_analysis.rb
185
187
  - lib/smartystreets_ruby_sdk/us_street/components.rb
186
188
  - lib/smartystreets_ruby_sdk/us_street/lookup.rb
187
189
  - lib/smartystreets_ruby_sdk/us_street/match_type.rb