pub struct Builder {
option_string: String,
}
impl Builder {
pub fn new() -> Builder {
Builder {
option_string: String::new(),
}
}
pub(crate) fn build(self) -> String {
self.option_string
}
pub fn realtime_start(&mut self, start_date: &str) -> &mut Builder {
self.option_string += format!("&realtime_start={}", start_date).as_str();
self
}
pub fn realtime_end(&mut self, end_date: &str) -> &mut Builder {
self.option_string += format!("&realtime_end={}", end_date).as_str();
self
}
}
#[cfg(test)]
mod tests {
use crate::category::Response;
use crate::client::FredClient;
#[test]
fn category_related_no_options() {
let mut c = match FredClient::new() {
Ok(c) => c,
Err(msg) => {
println!("{}", msg);
assert_eq!(2, 1);
return
},
};
let resp: Response = match c.category_related(125, None) {
Ok(resp) => resp,
Err(msg) => {
println!("{}", msg);
assert_eq!(2, 1);
return
},
};
for s in resp.categories {
println!("ID: {} Name: {} ParentID: {}", s.id, s.name, s.parent_id);
}
}
}