smartystreets_ruby_sdk 5.19.0 → 5.20.3

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: 51cb2a009b7e285e29d6f6fb5e689a365105c69b1ee91988708a54277c646e36
4
- data.tar.gz: 2125742bceda76772db7d941461247cc4a30d4bb09a70092d58b51f8857b5281
3
+ metadata.gz: 3c69c7e08647e5946fbfb968e690c6e6398aa52d8ea2cf2d9d24d332873df006
4
+ data.tar.gz: f8f16488a89c08c76d1fcbcb6f52d53c44b4c5c98d3b99593a40b6af98b8820d
5
5
  SHA512:
6
- metadata.gz: 4c24e7dd98c9b13c60567a41f6b41e111cde5dfc65b730541eabca7eb68b9b24d1f67b81165205aa52db00fca1c58efcde3473fe74c2530b77d52ab8230da809
7
- data.tar.gz: 9c5ca611177e645518e1dc4dffdc4762a8580dfc1a8a51c0fdd62c0b00a24962c2ef91b5d2e9e73e13760c6c0766c045f205f8bc00d5fa069ad3815dd71bb7b4
6
+ metadata.gz: 4d6468052deaf16a12101cc6bb0bf89c615ef2b5c97da3e8bf603ce70c09c18a08252f4d4b7fc6c7b735d670c2d63f6d0597256245b6e30aec51aee66b8b72a6
7
+ data.tar.gz: 01464c7a27f5655fed30d94d496551c14a81b1fe5f6bed77a114366b8578e97db6fcbbb6d7ca64b7744e9eb7ff511699e6ed0304ebeb41e7dc5f9fa90727b5fd
@@ -1,6 +1,7 @@
1
1
  require '../lib/smartystreets_ruby_sdk/static_credentials'
2
2
  require '../lib/smartystreets_ruby_sdk/shared_credentials'
3
3
  require '../lib/smartystreets_ruby_sdk/client_builder'
4
+ require '../lib/smartystreets_ruby_sdk/us_enrichment/lookup'
4
5
 
5
6
  class USEnrichmentAddressExample
6
7
  def run
@@ -24,9 +25,35 @@ class USEnrichmentAddressExample
24
25
  client = SmartyStreets::ClientBuilder.new(credentials).
25
26
  build_us_enrichment_api_client
26
27
  result = nil
28
+
29
+ # Create a new lookup instance to search with address components
30
+ lookup = SmartyStreets::USEnrichment::Lookup.new
31
+
32
+ lookup.street = "56 Union Ave"
33
+ lookup.city = "Somerville"
34
+ lookup.state = "NJ"
35
+ lookup.zipcode = "08876"
36
+
37
+ # Or, create a freeform lookup to search using a single line address
38
+ freeform_lookup = SmartyStreets::USEnrichment::Lookup.new
39
+ freeform_lookup.freeform = "56 Union Ave Somerville NJ 08876"
40
+
41
+
42
+
27
43
  begin
28
- result = client.send_property_financial_lookup("765613032")
29
- # result = client.send_property_principal_lookup("765613032")
44
+ # Send a lookup with a smarty key using the line below
45
+ result = client.send_property_principal_lookup("325023201")
46
+
47
+ # Uncomment the following lines to perform other types of lookups:
48
+ # result = client.send_property_principal_lookup(lookup) # Using address components
49
+ # result = client.send_property_principal_lookup(freeform_lookup) # Using freeform address
50
+
51
+ # Access the other Enrichment datasets using the below functions. All of these functions can take a lookup or a smartykey
52
+ # result = client.send_property_financial_lookup("325023201")
53
+ # result = client.send_geo_reference_lookup("325023201")
54
+ # result = client.send_secondary_lookup("325023201")
55
+ # result = client.send_secondary_count_lookup("325023201")
56
+
30
57
  rescue SmartyStreets::SmartyError => err
31
58
  puts err
32
59
  return
@@ -12,7 +12,8 @@ module SmartyStreets
12
12
  :sub_building_name, :postal_code, :dependent_locality, :premise_type, :sub_building_number,
13
13
  :super_administrative_area, :premise_extra, :dependent_thoroughfare_predirection,
14
14
  :building_trailing_type, :thoroughfare_predirection, :building_name, :level_type, :level_number,
15
- :country_iso_3, :sub_building_type
15
+ :country_iso_3, :sub_building_type, :additional_content, :delivery_installation, :delivery_installation_type,
16
+ :delivery_installation_qualifier_name, :route, :route_number, :route_type
16
17
 
17
18
  def initialize(obj)
18
19
  @country_iso_3 = obj.fetch('country_iso_3', nil)
@@ -58,6 +59,13 @@ module SmartyStreets
58
59
  @post_box = obj.fetch('post_box', nil)
59
60
  @post_box_type = obj.fetch('post_box_type', nil)
60
61
  @post_box_number = obj.fetch('post_box_number', nil)
62
+ @additional_content = obj.fetch('additional_content', nil)
63
+ @delivery_installation = obj.fetch('delivery_installation', nil)
64
+ @delivery_installation_type = obj.fetch('delivery_installation_type', nil)
65
+ @delivery_installation_qualifier_name = obj.fetch('delivery_installation_qualifier_name', nil)
66
+ @route = obj.fetch('route', nil)
67
+ @route_number = obj.fetch('route_number', nil)
68
+ @route_type = obj.fetch('route_type', nil)
61
69
  end
62
70
  end
63
71
  end
@@ -19,40 +19,89 @@ module SmartyStreets
19
19
  @serializer = serializer
20
20
  end
21
21
 
22
- def send_property_financial_lookup(smarty_key)
23
- __send(USEnrichment::Property::Financial::Lookup.new(smarty_key))
22
+ def send_property_financial_lookup(lookup)
23
+ if (lookup.instance_of? String)
24
+ __send(USEnrichment::Property::Financial::Lookup.new(lookup))
25
+ elsif (lookup.instance_of? USEnrichment::Lookup)
26
+ lookup.data_set = 'property'
27
+ lookup.data_sub_set = 'financial'
28
+ __send(lookup)
29
+ end
24
30
  end
25
31
 
26
- def send_property_principal_lookup(smarty_key)
27
- __send(USEnrichment::Property::Principal::Lookup.new(smarty_key))
32
+ def send_property_principal_lookup(lookup)
33
+ if (lookup.instance_of? String)
34
+ __send(USEnrichment::Property::Principal::Lookup.new(lookup))
35
+ elsif (lookup.instance_of? USEnrichment::Lookup)
36
+ lookup.data_set = 'property'
37
+ lookup.data_sub_set = 'principal'
38
+ __send(lookup)
39
+ end
28
40
  end
29
41
 
30
- def send_geo_reference_lookup(smarty_key)
31
- __send(USEnrichment::GeoReference::Lookup.new(smarty_key))
42
+ def send_geo_reference_lookup(lookup)
43
+ if (lookup.instance_of? String)
44
+ __send(USEnrichment::GeoReference::Lookup.new(lookup))
45
+ elsif (lookup.instance_of? USEnrichment::Lookup)
46
+ lookup.data_set = 'geo-reference'
47
+ lookup.data_sub_set = nil
48
+ __send(lookup)
49
+ end
32
50
  end
33
51
 
34
- def send_secondary_lookup(smarty_key)
35
- __send(USEnrichment::Secondary::Lookup.new(smarty_key))
52
+ def send_secondary_lookup(lookup)
53
+ if (lookup.instance_of? String)
54
+ __send(USEnrichment::Secondary::Lookup.new(lookup))
55
+ elsif (lookup.instance_of? USEnrichment::Lookup)
56
+ lookup.data_set = 'secondary'
57
+ lookup.data_sub_set = nil
58
+ __send(lookup)
59
+ end
36
60
  end
37
61
 
38
- def send_secondary_count_lookup(smarty_key)
39
- __send(USEnrichment::Secondary::Count::Lookup.new(smarty_key))
62
+ def send_secondary_count_lookup(lookup)
63
+ if (lookup.instance_of? String)
64
+ __send(USEnrichment::Secondary::Count::Lookup.new(lookup))
65
+ elsif (lookup.instance_of? USEnrichment::Lookup)
66
+ lookup.data_set = 'secondary'
67
+ lookup.data_sub_set = 'count'
68
+ __send(lookup)
69
+ end
40
70
  end
41
71
 
42
- def send_generic_lookup(smarty_key, data_set, data_sub_set = nil)
43
- __send(USEnrichment::Lookup.new(smarty_key, data_set, data_sub_set))
72
+ def send_generic_lookup(lookup, data_set, data_sub_set = nil)
73
+ if (lookup.instance_of? String)
74
+ __send(USEnrichment::Lookup.new(lookup, data_set, data_sub_set))
75
+ elsif (lookup.instance_of? USEnrichment::Lookup)
76
+ lookup.data_set = data_set
77
+ lookup.data_sub_set = data_sub_set
78
+ __send(lookup)
79
+ end
44
80
  end
45
81
 
46
82
  def __send(lookup)
47
83
  smarty_request = Request.new
48
84
 
49
85
  return if lookup.nil?
50
-
51
- if (lookup.data_sub_set.nil?)
52
- smarty_request.url_components = '/' + lookup.smarty_key + '/' + lookup.data_set
86
+ if (lookup.smarty_key.nil?)
87
+ if (lookup.data_sub_set.nil?)
88
+ smarty_request.url_components = '/search/' + lookup.data_set
89
+ else
90
+ smarty_request.url_components = '/search/' + lookup.data_set + '/' + lookup.data_sub_set
91
+ end
92
+ add_parameter(smarty_request, 'freeform', lookup.freeform)
93
+ add_parameter(smarty_request, 'street', lookup.street)
94
+ add_parameter(smarty_request, 'city', lookup.city)
95
+ add_parameter(smarty_request, 'state', lookup.state)
96
+ add_parameter(smarty_request, 'zipcode', lookup.zipcode)
53
97
  else
54
- smarty_request.url_components = '/' + lookup.smarty_key + '/' + lookup.data_set + '/' + lookup.data_sub_set
98
+ if (lookup.data_sub_set.nil?)
99
+ smarty_request.url_components = '/' + lookup.smarty_key + '/' + lookup.data_set
100
+ else
101
+ smarty_request.url_components = '/' + lookup.smarty_key + '/' + lookup.data_set + '/' + lookup.data_sub_set
102
+ end
55
103
  end
104
+
56
105
 
57
106
  response = @sender.send(smarty_request)
58
107
  results = @serializer.deserialize(response.payload)
@@ -83,6 +132,10 @@ module SmartyStreets
83
132
  end
84
133
  output
85
134
  end
135
+
136
+ def add_parameter(request, key, value)
137
+ request.parameters[key] = value unless value.nil? or value.empty?
138
+ end
86
139
  end
87
140
  end
88
141
  end
@@ -1,12 +1,18 @@
1
+ require_relative '../json_able'
1
2
  module SmartyStreets
2
3
  module USEnrichment
3
- class Lookup
4
- attr_reader :smarty_key, :data_set, :data_sub_set
4
+ class Lookup < JSONAble
5
+ attr_accessor :smarty_key, :data_set, :data_sub_set, :freeform, :street, :city, :state, :zipcode
5
6
 
6
- def initialize(smarty_key, data_set, data_sub_set)
7
+ def initialize(smarty_key=nil, data_set=nil, data_sub_set=nil, freeform=nil, street=nil, city=nil, state=nil, zipcode=nil)
7
8
  @smarty_key = smarty_key
8
9
  @data_set = data_set
9
10
  @data_sub_set = data_sub_set
11
+ @freeform = freeform
12
+ @street = street
13
+ @city = city
14
+ @state = state
15
+ @zipcode = zipcode
10
16
  end
11
17
  end
12
18
  end
@@ -1,3 +1,3 @@
1
1
  module SmartyStreets
2
- VERSION = '5.19.0' # DO NOT EDIT (this is updated by a build job when a new release is published)
2
+ VERSION = '5.20.3' # 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.19.0
4
+ version: 5.20.3
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: 2024-08-12 00:00:00.000000000 Z
11
+ date: 2024-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler