Skip to content

Commit 46342ab

Browse files
committed
Add IANA timezone example and clean up enrichment example output
1 parent 68250b2 commit 46342ab

4 files changed

Lines changed: 121 additions & 7 deletions

File tree

CLAUDE.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@ client = SmartyStreets::ClientBuilder.new(credentials)
3838
.build_us_street_api_client
3939
```
4040

41-
**Chain of Responsibility**: HTTP requests flow through a middleware chain of "Sender" objects. Each sender wraps an inner sender:
41+
**Chain of Responsibility**: HTTP requests flow through a middleware chain of "Sender" objects. Each sender wraps an inner sender (outermost to innermost):
4242
```
43-
URLPrefixSender → LicenseSender → RetrySender → SigningSender → StatusCodeSender → NativeSender
43+
URLPrefixSender → CustomQuerySender → LicenseSender → RetrySender → SigningSender → CustomHeaderSender → StatusCodeSender → NativeSender
4444
```
45+
`CustomHeaderSender` is only included when custom headers are configured; `RetrySender` only when max_retries > 0.
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`.
4548

4649
### Key Components
4750

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ us_reverse_geo_api:
4646
cd examples && ruby us_reverse_geo_example.rb
4747

4848
us_street_api:
49-
cd examples && ruby us_street_single_address_example.rb && ruby us_street_multiple_address_example.rb && ruby us_street_component_analysis_example.rb && ruby us_street_component_analysis_example.rb
49+
cd examples && ruby us_street_single_address_example.rb && ruby us_street_multiple_address_example.rb && ruby us_street_component_analysis_example.rb && ruby us_street_iana_timezone_example.rb
5050

5151
us_zipcode_api:
5252
cd examples && ruby us_zipcode_single_lookup_example.rb && ruby us_zipcode_multiple_lookup_example.rb

examples/us_enrichment_example.rb

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ def run
4444
freeform_lookup = SmartyStreets::USEnrichment::Lookup.new
4545
freeform_lookup.freeform = "56 Union Ave Somerville NJ 08876"
4646

47-
48-
4947
begin
5048
# Send a lookup with a smarty key using the line below
5149
# result = client.send_property_principal_lookup("325023201")
@@ -70,8 +68,67 @@ def run
7068
return
7169
end
7270

73-
puts "Lookup Successful! Here is the result: "
74-
puts result[0].inspect
71+
puts "Lookup Successful! Here is the result:"
72+
puts
73+
74+
response = result[0]
75+
attrs = response.attributes
76+
77+
puts "Smarty Key: #{response.smarty_key}"
78+
puts "Data Set: #{response.data_set_name}/#{response.data_subset_name}"
79+
puts "ETag: #{response.etag}"
80+
puts
81+
82+
puts "Property Address:"
83+
puts "\tFull Address: #{attrs.property_address_full}"
84+
puts "\tCity: #{attrs.property_address_city}"
85+
puts "\tState: #{attrs.property_address_state}"
86+
puts "\tZIP: #{attrs.property_address_zipcode}"
87+
puts
88+
89+
puts "Owner:"
90+
puts "\tName: #{attrs.owner_full_name}"
91+
puts "\tOccupancy: #{attrs.owner_occupancy_status}"
92+
puts
93+
94+
puts "Property Details:"
95+
puts "\tLand Use: #{attrs.land_use_standard}"
96+
puts "\tYear Built: #{attrs.year_built}"
97+
puts "\tBuilding Sqft: #{attrs.building_sqft}"
98+
puts "\tLot Sqft: #{attrs.lot_sqft}"
99+
puts "\tAcres: #{attrs.acres}"
100+
puts "\tBathrooms: #{attrs.bathrooms_total}"
101+
puts "\tBedrooms: #{attrs.bedrooms}"
102+
puts "\tStories: #{attrs.stories_number}"
103+
puts "\tFireplace: #{attrs.fireplace}"
104+
puts "\tGarage: #{attrs.garage}"
105+
puts
106+
107+
puts "Assessment:"
108+
puts "\tAssessed Value: #{attrs.assessed_value}"
109+
puts "\tTotal Market Value: #{attrs.total_market_value}"
110+
puts "\tTax Year: #{attrs.tax_assess_year}"
111+
puts "\tTax Billed: #{attrs.tax_billed_amount}"
112+
puts
113+
114+
puts "Location:"
115+
puts "\tCounty: #{attrs.situs_county}"
116+
puts "\tLatitude: #{attrs.latitude}"
117+
puts "\tLongitude: #{attrs.longitude}"
118+
puts "\tElevation (ft): #{attrs.elevation_feet}"
119+
puts
120+
121+
unless attrs.financial_history.nil? || attrs.financial_history.empty?
122+
puts "Financial History (#{attrs.financial_history.length} entries):"
123+
attrs.financial_history.each_with_index do |entry, i|
124+
puts "\tEntry #{i + 1}:"
125+
puts "\t\tDocument Type: #{entry.document_type_description}"
126+
puts "\t\tLender: #{entry.lender_name}"
127+
puts "\t\tMortgage Amount: #{entry.mortgage_amount}"
128+
puts "\t\tMortgage Type: #{entry.mortgage_type}"
129+
puts "\t\tRecording Date: #{entry.mortgage_recording_date}"
130+
end
131+
end
75132
end
76133
end
77134

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
require '../lib/smartystreets_ruby_sdk/static_credentials'
2+
require '../lib/smartystreets_ruby_sdk/shared_credentials'
3+
require '../lib/smartystreets_ruby_sdk/basic_auth_credentials'
4+
require '../lib/smartystreets_ruby_sdk/client_builder'
5+
require '../lib/smartystreets_ruby_sdk/us_street/lookup'
6+
require '../lib/smartystreets_ruby_sdk/us_street/match_type'
7+
8+
class USStreetIANATimezoneExample
9+
def run
10+
# For client-side requests (browser/mobile), use this code:
11+
# key = ENV['SMARTY_AUTH_WEB']
12+
# referer = ENV['SMARTY_AUTH_REFERER']
13+
# credentials = SmartyStreets::SharedCredentials.new(key, referer)
14+
15+
# For server-to-server requests, use this code:
16+
id = ENV['SMARTY_AUTH_ID']
17+
token = ENV['SMARTY_AUTH_TOKEN']
18+
credentials = SmartyStreets::BasicAuthCredentials.new(id, token)
19+
20+
client = SmartyStreets::ClientBuilder.new(credentials)
21+
.with_feature_iana_time_zone()
22+
.build_us_street_api_client
23+
24+
lookup = SmartyStreets::USStreet::Lookup.new
25+
lookup.street = "1 Rosedale"
26+
lookup.secondary = "APT 2"
27+
lookup.city = "Baltimore"
28+
lookup.state = "MD"
29+
lookup.zipcode = "21229"
30+
lookup.match = SmartyStreets::USStreet::MatchType::ENHANCED
31+
32+
begin
33+
client.send_lookup(lookup)
34+
rescue SmartyStreets::SmartyError => err
35+
puts err
36+
return
37+
end
38+
39+
result = lookup.result
40+
41+
if result.empty?
42+
return
43+
end
44+
45+
first_candidate = result[0]
46+
47+
puts "IANA Time Zone: #{first_candidate.metadata.iana_time_zone}"
48+
puts "IANA UTC Offset: #{first_candidate.metadata.iana_utc_offset}"
49+
puts "IANA Obeys DST: #{first_candidate.metadata.iana_obeys_dst}"
50+
end
51+
end
52+
53+
example = USStreetIANATimezoneExample.new
54+
example.run

0 commit comments

Comments
 (0)