Skip to content

Commit a933881

Browse files
authored
Merge pull request #32 from dacut/feature/add-county-source
Add county_source parameter to the US Street API
2 parents b57ed2c + 42a231f commit a933881

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

smarty-rust-sdk/src/us_street_api/lookup.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub struct Lookup {
3838
#[serde(rename = "format")]
3939
pub format_output: OutputFormat,
4040

41+
pub county_source: CountySource,
42+
4143
#[serde(skip_serializing)]
4244
pub results: Candidates,
4345
}
@@ -59,6 +61,7 @@ impl Default for Lookup {
5961

6062
match_strategy: Default::default(),
6163
format_output: Default::default(),
64+
county_source: Default::default(),
6265
results: vec![],
6366
}
6467
}
@@ -90,6 +93,7 @@ impl Lookup {
9093
has_param("candidates".to_string(), max_candidates_string),
9194
has_param("match".to_string(), self.match_strategy.to_string()),
9295
has_param("format".to_string(), self.format_output.to_string()),
96+
has_param("county_source".to_string(), self.county_source.to_string()),
9397
]
9498
.iter()
9599
.filter_map(Option::clone)
@@ -141,3 +145,24 @@ impl Display for OutputFormat {
141145
}
142146
}
143147
}
148+
149+
#[derive(Default, Debug, Clone, PartialEq, Serialize)]
150+
#[serde(rename_all = "snake_case")]
151+
pub enum CountySource {
152+
#[default]
153+
Postal,
154+
Geographic,
155+
}
156+
157+
impl Display for CountySource {
158+
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
159+
match self {
160+
CountySource::Postal => {
161+
write!(f, "postal")
162+
}
163+
CountySource::Geographic => {
164+
write!(f, "geographic")
165+
}
166+
}
167+
}
168+
}

0 commit comments

Comments
 (0)