Skip to content

Commit 2c248bc

Browse files
Enrichment/financial refactor (#39)
* Added financial_history to property/principal response. Added features to lookup. * Fully remove enrichment property financial.
1 parent a4a22f5 commit 2c248bc

File tree

6 files changed

+67
-173
lines changed

6 files changed

+67
-173
lines changed

smarty-rust-sdk/examples/us_enrichment_api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use smarty_rust_sdk::sdk::authentication::SecretKeyCredential;
22
use smarty_rust_sdk::sdk::options::OptionsBuilder;
33

44
use smarty_rust_sdk::us_enrichment_api::client::*;
5-
use smarty_rust_sdk::us_enrichment_api::financial::*;
65
use smarty_rust_sdk::us_enrichment_api::geo::*;
76
use smarty_rust_sdk::us_enrichment_api::principal::*;
87

@@ -18,7 +17,6 @@ use std::error::Error;
1817
async fn main() -> Result<(), Box<dyn Error>> {
1918
let key = 7;
2019

21-
lookup::<FinancialResponse>(key).await?;
2220
lookup::<PrincipalResponse>(key).await?;
2321
lookup::<GeoReferenceResponse>(key).await?;
2422
lookup::<GeoReference2010Response>(key).await?;
@@ -33,6 +31,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
3331
async fn lookup<R: EnrichmentResponse>(key: u32) -> Result<(), Box<dyn Error>> {
3432
let mut lookup = EnrichmentLookup::<R> {
3533
smarty_key: key,
34+
include: "".to_string(), // optional: only include these attributes in the returned data. e.g. "group_structural,sale_date"
35+
exclude: "".to_string(), // optional: exclude attributes from the returned data
3636
etag: "".to_string(),
3737
..Default::default()
3838
};

smarty-rust-sdk/src/us_enrichment_api/client.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ impl USEnrichmentClient {
4040
}
4141

4242
req = self.client.build_request(req);
43+
req = req.query(&lookup.clone().into_param_array());
4344

4445
println!("{req:?}");
4546

smarty-rust-sdk/src/us_enrichment_api/financial.rs

Lines changed: 0 additions & 170 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
1+
use crate::sdk::has_param;
12
use crate::us_enrichment_api::response::EnrichmentResponse;
23

34
#[derive(Clone, Default)]
45
pub struct EnrichmentLookup<R: EnrichmentResponse> {
56
pub smarty_key: u32,
7+
pub include: String,
8+
pub exclude: String,
69
pub etag: String,
10+
pub features: String,
711
pub results: Vec<R>,
812
}
913

1014
impl<R: EnrichmentResponse> EnrichmentLookup<R> {
1115
pub(crate) fn set_results(&mut self, results: Vec<R>) {
1216
self.results = results
1317
}
18+
19+
pub(crate) fn into_param_array(self) -> Vec<(String, String)> {
20+
vec![
21+
has_param("include".to_string(), self.include),
22+
has_param("exclude".to_string(), self.exclude),
23+
has_param("features".to_string(), self.features),
24+
]
25+
.iter()
26+
.filter_map(Option::clone)
27+
.collect::<Vec<_>>()
28+
}
1429
}

smarty-rust-sdk/src/us_enrichment_api/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pub mod lookup;
33

44
pub mod response;
55

6-
pub mod financial;
76
pub mod geo;
87
pub mod principal;
98
pub mod secondary;

smarty-rust-sdk/src/us_enrichment_api/principal.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,54 @@ impl EnrichmentResponse for PrincipalResponse {
1818
}
1919
}
2020

21+
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
22+
#[serde(default)]
23+
pub struct FinancialHistoryEntry {
24+
pub code_title_company: String,
25+
pub document_type_description: String,
26+
pub instrument_date: String,
27+
pub interest_rate_type_2: String,
28+
pub lender_address: String,
29+
pub lender_address_2: String,
30+
pub lender_city: String,
31+
pub lender_city_2: String,
32+
pub lender_code_2: String,
33+
pub lender_first_name: String,
34+
pub lender_first_name_2: String,
35+
pub lender_last_name: String,
36+
pub lender_last_name_2: String,
37+
pub lender_name: String,
38+
pub lender_name_2: String,
39+
pub lender_seller_carry_back: String,
40+
pub lender_seller_carry_back_2: String,
41+
pub lender_state: String,
42+
pub lender_state_2: String,
43+
pub lender_zip: String,
44+
pub lender_zip_2: String,
45+
pub lender_zip_extended: String,
46+
pub lender_zip_extended_2: String,
47+
pub mortgage_amount: String,
48+
pub mortgage_amount_2: String,
49+
pub mortgage_due_date: String,
50+
pub mortgage_due_date_2: String,
51+
pub mortgage_interest_rate: String,
52+
pub mortgage_interest_rate_type: String,
53+
pub mortgage_lender_code: String,
54+
pub mortgage_rate_2: String,
55+
pub mortgage_recording_date: String,
56+
pub mortgage_recording_date_2: String,
57+
pub mortgage_term: String,
58+
pub mortgage_term_2: String,
59+
pub mortgage_term_type: String,
60+
pub mortgage_term_type_2: String,
61+
pub mortgage_type: String,
62+
pub mortgage_type_2: String,
63+
pub multi_parcel_flag: String,
64+
pub name_title_company: String,
65+
pub recording_date: String,
66+
pub transfer_amount: String,
67+
}
68+
2169
#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
2270
#[serde(default)]
2371
pub struct PrincipalAttributes {
@@ -139,6 +187,7 @@ pub struct PrincipalAttributes {
139187
pub family_room: String,
140188
pub fence: String,
141189
pub fence_area: String,
190+
pub financial_history: Vec<FinancialHistoryEntry>,
142191
pub fips_code: String,
143192
pub fire_resistance_code: String,
144193
pub fire_sprinklers_flag: String,

0 commit comments

Comments
 (0)