-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from smartystreets/landon/us_enrichment
Landon/us enrichment Add US Enrichment API to the SDK
- Loading branch information
Showing
14 changed files
with
1,878 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require '../lib/smartystreets_ruby_sdk/static_credentials' | ||
require '../lib/smartystreets_ruby_sdk/shared_credentials' | ||
require '../lib/smartystreets_ruby_sdk/client_builder' | ||
|
||
class USEnrichmentAddressExample | ||
def run | ||
# key = 'Your SmartyStreets Auth Key here' | ||
# referer = 'Your host name here' | ||
# We recommend storing your secret keys in environment variables instead---it's safer! | ||
# key = ENV['SMARTY_AUTH_WEB'] | ||
# referer = ENV['SMARTY_AUTH_REFERER'] | ||
# credentials = SmartyStreets::SharedCredentials.new(key, referer) | ||
|
||
id = ENV['SMARTY_AUTH_ID'] | ||
token = ENV['SMARTY_AUTH_TOKEN'] | ||
credentials = SmartyStreets::StaticCredentials.new(id, token) | ||
|
||
# The appropriate license values to be used for your subscriptions | ||
# can be found on the Subscriptions page of the account dashboard. | ||
# https://www.smartystreets.com/docs/cloud/licensing | ||
# | ||
# To try with a proxy, add this method call at the end of the chain | ||
# with_proxy('localhost', 8080, 'proxyUser', 'proxyPassword') | ||
client = SmartyStreets::ClientBuilder.new(credentials). | ||
build_us_enrichment_api_client | ||
result = nil | ||
begin | ||
result = client.send_property_financial_lookup("765613032") | ||
# result = client.send_property_principal_lookup("765613032") | ||
rescue SmartyStreets::SmartyError => err | ||
puts err | ||
return | ||
end | ||
|
||
if result.empty? | ||
puts 'No results. This means the smartykey is not valid.' | ||
return | ||
end | ||
|
||
puts "Lookup Successful! Here is the result: " | ||
puts result[0].inspect | ||
end | ||
end | ||
|
||
example = USEnrichmentAddressExample.new | ||
example.run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require_relative './us_enrichment/property/financial/attributes' | ||
require_relative './us_enrichment/property/financial/history_entry' | ||
require_relative './us_enrichment/property/financial/response' | ||
require_relative './us_enrichment/property/financial/lookup' | ||
|
||
require_relative './us_enrichment/property/principal/attributes' | ||
require_relative './us_enrichment/property/principal/response' | ||
require_relative './us_enrichment/property/principal/lookup' | ||
|
||
require_relative './us_enrichment/client' | ||
|
||
module SmartyStreets | ||
module USEnrichment | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
require_relative "property/financial/response" | ||
require_relative "property/principal/response" | ||
require_relative "property/financial/lookup" | ||
require_relative "property/principal/lookup" | ||
require_relative '../request' | ||
|
||
module SmartyStreets | ||
module USEnrichment | ||
class Client | ||
def initialize(sender, serializer) | ||
@sender = sender | ||
@serializer = serializer | ||
end | ||
|
||
def send_property_financial_lookup(smarty_key) | ||
__send(USEnrichment::Property::Financial::Lookup.new(smarty_key)) | ||
end | ||
|
||
def send_property_principal_lookup(smarty_key) | ||
__send(USEnrichment::Property::Principal::Lookup.new(smarty_key)) | ||
end | ||
|
||
def __send(lookup) | ||
smarty_request = Request.new | ||
|
||
return if lookup.nil? | ||
|
||
smarty_request.url_prefix = '/' + lookup.smarty_key + '/' + lookup.data_set + '/' + lookup.data_sub_set | ||
|
||
response = @sender.send(smarty_request) | ||
results = @serializer.deserialize(response.payload) | ||
|
||
results = [] if results.nil? | ||
raise response.error if response.error | ||
|
||
output = [] | ||
results.each do |raw_result| | ||
result = nil | ||
if lookup.data_sub_set == "financial" | ||
result = USEnrichment::Property::Financial::Response.new(raw_result) | ||
end | ||
if lookup.data_sub_set == "principal" | ||
result = USEnrichment::Property::Principal::Response.new(raw_result) | ||
end | ||
output << result | ||
end | ||
output | ||
end | ||
end | ||
end | ||
end |
137 changes: 137 additions & 0 deletions
137
lib/smartystreets_ruby_sdk/us_enrichment/property/financial/attributes.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
require_relative 'history_entry' | ||
|
||
module SmartyStreets | ||
module USEnrichment | ||
module Property | ||
module Financial | ||
class Attributes | ||
attr_reader :assessed_improvement_percent, :assessed_improvement_value, :assessed_land_value, :assessed_value, | ||
:assessor_last_update, :assessor_taxroll_update, :contact_city, :contact_crrt, :contact_full_address, :contact_house_number, | ||
:contact_mail_info_format, :contact_mail_info_privacy, :contact_mailing_county, :contact_mailing_fips, :contact_post_direction, | ||
:contact_pre_direction, :contact_state, :contact_street_name, :contact_suffix, :contact_unit_designator, :contact_value, | ||
:contact_zip, :contact_zip4, :deed_document_page, :deed_document_book, :deed_document_number, :deed_owner_first_name, | ||
:deed_owner_first_name2, :deed_owner_first_name3, :deed_owner_first_name4, :deed_owner_full_name, :deed_owner_full_name2, | ||
:deed_owner_full_name3, :deed_owner_full_name4, :deed_owner_last_name, :deed_owner_last_name2, :deed_owner_last_name3, | ||
:deed_owner_last_name4, :deed_owner_middle_name, :deed_owner_middle_name2, :deed_owner_middle_name3, :deed_owner_middle_name4, | ||
:deed_owner_suffix, :deed_owner_suffix2, :deed_owner_suffix3, :deed_owner_suffix4, :deed_sale_date, :deed_sale_price, | ||
:deed_transaction_id, :disabled_tax_exemption, :financial_history, :first_name, :first_name_2, :first_name_3, :first_name_4, | ||
:homeowner_tax_exemption, :last_name, :last_name_2, :last_name_3, :last_name_4, :market_improvement_percent, :market_improvement_value, | ||
:market_land_value, :market_value_year, :match_type, :middle_name, :middle_name_2, :middle_name_3, :middle_name_4, :other_tax_exemption, | ||
:owner_full_name, :owner_full_name_2, :owner_full_name_3, :owner_full_name_4, :ownership_transfer_date, :ownership_transfer_doc_number, | ||
:ownership_transfer_transaction_id, :ownership_type, :ownership_type_2, :previous_assessed_value, :prior_sale_amount, :prior_sale_date, | ||
:sale_amount, :sale_date, :senior_tax_exemption, :suffix, :suffix_2, :suffix_3, :suffix_4, :tax_assess_year, :tax_billed_amount, | ||
:tax_delinquent_year, :tax_fiscal_year, :tax_rate_area, :total_market_value, :trust_description, :veteran_tax_exemption, :widow_tax_exemption | ||
|
||
def initialize(obj) | ||
@assessed_improvement_percent = obj['assessed_improvement_percent'] | ||
@assessed_improvement_value = obj['assessed_improvement_value'] | ||
@assessed_land_value = obj['assessed_land_value'] | ||
@assessed_value = obj['assessed_value'] | ||
@assessor_last_update = obj['assessor_last_update'] | ||
@assessor_taxroll_update = obj['assessor_taxroll_update'] | ||
@contact_city = obj['contact_city'] | ||
@contact_crrt = obj['contact_crrt'] | ||
@contact_full_address = obj['contact_full_address'] | ||
@contact_house_number = obj['contact_house_number'] | ||
@contact_mail_info_format = obj['contact_mail_info_format'] | ||
@contact_mail_info_privacy = obj['contact_mail_info_privacy'] | ||
@contact_mailing_county = obj['contact_mailing_county'] | ||
@contact_mailing_fips = obj['contact_mailing_fips'] | ||
@contact_post_direction = obj['contact_post_direction'] | ||
@contact_pre_direction = obj['contact_pre_direction'] | ||
@contact_state = obj['contact_state'] | ||
@contact_street_name = obj['contact_street_name'] | ||
@contact_suffix = obj['contact_suffix'] | ||
@contact_unit_designator = obj['contact_unit_designator'] | ||
@contact_value = obj['contact_value'] | ||
@contact_zip = obj['contact_zip'] | ||
@contact_zip4 = obj['contact_zip4'] | ||
@deed_document_page = obj['deed_document_page'] | ||
@deed_document_book = obj['deed_document_book'] | ||
@deed_document_number = obj['deed_document_number'] | ||
@deed_owner_first_name = obj['deed_owner_first_name'] | ||
@deed_owner_first_name2 = obj['deed_owner_first_name2'] | ||
@deed_owner_first_name3 = obj['deed_owner_first_name3'] | ||
@deed_owner_first_name4 = obj['deed_owner_first_name4'] | ||
@deed_owner_full_name = obj['deed_owner_full_name'] | ||
@deed_owner_full_name2 = obj['deed_owner_full_name2'] | ||
@deed_owner_full_name3 = obj['deed_owner_full_name3'] | ||
@deed_owner_full_name4 = obj['deed_owner_full_name4'] | ||
@deed_owner_last_name = obj['deed_owner_last_name'] | ||
@deed_owner_last_name2 = obj['deed_owner_last_name2'] | ||
@deed_owner_last_name3 = obj['deed_owner_last_name3'] | ||
@deed_owner_last_name4 = obj['deed_owner_last_name4'] | ||
@deed_owner_middle_name = obj['deed_owner_middle_name'] | ||
@deed_owner_middle_name2 = obj['deed_owner_middle_name2'] | ||
@deed_owner_middle_name3 = obj['deed_owner_middle_name3'] | ||
@deed_owner_middle_name4 = obj['deed_owner_middle_name4'] | ||
@deed_owner_suffix = obj['deed_owner_suffix'] | ||
@deed_owner_suffix2 = obj['deed_owner_suffix2'] | ||
@deed_owner_suffix3 = obj['deed_owner_suffix3'] | ||
@deed_owner_suffix4 = obj['deed_owner_suffix4'] | ||
@deed_sale_date = obj['deed_sale_date'] | ||
@deed_sale_price = obj['deed_sale_price'] | ||
@deed_transaction_id = obj['deed_transaction_id'] | ||
@disabled_tax_exemption = obj['disabled_tax_exemption'] | ||
@financial_history = createFinancialHistory(obj['financial_history']) | ||
@first_name = obj['first_name'] | ||
@first_name_2 = obj['first_name_2'] | ||
@first_name_3 = obj['first_name_3'] | ||
@first_name_4 = obj['first_name_4'] | ||
@homeowner_tax_exemption = obj['homeowner_tax_exemption'] | ||
@last_name = obj['last_name'] | ||
@last_name_2 = obj['last_name_2'] | ||
@last_name_3 = obj['last_name_3'] | ||
@last_name_4 = obj['last_name_4'] | ||
@market_improvement_percent = obj['market_improvement_percent'] | ||
@market_improvement_value = obj['market_improvement_value'] | ||
@market_land_value = obj['market_land_value'] | ||
@market_value_year = obj['market_value_year'] | ||
@match_type = obj['match_type'] | ||
@middle_name = obj['middle_name'] | ||
@middle_name_2 = obj['middle_name_2'] | ||
@middle_name_3 = obj['middle_name_3'] | ||
@middle_name_4 = obj['middle_name_4'] | ||
@other_tax_exemption = obj['other_tax_exemption'] | ||
@owner_full_name = obj['owner_full_name'] | ||
@owner_full_name_2 = obj['owner_full_name_2'] | ||
@owner_full_name_3 = obj['owner_full_name_3'] | ||
@owner_full_name_4 = obj['owner_full_name_4'] | ||
@ownership_transfer_date = obj['ownership_transfer_date'] | ||
@ownership_transfer_doc_number = obj['ownership_transfer_doc_number'] | ||
@ownership_transfer_transaction_id = obj['ownership_transfer_transaction_id'] | ||
@ownership_type = obj['ownership_type'] | ||
@ownership_type_2 = obj['ownership_type_2'] | ||
@previous_assessed_value = obj['previous_assessed_value'] | ||
@prior_sale_amount = obj['prior_sale_amount'] | ||
@prior_sale_date = obj['prior_sale_date'] | ||
@sale_amount = obj['sale_amount'] | ||
@sale_date = obj['sale_date'] | ||
@senior_tax_exemption = obj['senior_tax_exemption'] | ||
@suffix = obj['suffix'] | ||
@suffix_2 = obj['suffix_2'] | ||
@suffix_3 = obj['suffix_3'] | ||
@suffix_4 = obj['suffix_4'] | ||
@tax_assess_year = obj['tax_assess_year'] | ||
@tax_billed_amount = obj['tax_billed_amount'] | ||
@tax_delinquent_year = obj['tax_delinquent_year'] | ||
@tax_fiscal_year = obj['tax_fiscal_year'] | ||
@tax_rate_area = obj['tax_rate_area'] | ||
@total_market_value = obj['total_market_value'] | ||
@trust_description = obj['trust_description'] | ||
@veteran_tax_exemption = obj['veteran_tax_exemption'] | ||
@widow_tax_exemption = obj['widow_tax_exemption'] | ||
end | ||
|
||
def createFinancialHistory(historyArray) | ||
entryArray = [] | ||
for entry in historyArray do | ||
entryArray << Financial::HistoryEntry.new(entry) | ||
end | ||
return entryArray | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
63 changes: 63 additions & 0 deletions
63
lib/smartystreets_ruby_sdk/us_enrichment/property/financial/history_entry.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
module SmartyStreets | ||
module USEnrichment | ||
module Property | ||
module Financial | ||
class HistoryEntry | ||
attr_reader :code_title_company, :instrument_date, :interest_rate_type_2, :lender_address, :lender_address_2, | ||
:lender_city, :lender_city_2, :lender_code_2, :lender_first_name, :lender_first_name_2, :lender_last_name, | ||
:lender_last_name_2, :lender_name, :lender_name_2, :lender_seller_carry_back, :lender_seller_carry_back_2, | ||
:lender_state, :lender_state_2, :lender_zip, :lender_zip_2, :lender_zip_extended, :lender_zip_extended_2, | ||
:mortgage_amount, :mortgage_amount_2, :mortgage_due_date, :mortgage_due_date_2, :mortgage_interest_rate, | ||
:mortgage_interest_rate_type, :mortgage_lender_code, :mortgage_rate_2, :mortgage_recording_date, | ||
:mortgage_recording_date_2, :mortgage_term, :mortgage_term_2, :mortgage_term_type, :mortgage_term_type_2, | ||
:mortgage_type, :mortgage_type_2, :multi_parcel_flag, :name_title_company, :recording_date, :transfer_amount | ||
|
||
def initialize(obj) | ||
@code_title_company = obj['code_title_company'] | ||
@instrument_date = obj['instrument_date'] | ||
@interest_rate_type_2 = obj['interest_rate_type_2'] | ||
@lender_address = obj['lender_address'] | ||
@lender_address_2 = obj['lender_address_2'] | ||
@lender_city = obj['lender_city'] | ||
@lender_city_2 = obj['lender_city_2'] | ||
@lender_code_2 = obj['lender_code_2'] | ||
@lender_first_name = obj['lender_first_name'] | ||
@lender_first_name_2 = obj['lender_first_name_2'] | ||
@lender_last_name = obj['lender_last_name'] | ||
@lender_last_name_2 = obj['lender_last_name_2'] | ||
@lender_name = obj['lender_name'] | ||
@lender_name_2 = obj['lender_name_2'] | ||
@lender_seller_carry_back = obj['lender_seller_carry_back'] | ||
@lender_seller_carry_back_2 = obj['lender_seller_carry_back_2'] | ||
@lender_state = obj['lender_state'] | ||
@lender_state_2 = obj['lender_state_2'] | ||
@lender_zip = obj['lender_zip'] | ||
@lender_zip_2 = obj['lender_zip_2'] | ||
@lender_zip_extended = obj['lender_zip_extended'] | ||
@lender_zip_extended_2 = obj['lender_zip_extended_2'] | ||
@mortgage_amount = obj['mortgage_amount'] | ||
@mortgage_amount_2 = obj['mortgage_amount_2'] | ||
@mortgage_due_date = obj['mortgage_due_date'] | ||
@mortgage_due_date_2 = obj['mortgage_due_date_2'] | ||
@mortgage_interest_rate = obj['mortgage_interest_rate'] | ||
@mortgage_interest_rate_type = obj['mortgage_interest_rate_type'] | ||
@mortgage_lender_code = obj['mortgage_lender_code'] | ||
@mortgage_rate_2 = obj['mortgage_rate_2'] | ||
@mortgage_recording_date = obj['mortgage_recording_date'] | ||
@mortgage_recording_date_2 = obj['mortgage_recording_date_2'] | ||
@mortgage_term = obj['mortgage_term'] | ||
@mortgage_term_2 = obj['mortgage_term_2'] | ||
@mortgage_term_type = obj['mortgage_term_type'] | ||
@mortgage_term_type_2 = obj['mortgage_term_type_2'] | ||
@mortgage_type = obj['mortgage_type'] | ||
@mortgage_type_2 = obj['mortgage_type_2'] | ||
@multi_parcel_flag = obj['multi_parcel_flag'] | ||
@name_title_company = obj['name_title_company'] | ||
@recording_date = obj['recording_date'] | ||
@transfer_amount = obj['transfer_amount'] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
17 changes: 17 additions & 0 deletions
17
lib/smartystreets_ruby_sdk/us_enrichment/property/financial/lookup.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module SmartyStreets | ||
module USEnrichment | ||
module Property | ||
module Financial | ||
class Lookup | ||
attr_reader :smarty_key, :data_set, :data_sub_set | ||
|
||
def initialize(smarty_key) | ||
@smarty_key = smarty_key | ||
@data_set = "property" | ||
@data_sub_set = "financial" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.