smartystreets_ruby_sdk 10.1.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: 451e124efa79d87aed1df0f4a4a595b698463835d8ffc4461168d439da9e2b56
4
- data.tar.gz: dbd7c8c731275bd1bc62e8fb0cc0e930e18ad0ce886b26e8bd570f84f0a4f4a7
3
+ metadata.gz: cb6d942045e702488251e2568a2130c99ded17b618bb2f944ad158f46ea8e5d1
4
+ data.tar.gz: 52fb7c510cf53f0730847da505e26b98b8c6c7b2bc904acf774533d3486964c3
5
5
  SHA512:
6
- metadata.gz: 8e4c92f2f87638cfb7ae504599040b5745eec1d6553333409648077e5962d112f5d66a771435a78f3701d12e555d034e6821ad7d690fc97aa45214923f4b42e1
7
- data.tar.gz: e3c2516ec819aab127324cd4ae3f211e2ec1fe363a80aa2ff490993ce3b0859cccc85c2b99244080f95b90b5ef67d32d93c104e7afd171922b50a7490eb79fdc
6
+ metadata.gz: '09b6013d45389218d20f30509f2f5fdf3e1111fa4838dbbe41da354bbc21a92441d64ebdfb0a2c03adf474e4a7ede41f61f50be1bc27a93b501f6836c4013da8'
7
+ data.tar.gz: de761e143d3ff251d1a174e3e210a308844d9b0c67e11289577b8de050f39e98297648d7fa6417e91c9b23f11d67ad75d5629a9d67f5144087b13d6fc1776278
@@ -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
@@ -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.1.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.1.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-10-01 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
@@ -129,6 +129,7 @@ files:
129
129
  - lib/smartystreets_ruby_sdk/international_postal_code.rb
130
130
  - lib/smartystreets_ruby_sdk/international_postal_code/candidate.rb
131
131
  - lib/smartystreets_ruby_sdk/international_postal_code/client.rb
132
+ - lib/smartystreets_ruby_sdk/international_postal_code/language_mode.rb
132
133
  - lib/smartystreets_ruby_sdk/international_postal_code/lookup.rb
133
134
  - lib/smartystreets_ruby_sdk/international_street.rb
134
135
  - lib/smartystreets_ruby_sdk/international_street/analysis.rb
@@ -143,6 +144,7 @@ files:
143
144
  - lib/smartystreets_ruby_sdk/json_able.rb
144
145
  - lib/smartystreets_ruby_sdk/license_sender.rb
145
146
  - lib/smartystreets_ruby_sdk/logger.rb
147
+ - lib/smartystreets_ruby_sdk/max_results.rb
146
148
  - lib/smartystreets_ruby_sdk/native_sender.rb
147
149
  - lib/smartystreets_ruby_sdk/native_serializer.rb
148
150
  - lib/smartystreets_ruby_sdk/proxy.rb