smartystreets_ruby_sdk 5.19.0 → 5.20.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: feea3fd221e9e87912c8d35bd636b8c295ae0415ef20cc45880b330d1199ce3f
|
4
|
+
data.tar.gz: e0d8168d70e4edf32906f49ec0cb39b1f7890804a7067e80cf7538e1db1ba24c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17120bcc323bd9dd58ce32520fdfe8993afaf352dd595bbc2316a33cddd5e8ab44b4c2728b807488ab601be72e68a4627b5ea3a5b4a5825bb9843e0ffeb2e0eb
|
7
|
+
data.tar.gz: a9535cac7038a34e74101d551781368d883c9aafd12ef9b5dbe52d37c158cf8d3253cb179a1ce2a872cb928660a40c599e92a163ee3e7f1d4a0fbfcc165d64d7
|
@@ -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
|
-
|
29
|
-
|
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
|
@@ -19,40 +19,89 @@ module SmartyStreets
|
|
19
19
|
@serializer = serializer
|
20
20
|
end
|
21
21
|
|
22
|
-
def send_property_financial_lookup(
|
23
|
-
|
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(
|
27
|
-
|
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(
|
31
|
-
|
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(
|
35
|
-
|
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(
|
39
|
-
|
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(
|
43
|
-
|
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
|
-
|
52
|
-
|
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
|
-
|
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
|
-
|
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
|
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.
|
4
|
+
version: 5.20.2
|
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-
|
11
|
+
date: 2024-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|