smartystreets_ruby_sdk 5.9.0 → 5.11.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52fd48c6c51199f3dcd357a5acc5f6bc16a6ea53ed8d5467be6a00bfe5abb864
4
- data.tar.gz: faebc7c05c2e636c6c7b0cc687d24970abf7b1a695c8d4d68a03d5a62e8e46c1
3
+ metadata.gz: 76535338d0306bc77ed2b85bf80c0fb8de67f4c75597fe5680a8d20b79709a12
4
+ data.tar.gz: 485f697dfc44b1a9bb8589cecd8495f770d3f65e513a29ea2e6a390ac6c03eb4
5
5
  SHA512:
6
- metadata.gz: b0d0d14bd4b4e8846f588b3743f7fc1fe026d3cb5270935885cde1d371d85bc01342b2a1b8cb62a4220392d064e5a76fb375fe497ee5400b2ccb1d59832a8a45
7
- data.tar.gz: 8270d077871bf469999c5a864f58374f78000276ad4cbdcc85cc395d43c40f3d7152a71e4aa7c4ed7e8cd1d0731b24c5031557d417cb30891aedc2033a9d71cc
6
+ metadata.gz: c822627163eca11ccffd2bde54e08b853f6d782d82e05abbf17ea295bedf0ac7f41a5dba3261dbf3350527910b222031cf94f0ed2103d683fcea00028f55122a
7
+ data.tar.gz: 730369107a715aa070314d6be7b59603ef10516108954d7d93314418f38b0f4d0f485cb9e8336f4ca085d115dfd1b64092ad5d672e710201dd0e606e8ef58530
@@ -14,7 +14,11 @@ class InternationalExample
14
14
  # auth_token = ENV['SMARTY_AUTH_TOKEN']
15
15
 
16
16
  credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
17
- client = SmartyStreets::ClientBuilder.new(credentials) # .with_licenses(%w(international-fake-license))
17
+
18
+ # The appropriate license values to be used for your subscriptions
19
+ # can be found on the Subscriptions page of the account dashboard.
20
+ # https://www.smartystreets.com/docs/cloud/licensing
21
+ client = SmartyStreets::ClientBuilder.new(credentials).with_licenses(['international-global-plus-cloud'])
18
22
  .build_international_street_api_client
19
23
 
20
24
  # Documentation for input fields can be found at:
@@ -0,0 +1,48 @@
1
+ require 'smartystreets_ruby_sdk/shared_credentials'
2
+ require '../lib/smartystreets_ruby_sdk/client_builder'
3
+ require '../lib/smartystreets_ruby_sdk/us_autocomplete_pro/lookup'
4
+
5
+ class USAutocompleteProExample
6
+ Lookup = SmartyStreets::USAutocompletePro::Lookup
7
+
8
+ def run
9
+ # key = 'Your SmartyStreets Auth ID here'
10
+ # hostname = 'Your SmartyStreets Auth Token here'
11
+
12
+ # We recommend storing your secret keys in environment variables instead---it's safer!
13
+ key = ENV['SMARTY_AUTH_WEB']
14
+ referer = ENV['SMARTY_AUTH_REFERER']
15
+
16
+ credentials = SmartyStreets::SharedCredentials.new(key, referer)
17
+
18
+ # The appropriate license values to be used for your subscriptions
19
+ # can be found on the Subscriptions page of the account dashboard.
20
+ # https://www.smartystreets.com/docs/cloud/licensing
21
+ client = SmartyStreets::ClientBuilder.new(credentials).with_licenses(['us-autocomplete-pro-cloud'])
22
+ .build_us_autocomplete_pro_api_client
23
+
24
+ # Documentation for input fields can be found at:
25
+ # https://smartystreets.com/docs/cloud/us-autocomplete-api
26
+
27
+ lookup = Lookup.new('4770 Lincoln Ave O')
28
+ lookup.max_results = 10
29
+ lookup.add_city_filter('Ogden')
30
+ lookup.add_state_filter('IL')
31
+ lookup.max_results = 5
32
+ lookup.prefer_ratio = 3
33
+
34
+ suggestions = client.send(lookup) # The client will also return the suggestions directly
35
+
36
+ puts
37
+ puts '*** Result with some filters ***'
38
+ puts
39
+
40
+ suggestions.each do |suggestion|
41
+ puts "#{suggestion.street_line} #{suggestion.city}, #{suggestion.state}"
42
+ end
43
+
44
+ end
45
+ end
46
+
47
+ USAutocompleteProExample.new.run
48
+
@@ -14,7 +14,11 @@ class USReverseGeoExample
14
14
  # auth_token = ENV['SMARTY_AUTH_TOKEN']
15
15
 
16
16
  credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
17
- client = SmartyStreets::ClientBuilder.new(credentials)
17
+
18
+ # The appropriate license values to be used for your subscriptions
19
+ # can be found on the Subscriptions page of the account dashboard.
20
+ # https://www.smartystreets.com/docs/cloud/licensing
21
+ client = SmartyStreets::ClientBuilder.new(credentials).with_licenses(['us-reverse-geocoding-cloud'])
18
22
  .build_us_reverse_geo_api_client
19
23
 
20
24
  # Documentation for input fields can be found at:
@@ -36,6 +40,7 @@ class USReverseGeoExample
36
40
  puts "City: #{address.city}"
37
41
  puts "State Abbreviation: #{address.state_abbreviation}"
38
42
  puts "ZIP Code: #{address.zipcode}"
43
+ puts "License: #{coordinate.get_license}"
39
44
  end
40
45
  end
41
46
 
@@ -16,7 +16,10 @@ class USStreetMultipleAddressExample
16
16
 
17
17
  credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
18
18
 
19
- client = SmartyStreets::ClientBuilder.new(credentials) # .with_licenses(%w(us-rooftop-geocoding-cloud))
19
+ # The appropriate license values to be used for your subscriptions
20
+ # can be found on the Subscriptions page of the account dashboard.
21
+ # https://www.smartystreets.com/docs/cloud/licensing
22
+ client = SmartyStreets::ClientBuilder.new(credentials).with_licenses(['us-rooftop-geocoding-cloud'])
20
23
  .build_us_street_api_client
21
24
  batch = SmartyStreets::Batch.new
22
25
 
@@ -13,7 +13,10 @@ class USStreetSingleAddressExample
13
13
 
14
14
  credentials = SmartyStreets::StaticCredentials.new(auth_id, auth_token)
15
15
 
16
- client = SmartyStreets::ClientBuilder.new(credentials).
16
+ # The appropriate license values to be used for your subscriptions
17
+ # can be found on the Subscriptions page of the account dashboard.
18
+ # https://www.smartystreets.com/docs/cloud/licensing
19
+ client = SmartyStreets::ClientBuilder.new(credentials).with_licenses(['us-rooftop-geocoding-cloud'])
17
20
  # with_proxy('localhost', 8080, 'proxyUser', 'proxyPassword'). # Uncomment this line to try it with a proxy
18
21
  build_us_street_api_client
19
22
 
@@ -25,6 +25,7 @@ require 'smartystreets_ruby_sdk/us_extract'
25
25
  require 'smartystreets_ruby_sdk/us_street'
26
26
  require 'smartystreets_ruby_sdk/us_zipcode'
27
27
  require 'smartystreets_ruby_sdk/us_autocomplete'
28
+ require 'smartystreets_ruby_sdk/us_autocomplete_pro'
28
29
  require 'smartystreets_ruby_sdk/international_street'
29
30
  require 'smartystreets_ruby_sdk/us_reverse_geo'
30
31
 
@@ -15,6 +15,7 @@ require_relative 'us_extract/client'
15
15
  require_relative 'us_autocomplete/client'
16
16
  require_relative 'international_street/client'
17
17
  require_relative 'us_reverse_geo/client'
18
+ require_relative 'us_autocomplete_pro/client'
18
19
 
19
20
  module SmartyStreets
20
21
  # The ClientBuilder class helps you build a client object for one of the supported SmartyStreets APIs.
@@ -23,6 +24,7 @@ module SmartyStreets
23
24
  class ClientBuilder
24
25
  INTERNATIONAL_STREET_API_URL = 'https://international-street.api.smartystreets.com/verify'.freeze
25
26
  US_AUTOCOMPLETE_API_URL = 'https://us-autocomplete.api.smartystreets.com/suggest'.freeze
27
+ US_AUTOCOMPLETE_PRO_API_URL = 'https://us-autocomplete-pro.api.smartystreets.com/lookup'.freeze
26
28
  US_EXTRACT_API_URL = 'https://us-extract.api.smartystreets.com/'.freeze
27
29
  US_STREET_API_URL = 'https://us-street.api.smartystreets.com/street-address'.freeze
28
30
  US_ZIP_CODE_API_URL = 'https://us-zipcode.api.smartystreets.com/lookup'.freeze
@@ -128,6 +130,11 @@ module SmartyStreets
128
130
  USAutocomplete::Client.new(build_sender, @serializer)
129
131
  end
130
132
 
133
+ def build_us_autocomplete_pro_api_client
134
+ ensure_url_prefix_not_null(US_AUTOCOMPLETE_PRO_API_URL)
135
+ USAutocompletePro::Client.new(build_sender, @serializer)
136
+ end
137
+
131
138
  def build_us_extract_api_client
132
139
  ensure_url_prefix_not_null(US_EXTRACT_API_URL)
133
140
  USExtract::Client.new(build_sender, @serializer)
@@ -50,8 +50,10 @@ module SmartyStreets
50
50
  def convert_candidates(raw_candidates)
51
51
  candidates = []
52
52
 
53
- raw_candidates.each do |candidate|
54
- candidates.push(Candidate.new(candidate))
53
+ unless raw_candidates.nil?
54
+ raw_candidates.each do |candidate|
55
+ candidates.push(Candidate.new(candidate))
56
+ end
55
57
  end
56
58
 
57
59
  candidates
@@ -6,7 +6,7 @@ module SmartyStreets
6
6
  end
7
7
 
8
8
  def sign(request)
9
- request.parameters['auth-id'] = @id
9
+ request.parameters['key'] = @id
10
10
  request.referer = @host_name
11
11
  end
12
12
  end
@@ -0,0 +1,10 @@
1
+ require_relative './us_autocomplete_pro/lookup'
2
+ require_relative './us_autocomplete_pro/geolocation_type'
3
+ require_relative './us_autocomplete_pro/suggestion'
4
+ require_relative './us_autocomplete_pro/client'
5
+
6
+ module SmartyStreets
7
+ module USAutocompletePro
8
+ end
9
+ end
10
+
@@ -0,0 +1,77 @@
1
+ require_relative '../request'
2
+ require_relative '../exceptions'
3
+ require_relative 'geolocation_type'
4
+ require_relative 'suggestion'
5
+
6
+ module SmartyStreets
7
+ module USAutocompletePro
8
+ # It is recommended to instantiate this class using ClientBuilder.build_us_autocomplete_pro_api_client
9
+ class Client
10
+ def initialize(sender, serializer)
11
+ @sender = sender
12
+ @serializer = serializer
13
+ end
14
+
15
+ # Sends a Lookup object to the US Autocomplete Pro API and stores the result in the Lookup's result field.
16
+ def send(lookup)
17
+ if not lookup or not lookup.search
18
+ raise SmartyStreets::SmartyError, 'Send() must be passed a Lookup with the prefix field set.'
19
+ end
20
+
21
+ request = build_request(lookup)
22
+
23
+ response = @sender.send(request)
24
+
25
+ raise response.error if response.error
26
+
27
+ result = @serializer.deserialize(response.payload)
28
+ suggestions = convert_suggestions(result.fetch('suggestions', []))
29
+ lookup.result = suggestions
30
+ end
31
+
32
+
33
+ def build_request(lookup)
34
+ request = Request.new
35
+
36
+ add_parameter(request, 'search', lookup.search)
37
+ add_parameter(request, 'max_results', lookup.max_results.to_s)
38
+ add_parameter(request, 'include_only_cities', build_filter_string(lookup.city_filter))
39
+ add_parameter(request, 'include_only_states', build_filter_string(lookup.state_filter))
40
+ add_parameter(request, 'include_only_zip_codes', build_filter_string(lookup.zip_filter))
41
+ add_parameter(request, 'exclude_states', build_filter_string(lookup.exclude_states))
42
+ add_parameter(request, 'prefer_cities', build_filter_string(lookup.prefer_cities))
43
+ add_parameter(request, 'prefer_states', build_filter_string(lookup.prefer_states))
44
+ add_parameter(request, 'prefer_zip_codes', build_filter_string(lookup.prefer_zip_codes))
45
+ add_parameter(request, 'prefer_ratio', lookup.prefer_ratio.to_s)
46
+ if lookup.prefer_zip_codes or lookup.zip_filter
47
+ request.parameters['prefer_geolocation'] = GeolocationType::NONE
48
+ else
49
+ add_parameter(request, 'prefer_geolocation', lookup.prefer_geolocation)
50
+ end
51
+ add_parameter(request, 'selected', lookup.selected)
52
+
53
+ request
54
+ end
55
+
56
+ def build_filter_string(filter_list)
57
+ filter_list ? filter_list.join(',') : nil
58
+ end
59
+
60
+ def convert_suggestions(suggestion_hashes)
61
+ converted_suggestions = []
62
+ return converted_suggestions if suggestion_hashes.nil?
63
+
64
+ suggestion_hashes.each do |suggestion|
65
+ converted_suggestions.push(USAutocompletePro::Suggestion.new(suggestion))
66
+ end
67
+
68
+ converted_suggestions
69
+ end
70
+
71
+ def add_parameter(request, key, value)
72
+ request.parameters[key] = value unless value.nil? or value.empty?
73
+ end
74
+ end
75
+ end
76
+ end
77
+
@@ -0,0 +1,8 @@
1
+ module SmartyStreets
2
+ module USAutocompletePro
3
+ module GeolocationType
4
+ CITY = 'city'
5
+ NONE = 'none'
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,61 @@
1
+ require_relative '../json_able'
2
+
3
+ module SmartyStreets
4
+ module USAutocompletePro
5
+ # In addition to holding all of the input data for this lookup, this class also will contain the result
6
+ # of the lookup after it comes back from the API.
7
+ #
8
+ # See "https://smartystreets.com/docs/cloud/us-autocomplete-api#http-request-input-fields"
9
+ class Lookup < JSONAble
10
+
11
+ attr_accessor :result, :search, :max_results, :city_filter, :state_filter, :zip_filter,
12
+ :exclude_states, :prefer_cities, :prefer_states, :prefer_zip_codes, :prefer_ratio, :prefer_geolocation, :selected
13
+
14
+ def initialize(search=nil, max_results=nil, city_filter=nil, state_filter=nil, zip_filter=nil,
15
+ exclude_states=nil, prefer_cities=nil, prefer_states=nil, prefer_zips=nil, prefer_ratio=nil,
16
+ prefer_geolocation=nil, selected=nil)
17
+ @result = []
18
+ @search = search
19
+ @max_results = max_results
20
+ @city_filter = city_filter ? city_filter : []
21
+ @state_filter = state_filter ? state_filter : []
22
+ @zip_filter = zip_filter ? zip_filter : []
23
+ @exclude_states = exclude_states ? exclude_states : []
24
+ @prefer_cities = prefer_cities ? prefer_cities : []
25
+ @prefer_states = prefer_states ? prefer_states : []
26
+ @prefer_zip_codes = prefer_zips ? prefer_zips : []
27
+ @prefer_ratio = prefer_ratio
28
+ @prefer_geolocation = prefer_geolocation
29
+ @selected = selected
30
+ end
31
+
32
+ def add_city_filter(city)
33
+ @city_filter.push(city)
34
+ end
35
+
36
+ def add_state_filter(state)
37
+ @state_filter.push(state)
38
+ end
39
+
40
+ def add_zip_filter(zip)
41
+ @zip_filter.push(zip)
42
+ end
43
+
44
+ def add_state_exclusion(state)
45
+ @exclude_states.push(state)
46
+ end
47
+
48
+ def add_preferred_city(city)
49
+ @prefer_cities.push(city)
50
+ end
51
+
52
+ def add_preferred_state(state)
53
+ @prefer_states.push(state)
54
+ end
55
+
56
+ def add_preferred_zip(zip)
57
+ @prefer_zip_codes.push(zip)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,18 @@
1
+ module SmartyStreets
2
+ module USAutocompletePro
3
+ # See "https://smartystreets.com/docs/cloud/us-autocomplete-api#http-response"
4
+ class Suggestion
5
+
6
+ attr_reader :street_line, :secondary, :city, :state, :zipcode, :entries
7
+
8
+ def initialize(obj)
9
+ @street_line = obj.fetch('street_line', nil)
10
+ @secondary = obj.fetch('secondary', nil)
11
+ @city = obj.fetch('city', nil)
12
+ @state = obj.fetch('state', nil)
13
+ @zipcode = obj.fetch('zipcode', nil)
14
+ @entries = obj.fetch('entries', 0)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -10,6 +10,15 @@ module SmartyStreets
10
10
  @accuracy = obj.fetch('accuracy', nil)
11
11
  @license = obj.fetch('license', nil)
12
12
  end
13
+
14
+ def get_license()
15
+ case @license
16
+ when 1
17
+ return "SmartyStreets Proprietary"
18
+ else
19
+ return "SmartyStreets"
20
+ end
21
+ end
13
22
  end
14
23
  end
15
24
  end
@@ -3,19 +3,22 @@ module SmartyStreets
3
3
  # See "https://smartystreets.com/docs/cloud/us-street-api#analysis"
4
4
  class Analysis
5
5
  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
6
+ :is_ews_match, :dpv_footnotes, :cmra, :vacant, :no_stat, :match_mode, :match_details
7
7
 
8
8
  def initialize(obj)
9
9
  @dpv_match_code = obj['dpv_match_code']
10
10
  @dpv_footnotes = obj['dpv_footnotes']
11
11
  @cmra = obj['dpv_cmra']
12
12
  @vacant = obj['dpv_vacant']
13
+ @no_stat = obj['dpv_no_stat']
13
14
  @active = obj['active']
14
15
  @is_ews_match = obj['ews_match']
15
16
  @footnotes = obj['footnotes']
16
17
  @lacs_link_code = obj['lacslink_code']
17
18
  @lacs_link_indicator = obj['lacslink_indicator']
18
19
  @is_suite_link_match = obj['suitelink_match']
20
+ @match_mode = obj['match_mode']
21
+ @match_details = obj['match_details']
19
22
  end
20
23
  end
21
24
  end
@@ -1,3 +1,3 @@
1
1
  module SmartyStreets
2
- VERSION = '5.9.0' # DO NOT EDIT (this is updated by a build job when a new release is published)
2
+ VERSION = '5.11.1' # 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: 5.9.0
4
+ version: 5.11.1
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: 2020-10-29 00:00:00.000000000 Z
11
+ date: 2021-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,6 +92,7 @@ files:
92
92
  - docker-compose.yml
93
93
  - examples/international_example.rb
94
94
  - examples/us_autocomplete_example.rb
95
+ - examples/us_autocomplete_pro_example.rb
95
96
  - examples/us_extract_example.rb
96
97
  - examples/us_reverse_geo_example.rb
97
98
  - examples/us_street_multiple_address_example.rb
@@ -134,6 +135,11 @@ files:
134
135
  - lib/smartystreets_ruby_sdk/us_autocomplete/geolocation_type.rb
135
136
  - lib/smartystreets_ruby_sdk/us_autocomplete/lookup.rb
136
137
  - lib/smartystreets_ruby_sdk/us_autocomplete/suggestion.rb
138
+ - lib/smartystreets_ruby_sdk/us_autocomplete_pro.rb
139
+ - lib/smartystreets_ruby_sdk/us_autocomplete_pro/client.rb
140
+ - lib/smartystreets_ruby_sdk/us_autocomplete_pro/geolocation_type.rb
141
+ - lib/smartystreets_ruby_sdk/us_autocomplete_pro/lookup.rb
142
+ - lib/smartystreets_ruby_sdk/us_autocomplete_pro/suggestion.rb
137
143
  - lib/smartystreets_ruby_sdk/us_extract.rb
138
144
  - lib/smartystreets_ruby_sdk/us_extract/address.rb
139
145
  - lib/smartystreets_ruby_sdk/us_extract/client.rb