smartystreets_ruby_sdk 10.0.0 → 10.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: 6dfe1e04d687c3c2b33c116f12115c921092875761773196e70b05686642147d
4
- data.tar.gz: c48c629d5c11195f679fe264b0fe4557e0fc78355e8f51b3ff62ebc463f27da8
3
+ metadata.gz: cb6d942045e702488251e2568a2130c99ded17b618bb2f944ad158f46ea8e5d1
4
+ data.tar.gz: 52fb7c510cf53f0730847da505e26b98b8c6c7b2bc904acf774533d3486964c3
5
5
  SHA512:
6
- metadata.gz: 1fdef4159968f9cdfd3a6e67afefc68ffdddbf527bc4331f424410274b27812c1cfce78c18ca81e8a3ccc817d4b0db267513a116c55e182d43e71e8ffee694c8
7
- data.tar.gz: 5fc398cc1452df089d87f0f13869b6ead3ebe387a9698d47881a064b498b8a10b992381e5ec26d95626e0dfdceb56ec47833f15e91601a60f6bbb9de513c4a6c
6
+ metadata.gz: '09b6013d45389218d20f30509f2f5fdf3e1111fa4838dbbe41da354bbc21a92441d64ebdfb0a2c03adf474e4a7ede41f61f50be1bc27a93b501f6836c4013da8'
7
+ data.tar.gz: de761e143d3ff251d1a174e3e210a308844d9b0c67e11289577b8de050f39e98297648d7fa6417e91c9b23f11d67ad75d5629a9d67f5144087b13d6fc1776278
data/CLAUDE.md CHANGED
@@ -44,7 +44,7 @@ URLPrefixSender → CustomQuerySender → LicenseSender → RetrySender → Sign
44
44
  ```
45
45
  `CustomHeaderSender` is only included when custom headers are configured; `RetrySender` only when max_retries > 0.
46
46
 
47
- **Authentication**: Three credential types — `StaticCredentials` (auth-id/auth-token), `SharedCredentials` (website key/hostname), and `BasicAuthCredentials` (basic auth header). Credentials are passed to `ClientBuilder` and injected into the sender chain via `SigningSender`.
47
+ **Authentication**: Three credential types — `StaticCredentials` (auth-id/auth-token), `SharedCredentials` (website key/hostname), and `BasicAuthCredentials` (basic auth header). Credentials are passed to `ClientBuilder` and injected into the sender chain via `SigningSender`. Embedded/website keys are GET-only, so they are not valid for batch (POST) requests or the US Extract API (POST-only): https://www.smarty.com/docs/cloud/authentication
48
48
 
49
49
  ### Key Components
50
50
 
@@ -4,9 +4,11 @@ require '../lib/smartystreets_ruby_sdk/basic_auth_credentials'
4
4
  require '../lib/smartystreets_ruby_sdk/client_builder'
5
5
  require '../lib/smartystreets_ruby_sdk/international_autocomplete/lookup'
6
6
  require '../lib/smartystreets_ruby_sdk/international_autocomplete/client'
7
+ require '../lib/smartystreets_ruby_sdk/international_autocomplete/language_mode'
7
8
 
8
9
  class InternationalAutocompleteExample
9
10
  Lookup = SmartyStreets::InternationalAutocomplete::Lookup
11
+ LanguageMode = SmartyStreets::InternationalAutocomplete::LanguageMode
10
12
 
11
13
  def run
12
14
  # key = 'Your SmartyStreets Auth Key here'
@@ -30,6 +32,7 @@ class InternationalAutocompleteExample
30
32
  lookup.locality = "Paris"
31
33
  lookup.max_group_results = 5
32
34
  lookup.geolocation = true
35
+ lookup.language = LanguageMode::NATIVE
33
36
 
34
37
  # lookup.add_custom_parameter('parameter', 'value')
35
38
 
@@ -34,6 +34,7 @@ class InternationalExample
34
34
  lookup.administrative_area = 'SP'
35
35
  lookup.country = 'Brazil'
36
36
  lookup.postal_code = '02516-050'
37
+ # lookup.max_results = 5 # Optional: maximum number of candidates to return
37
38
 
38
39
  # lookup.add_custom_parameter('parameter', 'value')
39
40
 
@@ -28,6 +28,8 @@ class InternationalPostalCodeExample
28
28
  lookup.administrative_area = 'SP'
29
29
  lookup.country = 'Brazil'
30
30
  lookup.postal_code = '02516'
31
+ # lookup.language = SmartyStreets::InternationalPostalCode::LanguageMode::LATIN # Optional: 'native' or 'latin'
32
+ # lookup.max_results = 10 # Optional: maximum number of candidates to return
31
33
 
32
34
  results = client.send_lookup(lookup)
33
35
 
@@ -44,6 +46,7 @@ class InternationalPostalCodeExample
44
46
  display(candidate.administrative_area)
45
47
  display(candidate.super_administrative_area)
46
48
  display(candidate.postal_code)
49
+ display(candidate.thoroughfare)
47
50
  puts
48
51
  end
49
52
  end
@@ -1,5 +1,4 @@
1
1
  require '../lib/smartystreets_ruby_sdk/static_credentials'
2
- require '../lib/smartystreets_ruby_sdk/shared_credentials'
3
2
  require '../lib/smartystreets_ruby_sdk/basic_auth_credentials'
4
3
  require '../lib/smartystreets_ruby_sdk/client_builder'
5
4
  require '../lib/smartystreets_ruby_sdk/us_extract/lookup'
@@ -10,12 +9,10 @@ class USExtractExample
10
9
  Lookup = SmartyStreets::USExtract::Lookup
11
10
 
12
11
  def run
13
- # key = 'Your SmartyStreets Auth Key here'
14
- # referer = 'Your host name here'
15
- # We recommend storing your secret keys in environment variables instead---it's safer!
16
- # key = ENV['SMARTY_AUTH_WEB']
17
- # referer = ENV['SMARTY_AUTH_REFERER']
18
- # credentials = SmartyStreets::SharedCredentials.new(key, referer)
12
+ # We recommend storing your secret keys in environment variables.
13
+ #
14
+ # The US Extract API is POST-only and embedded keys are restricted to GET, so this
15
+ # API requires secret keys: https://www.smarty.com/docs/cloud/authentication
19
16
 
20
17
  id = ENV['SMARTY_AUTH_ID']
21
18
  token = ENV['SMARTY_AUTH_TOKEN']
@@ -1,5 +1,4 @@
1
1
  require '../lib/smartystreets_ruby_sdk/static_credentials'
2
- require '../lib/smartystreets_ruby_sdk/shared_credentials'
3
2
  require '../lib/smartystreets_ruby_sdk/basic_auth_credentials'
4
3
  require '../lib/smartystreets_ruby_sdk/client_builder'
5
4
  require '../lib/smartystreets_ruby_sdk/batch'
@@ -11,7 +10,11 @@ class USStreetLookupsWithMatchStrategyExample
11
10
  MatchType = SmartyStreets::USStreet::MatchType
12
11
 
13
12
  def run
14
- # We recommend storing your secret keys in environment variables instead---it's safer!
13
+ # We recommend storing your secret keys in environment variables.
14
+ #
15
+ # Batch requests are sent via HTTP POST. Embedded keys are restricted to GET, so
16
+ # batches require secret keys: https://www.smarty.com/docs/cloud/authentication
17
+
15
18
  id = ENV['SMARTY_AUTH_ID']
16
19
  token = ENV['SMARTY_AUTH_TOKEN']
17
20
  credentials = SmartyStreets::BasicAuthCredentials.new(id, token)
@@ -1,5 +1,4 @@
1
1
  require '../lib/smartystreets_ruby_sdk/static_credentials'
2
- require '../lib/smartystreets_ruby_sdk/shared_credentials'
3
2
  require '../lib/smartystreets_ruby_sdk/basic_auth_credentials'
4
3
  require '../lib/smartystreets_ruby_sdk/client_builder'
5
4
  require '../lib/smartystreets_ruby_sdk/batch'
@@ -10,12 +9,10 @@ class USStreetMultipleAddressExample
10
9
  Lookup = SmartyStreets::USStreet::Lookup
11
10
 
12
11
  def run
13
- # key = 'Your SmartyStreets Auth Key here'
14
- # referer = 'Your host name here'
15
- # We recommend storing your secret keys in environment variables instead---it's safer!
16
- # key = ENV['SMARTY_AUTH_WEB']
17
- # referer = ENV['SMARTY_AUTH_REFERER']
18
- # credentials = SmartyStreets::SharedCredentials.new(key, referer)
12
+ # We recommend storing your secret keys in environment variables.
13
+ #
14
+ # Batch requests are sent via HTTP POST. Embedded keys are restricted to GET, so
15
+ # batches require secret keys: https://www.smarty.com/docs/cloud/authentication
19
16
 
20
17
  id = ENV['SMARTY_AUTH_ID']
21
18
  token = ENV['SMARTY_AUTH_TOKEN']
@@ -1,5 +1,4 @@
1
1
  require '../lib/smartystreets_ruby_sdk/static_credentials'
2
- require '../lib/smartystreets_ruby_sdk/shared_credentials'
3
2
  require '../lib/smartystreets_ruby_sdk/basic_auth_credentials'
4
3
  require '../lib/smartystreets_ruby_sdk/client_builder'
5
4
  require '../lib/smartystreets_ruby_sdk/batch'
@@ -9,12 +8,10 @@ class USZipcodeMultipleLookupExample
9
8
  Lookup = SmartyStreets::USZipcode::Lookup
10
9
 
11
10
  def run
12
- # key = 'Your SmartyStreets Auth Key here'
13
- # referer = 'Your host name here'
14
- # We recommend storing your secret keys in environment variables instead---it's safer!
15
- # key = ENV['SMARTY_AUTH_WEB']
16
- # referer = ENV['SMARTY_AUTH_REFERER']
17
- # credentials = SmartyStreets::SharedCredentials.new(key, referer)
11
+ # We recommend storing your secret keys in environment variables.
12
+ #
13
+ # Batch requests are sent via HTTP POST. Embedded keys are restricted to GET, so
14
+ # batches require secret keys: https://www.smarty.com/docs/cloud/authentication
18
15
 
19
16
  id = ENV['SMARTY_AUTH_ID']
20
17
  token = ENV['SMARTY_AUTH_TOKEN']
@@ -1,6 +1,7 @@
1
1
  require_relative '../request'
2
2
  require_relative '../exceptions'
3
3
  require_relative 'suggestion'
4
+ require_relative 'language_mode'
4
5
 
5
6
  module SmartyStreets
6
7
  module InternationalAutocomplete
@@ -43,6 +44,7 @@ module SmartyStreets
43
44
  add_parameter(request, 'geolocation', 'on') if lookup.geolocation
44
45
  add_parameter(request, 'include_only_locality', lookup.locality)
45
46
  add_parameter(request, 'include_only_postal_code', lookup.postal_code)
47
+ add_parameter(request, 'language', normalized_language(lookup.language))
46
48
 
47
49
  for key in lookup.custom_param_hash.keys do
48
50
  add_parameter(request, key, lookup.custom_param_hash[key])
@@ -65,6 +67,12 @@ module SmartyStreets
65
67
  def add_parameter(request, key, value)
66
68
  request.parameters[key] = value unless value.nil? or value.empty?
67
69
  end
70
+
71
+ def normalized_language(language)
72
+ return nil if language.nil?
73
+
74
+ LanguageMode.from_value(language).value
75
+ end
68
76
  end
69
77
  end
70
78
  end
@@ -0,0 +1,26 @@
1
+ require_relative '../exceptions'
2
+
3
+ module SmartyStreets
4
+ module InternationalAutocomplete
5
+ # A closed set of valid Language values, the closest Ruby equivalent to an enum: a fixed set of frozen
6
+ # instances rather than an arbitrary string.
7
+ class LanguageMode < Data.define(:value)
8
+ NATIVE = new('native')
9
+ LATIN = new('latin')
10
+
11
+ ALL = [NATIVE, LATIN].freeze
12
+
13
+ # Resolves a LanguageMode instance or a raw value (eg. from user input or config) into a LanguageMode,
14
+ # matching 'native'/'latin' regardless of case.
15
+ def self.from_value(value)
16
+ return value if value.is_a?(LanguageMode)
17
+
18
+ match = ALL.find { |mode| mode.value.casecmp?(value.to_s) }
19
+ raise SmartyStreets::UnprocessableEntityError,
20
+ "invalid Language value; must be unset, 'native', or 'latin' (case-insensitive)" if match.nil?
21
+
22
+ match
23
+ end
24
+ end
25
+ end
26
+ end
@@ -4,9 +4,13 @@ module SmartyStreets
4
4
  module InternationalAutocomplete
5
5
  # In addition to holding all of the input data for this lookup, this class also will contain the result
6
6
  # of the lookup after it comes back from the API.
7
+ #
8
+ # @language:: When not set, the output language will match the default for the country.
9
+ # When set to language_mode.NATIVE, the results will always be in the language of the output country.
10
+ # When set to language_mode.LATIN, the results will always be provided using a Latin character set.
7
11
  class Lookup < JSONAble
8
12
 
9
- attr_accessor :result, :search, :address_id, :country, :max_results, :max_group_results, :geolocation, :locality, :postal_code, :custom_param_hash
13
+ attr_accessor :result, :search, :address_id, :country, :max_results, :max_group_results, :geolocation, :locality, :postal_code, :language, :custom_param_hash
10
14
 
11
15
  def initialize(search = nil, address_id = nil, country = nil, max_results = nil, max_group_results = 100, geolocation = false, locality = nil, postal_code = nil, custom_param_hash = nil)
12
16
  @result = []
@@ -18,6 +22,7 @@ module SmartyStreets
18
22
  @geolocation = geolocation
19
23
  @locality = locality
20
24
  @postal_code = postal_code
25
+ @language = nil
21
26
  @custom_param_hash = {}
22
27
  end
23
28
 
@@ -1,6 +1,7 @@
1
1
  require_relative './international_autocomplete/lookup'
2
2
  require_relative './international_autocomplete/suggestion'
3
3
  require_relative './international_autocomplete/client'
4
+ require_relative './international_autocomplete/language_mode'
4
5
 
5
6
  module SmartyStreets
6
7
  module InternationalAutocomplete
@@ -13,7 +13,8 @@ module SmartyStreets
13
13
  :dependent_locality_name,
14
14
  :double_dependent_locality,
15
15
  :postal_code,
16
- :postal_code_extra
16
+ :postal_code_extra,
17
+ :thoroughfare
17
18
 
18
19
  def initialize(obj)
19
20
  @input_id = obj['input_id']
@@ -27,6 +28,7 @@ module SmartyStreets
27
28
  @double_dependent_locality = obj['double_dependent_locality']
28
29
  @postal_code = obj['postal_code']
29
30
  @postal_code_extra = obj['postal_code_extra']
31
+ @thoroughfare = obj['thoroughfare']
30
32
  end
31
33
  end
32
34
  end
@@ -1,6 +1,8 @@
1
1
  require_relative '../request'
2
2
  require_relative '../exceptions'
3
3
  require_relative 'candidate'
4
+ require_relative 'language_mode'
5
+ require_relative '../max_results'
4
6
 
5
7
  module SmartyStreets
6
8
  module InternationalPostalCode
@@ -35,6 +37,8 @@ module SmartyStreets
35
37
  add_parameter(request, 'locality', lookup.locality)
36
38
  add_parameter(request, 'administrative_area', lookup.administrative_area)
37
39
  add_parameter(request, 'postal_code', lookup.postal_code)
40
+ add_parameter(request, 'language', normalized_language(lookup.language))
41
+ add_parameter(request, 'max_results', MaxResults.normalize(lookup.max_results))
38
42
 
39
43
  request
40
44
  end
@@ -53,6 +57,12 @@ module SmartyStreets
53
57
  def add_parameter(request, key, value)
54
58
  request.parameters[key] = value unless value.nil? or value.empty?
55
59
  end
60
+
61
+ def normalized_language(language)
62
+ return nil if language.nil?
63
+
64
+ LanguageMode.from_value(language).value
65
+ end
56
66
  end
57
67
  end
58
68
  end
@@ -0,0 +1,26 @@
1
+ require_relative '../exceptions'
2
+
3
+ module SmartyStreets
4
+ module InternationalPostalCode
5
+ # A closed set of valid Language values, the closest Ruby equivalent to an enum: a fixed set of frozen
6
+ # instances rather than an arbitrary string.
7
+ class LanguageMode < Data.define(:value)
8
+ NATIVE = new('native')
9
+ LATIN = new('latin')
10
+
11
+ ALL = [NATIVE, LATIN].freeze
12
+
13
+ # Resolves a LanguageMode instance or a raw value (eg. from user input or config) into a LanguageMode,
14
+ # matching 'native'/'latin' regardless of case.
15
+ def self.from_value(value)
16
+ return value if value.is_a?(LanguageMode)
17
+
18
+ match = ALL.find { |mode| mode.value.casecmp?(value.to_s) }
19
+ raise SmartyStreets::UnprocessableEntityError,
20
+ "invalid Language value; must be unset, 'native', or 'latin' (case-insensitive)" if match.nil?
21
+
22
+ match
23
+ end
24
+ end
25
+ end
26
+ end
@@ -2,9 +2,15 @@ module SmartyStreets
2
2
  module InternationalPostalCode
3
3
  # Holds the input data for a postal code lookup and the results returned by the API.
4
4
  # See https://smartystreets.com/docs/cloud/international-postal-code-api
5
+ #
6
+ # @language:: When not set, results are returned using the Latin character set.
7
+ # When set to language_mode.NATIVE (JPN only), results are returned in the native character set for that country.
8
+ # When set to language_mode.LATIN, results use the Latin character set with accents and other diacritics removed.
9
+ # @max_results:: Optional. The maximum number of candidates to return. Omitted from the request when unset or 0.
5
10
  class Lookup
6
11
 
7
- attr_accessor :input_id, :country, :locality, :administrative_area, :postal_code, :results
12
+ attr_accessor :input_id, :country, :locality, :administrative_area, :postal_code, :language, :max_results,
13
+ :results
8
14
 
9
15
  def initialize
10
16
  @input_id = nil
@@ -12,6 +18,8 @@ module SmartyStreets
12
18
  @locality = nil
13
19
  @administrative_area = nil
14
20
  @postal_code = nil
21
+ @language = nil
22
+ @max_results = nil
15
23
  @results = []
16
24
  end
17
25
  end
@@ -1,5 +1,6 @@
1
1
  require 'smartystreets_ruby_sdk/international_postal_code/lookup'
2
2
  require 'smartystreets_ruby_sdk/international_postal_code/candidate'
3
3
  require 'smartystreets_ruby_sdk/international_postal_code/client'
4
+ require 'smartystreets_ruby_sdk/international_postal_code/language_mode'
4
5
 
5
6
 
@@ -1,6 +1,7 @@
1
1
  require_relative '../request'
2
2
  require_relative 'candidate'
3
3
  require_relative 'language_mode'
4
+ require_relative '../max_results'
4
5
 
5
6
  module SmartyStreets
6
7
  module InternationalStreet
@@ -57,6 +58,7 @@ module SmartyStreets
57
58
  add_parameter(request, 'administrative_area', lookup.administrative_area)
58
59
  add_parameter(request, 'postal_code', lookup.postal_code)
59
60
  add_parameter(request, 'features', lookup.features)
61
+ add_parameter(request, 'max_results', MaxResults.normalize(lookup.max_results))
60
62
 
61
63
  for key in lookup.custom_param_hash.keys do
62
64
  add_parameter(request, key, lookup.custom_param_hash[key])
@@ -14,11 +14,12 @@ module SmartyStreets
14
14
  # @language:: When not set, the output language will match the language of the input values.
15
15
  # When set to language_mode.NATIVE, the results will always be in the language of the output country.
16
16
  # When set to language_mode.LATIN, the results will always be provided using a Latin character set.
17
+ # @max_results:: Optional. The maximum number of candidates to return. Omitted from the request when unset or 0.
17
18
  class Lookup
18
19
 
19
20
  attr_accessor :input_id, :freeform, :locality, :postal_code, :address3, :address2, :inputId, :address1,
20
21
  :geocode, :administrative_area, :country, :organization, :language, :address4, :result,
21
- :features, :custom_param_hash
22
+ :features, :max_results, :custom_param_hash
22
23
 
23
24
  def initialize(freeform=nil, country=nil)
24
25
  @result = []
@@ -37,6 +38,7 @@ module SmartyStreets
37
38
  @administrative_area = nil
38
39
  @postal_code = nil
39
40
  @features = nil
41
+ @max_results = nil
40
42
  @custom_param_hash = {}
41
43
  end
42
44
 
@@ -0,0 +1,23 @@
1
+ require_relative 'exceptions'
2
+
3
+ module SmartyStreets
4
+ # Shared handling for the max_results input: accepts a whole number (or a string holding one),
5
+ # and returns it as a string only when it is above 0, so it can be sent as a query parameter.
6
+ # Unset (nil or blank) returns nil; anything that isn't a whole number raises.
7
+ module MaxResults
8
+ WHOLE_NUMBER = /\A\s*[+-]?\d+\s*\z/
9
+
10
+ def self.normalize(value)
11
+ return nil if value.nil? || (value.is_a?(String) && value.strip.empty?)
12
+
13
+ number = case value
14
+ when Integer then value
15
+ when Float then value.to_i if value.finite? && value == value.floor
16
+ when String then value.to_i if value.match?(WHOLE_NUMBER)
17
+ end
18
+ raise SmartyStreets::UnprocessableEntityError, 'invalid max_results value; must be a whole number' if number.nil?
19
+
20
+ number.positive? ? number.to_s : nil
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module SmartyStreets
2
- VERSION = '10.0.0' # DO NOT EDIT (this is updated by a build job when a new release is published)
2
+ VERSION = '10.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: 10.0.0
4
+ version: 10.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: 2026-08-19 00:00:00.000000000 Z
11
+ date: 2026-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -123,11 +123,13 @@ files:
123
123
  - lib/smartystreets_ruby_sdk/exceptions.rb
124
124
  - lib/smartystreets_ruby_sdk/international_autocomplete.rb
125
125
  - lib/smartystreets_ruby_sdk/international_autocomplete/client.rb
126
+ - lib/smartystreets_ruby_sdk/international_autocomplete/language_mode.rb
126
127
  - lib/smartystreets_ruby_sdk/international_autocomplete/lookup.rb
127
128
  - lib/smartystreets_ruby_sdk/international_autocomplete/suggestion.rb
128
129
  - lib/smartystreets_ruby_sdk/international_postal_code.rb
129
130
  - lib/smartystreets_ruby_sdk/international_postal_code/candidate.rb
130
131
  - lib/smartystreets_ruby_sdk/international_postal_code/client.rb
132
+ - lib/smartystreets_ruby_sdk/international_postal_code/language_mode.rb
131
133
  - lib/smartystreets_ruby_sdk/international_postal_code/lookup.rb
132
134
  - lib/smartystreets_ruby_sdk/international_street.rb
133
135
  - lib/smartystreets_ruby_sdk/international_street/analysis.rb
@@ -142,6 +144,7 @@ files:
142
144
  - lib/smartystreets_ruby_sdk/json_able.rb
143
145
  - lib/smartystreets_ruby_sdk/license_sender.rb
144
146
  - lib/smartystreets_ruby_sdk/logger.rb
147
+ - lib/smartystreets_ruby_sdk/max_results.rb
145
148
  - lib/smartystreets_ruby_sdk/native_sender.rb
146
149
  - lib/smartystreets_ruby_sdk/native_serializer.rb
147
150
  - lib/smartystreets_ruby_sdk/proxy.rb