-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete enrichment SDK and fix other tests
- Loading branch information
1 parent
6c9c3b3
commit 37d7b67
Showing
23 changed files
with
1,705 additions
and
3 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
29 changes: 29 additions & 0 deletions
29
Sources/SmartyStreets/USEnrichment/LookupTypes/EnrichmentLookup.swift
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,29 @@ | ||
import Foundation | ||
|
||
public class EnrichmentLookup: Encodable { | ||
private let smarty_key: String | ||
private let data_set_name: String | ||
private let data_subset_name: String | ||
|
||
public init(smartyKey: String, datasetName: String, dataSubsetName: String) { | ||
self.smarty_key = smartyKey | ||
self.data_set_name = datasetName | ||
self.data_subset_name = dataSubsetName | ||
} | ||
|
||
public func getSmartyKey() -> String { | ||
return smarty_key | ||
} | ||
|
||
public func getDatasetName() -> String { | ||
return data_set_name | ||
} | ||
|
||
public func getDataSubsetName() -> String { | ||
return data_subset_name | ||
} | ||
|
||
public func deserializeAndSetResults(serializer: SmartySerializer, payload: Data, error: UnsafeMutablePointer<NSError?>) { | ||
fatalError("You must use a Lookup subclass with an implemented version of deserializeAndSetResults") | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
Sources/SmartyStreets/USEnrichment/LookupTypes/PropertyFinancialEnrichmentLookup.swift
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 @@ | ||
import Foundation | ||
|
||
public class PropertyFinancialEnrichmentLookup: EnrichmentLookup { | ||
|
||
public var results:[FinancialResult]? | ||
|
||
init(smartyKey: String){ | ||
self.results = nil | ||
super.init(smartyKey: smartyKey, datasetName: "property", dataSubsetName: "financial") | ||
} | ||
|
||
override public func deserializeAndSetResults(serializer: SmartySerializer, payload: Data, error: UnsafeMutablePointer<NSError?>) { | ||
self.results = serializer.Deserialize(payload: payload, error: &error.pointee) as? [FinancialResult] | ||
} | ||
|
||
|
||
} |
15 changes: 15 additions & 0 deletions
15
Sources/SmartyStreets/USEnrichment/LookupTypes/PropertyPrincipalEnrichmentLookup.swift
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 @@ | ||
import Foundation | ||
|
||
public class PropertyPrincipalEnrichmentLookup: EnrichmentLookup { | ||
|
||
public var results:[PrincipalResult]? | ||
|
||
init(smartyKey: String){ | ||
self.results = nil | ||
super.init(smartyKey: smartyKey, datasetName: "property", dataSubsetName: "principal") | ||
} | ||
|
||
override public func deserializeAndSetResults(serializer: SmartySerializer, payload: Data, error: UnsafeMutablePointer<NSError?>) { | ||
self.results = serializer.Deserialize(payload: payload, error: &error.pointee) as? [PrincipalResult] | ||
} | ||
} |
131 changes: 131 additions & 0 deletions
131
Sources/SmartyStreets/USEnrichment/ResultTypes/PropertyFinancial/FinancialAttributes.swift
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,131 @@ | ||
import Foundation | ||
|
||
public struct FinancialAttributes: Codable { | ||
let assessedImprovementPercent, assessedImprovementValue, assessedLandValue, assessedValue: String? | ||
let assessorLastUpdate, assessorTaxrollUpdate, contactCity, contactCrrt: String? | ||
let contactFullAddress, contactHouseNumber, contactMailInfoFormat, contactMailInfoPrivacy: String? | ||
let contactMailingCounty, contactMailingFIPS, contactPostDirection, contactPreDirection: String? | ||
let contactState, contactStreetName, contactSuffix, contactUnitDesignator: String? | ||
let contactValue, contactZip, contactZip4, deedDocumentBook: String? | ||
let deedDocumentNumber, deedDocumentPage, deedOwnerFirstName, deedOwnerFirstName2: String? | ||
let deedOwnerFirstName3, deedOwnerFirstName4, deedOwnerFullName, deedOwnerFullName2: String? | ||
let deedOwnerFullName3, deedOwnerFullName4, deedOwnerLastName, deedOwnerLastName2: String? | ||
let deedOwnerLastName3, deedOwnerLastName4, deedOwnerMiddleName, deedOwnerMiddleName2: String? | ||
let deedOwnerMiddleName3, deedOwnerMiddleName4, deedOwnerSuffix, deedOwnerSuffix2: String? | ||
let deedOwnerSuffix3, deedOwnerSuffix4, deedSaleDate, deedSalePrice: String? | ||
let deedTransactionID, disabledTaxExemption: String? | ||
let financialHistory: [FinancialHistoryEntry] | ||
let firstName, firstName2, firstName3, firstName4: String? | ||
let homeownerTaxExemption, lastName, lastName2, lastName3: String? | ||
let lastName4, marketImprovementPercent, marketImprovementValue, marketLandValue: String? | ||
let marketValueYear, matchType, middleName, middleName2: String? | ||
let middleName3, middleName4, otherTaxExemption, ownerFullName: String? | ||
let ownerFullName2, ownerFullName3, ownerFullName4, ownershipTransferDate: String? | ||
let ownershipTransferDocNumber, ownershipTransferTransactionID, ownershipType, ownershipType2: String? | ||
let previousAssessedValue, priorSaleAmount, priorSaleDate, saleAmount: String? | ||
let saleDate, seniorTaxExemption, suffix, suffix2: String? | ||
let suffix3, suffix4, taxAssessYear, taxBilledAmount: String? | ||
let taxDelinquentYear, taxFiscalYear, taxRateArea, totalMarketValue: String? | ||
let trustDescription, veteranTaxExemption, widowTaxExemption: String? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case assessedImprovementPercent = "assessed_improvement_percent" | ||
case assessedImprovementValue = "assessed_improvement_value" | ||
case assessedLandValue = "assessed_land_value" | ||
case assessedValue = "assessed_value" | ||
case assessorLastUpdate = "assessor_last_update" | ||
case assessorTaxrollUpdate = "assessor_taxroll_update" | ||
case contactCity = "contact_city" | ||
case contactCrrt = "contact_crrt" | ||
case contactFullAddress = "contact_full_address" | ||
case contactHouseNumber = "contact_house_number" | ||
case contactMailInfoFormat = "contact_mail_info_format" | ||
case contactMailInfoPrivacy = "contact_mail_info_privacy" | ||
case contactMailingCounty = "contact_mailing_county" | ||
case contactMailingFIPS = "contact_mailing_fips" | ||
case contactPostDirection = "contact_post_direction" | ||
case contactPreDirection = "contact_pre_direction" | ||
case contactState = "contact_state" | ||
case contactStreetName = "contact_street_name" | ||
case contactSuffix = "contact_suffix" | ||
case contactUnitDesignator = "contact_unit_designator" | ||
case contactValue = "contact_value" | ||
case contactZip = "contact_zip" | ||
case contactZip4 = "contact_zip4" | ||
case deedDocumentBook = "deed_document_book" | ||
case deedDocumentNumber = "deed_document_number" | ||
case deedDocumentPage = "deed_document_page" | ||
case deedOwnerFirstName = "deed_owner_first_name" | ||
case deedOwnerFirstName2 = "deed_owner_first_name2" | ||
case deedOwnerFirstName3 = "deed_owner_first_name3" | ||
case deedOwnerFirstName4 = "deed_owner_first_name4" | ||
case deedOwnerFullName = "deed_owner_full_name" | ||
case deedOwnerFullName2 = "deed_owner_full_name2" | ||
case deedOwnerFullName3 = "deed_owner_full_name3" | ||
case deedOwnerFullName4 = "deed_owner_full_name4" | ||
case deedOwnerLastName = "deed_owner_last_name" | ||
case deedOwnerLastName2 = "deed_owner_last_name2" | ||
case deedOwnerLastName3 = "deed_owner_last_name3" | ||
case deedOwnerLastName4 = "deed_owner_last_name4" | ||
case deedOwnerMiddleName = "deed_owner_middle_name" | ||
case deedOwnerMiddleName2 = "deed_owner_middle_name2" | ||
case deedOwnerMiddleName3 = "deed_owner_middle_name3" | ||
case deedOwnerMiddleName4 = "deed_owner_middle_name4" | ||
case deedOwnerSuffix = "deed_owner_suffix" | ||
case deedOwnerSuffix2 = "deed_owner_suffix2" | ||
case deedOwnerSuffix3 = "deed_owner_suffix3" | ||
case deedOwnerSuffix4 = "deed_owner_suffix4" | ||
case deedSaleDate = "deed_sale_date" | ||
case deedSalePrice = "deed_sale_price" | ||
case deedTransactionID = "deed_transaction_id" | ||
case disabledTaxExemption = "disabled_tax_exemption" | ||
case financialHistory = "financial_history" | ||
case firstName = "first_name" | ||
case firstName2 = "first_name_2" | ||
case firstName3 = "first_name_3" | ||
case firstName4 = "first_name_4" | ||
case homeownerTaxExemption = "homeowner_tax_exemption" | ||
case lastName = "last_name" | ||
case lastName2 = "last_name_2" | ||
case lastName3 = "last_name_3" | ||
case lastName4 = "last_name_4" | ||
case marketImprovementPercent = "market_improvement_percent" | ||
case marketImprovementValue = "market_improvement_value" | ||
case marketLandValue = "market_land_value" | ||
case marketValueYear = "market_value_year" | ||
case matchType = "match_type" | ||
case middleName = "middle_name" | ||
case middleName2 = "middle_name_2" | ||
case middleName3 = "middle_name_3" | ||
case middleName4 = "middle_name_4" | ||
case otherTaxExemption = "other_tax_exemption" | ||
case ownerFullName = "owner_full_name" | ||
case ownerFullName2 = "owner_full_name_2" | ||
case ownerFullName3 = "owner_full_name_3" | ||
case ownerFullName4 = "owner_full_name_4" | ||
case ownershipTransferDate = "ownership_transfer_date" | ||
case ownershipTransferDocNumber = "ownership_transfer_doc_number" | ||
case ownershipTransferTransactionID = "ownership_transfer_transaction_id" | ||
case ownershipType = "ownership_type" | ||
case ownershipType2 = "ownership_type_2" | ||
case previousAssessedValue = "previous_assessed_value" | ||
case priorSaleAmount = "prior_sale_amount" | ||
case priorSaleDate = "prior_sale_date" | ||
case saleAmount = "sale_amount" | ||
case saleDate = "sale_date" | ||
case seniorTaxExemption = "senior_tax_exemption" | ||
case suffix | ||
case suffix2 = "suffix_2" | ||
case suffix3 = "suffix_3" | ||
case suffix4 = "suffix_4" | ||
case taxAssessYear = "tax_assess_year" | ||
case taxBilledAmount = "tax_billed_amount" | ||
case taxDelinquentYear = "tax_delinquent_year" | ||
case taxFiscalYear = "tax_fiscal_year" | ||
case taxRateArea = "tax_rate_area" | ||
case totalMarketValue = "total_market_value" | ||
case trustDescription = "trust_description" | ||
case veteranTaxExemption = "veteran_tax_exemption" | ||
case widowTaxExemption = "widow_tax_exemption" | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
Sources/SmartyStreets/USEnrichment/ResultTypes/PropertyFinancial/FinancialHistoryEntry.swift
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,61 @@ | ||
import Foundation | ||
|
||
public struct FinancialHistoryEntry: Codable { | ||
let codeTitleCompany, documentTypeDescription, instrumentDate, interestRateType2: String? | ||
let lenderAddress, lenderAddress2, lenderCity, lenderCity2: String? | ||
let lenderCode2, lenderFirstName, lenderFirstName2, lenderLastName: String? | ||
let lenderLastName2, lenderName, lenderName2, lenderSellerCarryBack: String? | ||
let lenderSellerCarryBack2, lenderState, lenderState2, lenderZip: String? | ||
let lenderZip2, lenderZipExtended, lenderZipExtended2, mortgageAmount: String? | ||
let mortgageAmount2, mortgageDueDate, mortgageDueDate2, mortgageInterestRate: String? | ||
let mortgageInterestRateType, mortgageLenderCode, mortgageRate2, mortgageRecordingDate: String? | ||
let mortgageRecordingDate2, mortgageTerm, mortgageTerm2, mortgageTermType: String? | ||
let mortgageTermType2, mortgageType, mortgageType2, multiParcelFlag: String? | ||
let nameTitleCompany, recordingDate, transferAmount: String? | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case codeTitleCompany = "code_title_company" | ||
case documentTypeDescription = "document_type_description" | ||
case instrumentDate = "instrument_date" | ||
case interestRateType2 = "interest_rate_type_2" | ||
case lenderAddress = "lender_address" | ||
case lenderAddress2 = "lender_address_2" | ||
case lenderCity = "lender_city" | ||
case lenderCity2 = "lender_city_2" | ||
case lenderCode2 = "lender_code_2" | ||
case lenderFirstName = "lender_first_name" | ||
case lenderFirstName2 = "lender_first_name_2" | ||
case lenderLastName = "lender_last_name" | ||
case lenderLastName2 = "lender_last_name_2" | ||
case lenderName = "lender_name" | ||
case lenderName2 = "lender_name_2" | ||
case lenderSellerCarryBack = "lender_seller_carry_back" | ||
case lenderSellerCarryBack2 = "lender_seller_carry_back_2" | ||
case lenderState = "lender_state" | ||
case lenderState2 = "lender_state_2" | ||
case lenderZip = "lender_zip" | ||
case lenderZip2 = "lender_zip_2" | ||
case lenderZipExtended = "lender_zip_extended" | ||
case lenderZipExtended2 = "lender_zip_extended_2" | ||
case mortgageAmount = "mortgage_amount" | ||
case mortgageAmount2 = "mortgage_amount_2" | ||
case mortgageDueDate = "mortgage_due_date" | ||
case mortgageDueDate2 = "mortgage_due_date_2" | ||
case mortgageInterestRate = "mortgage_interest_rate" | ||
case mortgageInterestRateType = "mortgage_interest_rate_type" | ||
case mortgageLenderCode = "mortgage_lender_code" | ||
case mortgageRate2 = "mortgage_rate_2" | ||
case mortgageRecordingDate = "mortgage_recording_date" | ||
case mortgageRecordingDate2 = "mortgage_recording_date_2" | ||
case mortgageTerm = "mortgage_term" | ||
case mortgageTerm2 = "mortgage_term_2" | ||
case mortgageTermType = "mortgage_term_type" | ||
case mortgageTermType2 = "mortgage_term_type_2" | ||
case mortgageType = "mortgage_type" | ||
case mortgageType2 = "mortgage_type_2" | ||
case multiParcelFlag = "multi_parcel_flag" | ||
case nameTitleCompany = "name_title_company" | ||
case recordingDate = "recording_date" | ||
case transferAmount = "transfer_amount" | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Sources/SmartyStreets/USEnrichment/ResultTypes/PropertyFinancial/FinancialResult.swift
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,13 @@ | ||
import Foundation | ||
|
||
public struct FinancialResult: Codable { | ||
let smartyKey, dataSetName, dataSubsetName: String | ||
let attributes: FinancialAttributes | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case smartyKey = "smarty_key" | ||
case dataSetName = "data_set_name" | ||
case dataSubsetName = "data_subset_name" | ||
case attributes | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...martyStreets/USEnrichment/ResultTypes/PropertyFinancial/PropertyFinancialSerializer.swift
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 @@ | ||
import Foundation | ||
|
||
|
||
public class PropertyFinancialSerializer: SmartySerializer { | ||
override func Serialize(obj: Any?, error: inout NSError!) -> Data! { | ||
let raw:PropertyFinancialEnrichmentLookup? = obj as? PropertyFinancialEnrichmentLookup | ||
let smartyErrors = SmartyErrors() | ||
let jsonEncoder = JSONEncoder() | ||
jsonEncoder.outputFormatting = .sortedKeys | ||
if raw == nil { | ||
let details = [NSLocalizedDescriptionKey: "The object to be serialized is nil"] | ||
error = NSError(domain: smartyErrors.SSErrorDomain, code: SmartyErrors.SSErrors.ObjectNilError.rawValue, userInfo: details) | ||
return nil | ||
} | ||
|
||
do { | ||
let jsonData = try jsonEncoder.encode(raw) as Data | ||
return jsonData | ||
} catch let jsonError { | ||
let details = [NSLocalizedDescriptionKey: jsonError.localizedDescription] | ||
error = NSError(domain: smartyErrors.SSErrorDomain, code: SmartyErrors.SSErrors.ObjectInvalidTypeError.rawValue, userInfo: details) | ||
} | ||
|
||
|
||
return nil | ||
} | ||
|
||
override public func Deserialize(payload: Data?, error: inout NSError!) -> Any! { | ||
let smartyErrors = SmartyErrors() | ||
let jsonDecoder = JSONDecoder() | ||
if payload == nil { | ||
let details = [NSLocalizedDescriptionKey: "The payload is nil."] | ||
error = NSError(domain: smartyErrors.SSErrorDomain, code: SmartyErrors.SSErrors.ObjectNilError.rawValue, userInfo: details) | ||
return nil | ||
} | ||
|
||
do { | ||
let result:[FinancialResult] = try jsonDecoder.decode([FinancialResult].self, from: payload!) | ||
return result | ||
} catch let jsonError { | ||
let details = [NSLocalizedDescriptionKey:jsonError.localizedDescription] | ||
error = NSError(domain: smartyErrors.SSErrorDomain, code: SmartyErrors.SSErrors.ObjectInvalidTypeError.rawValue, userInfo: details) | ||
return nil | ||
} | ||
} | ||
} |
Oops, something went wrong.