aboutsummaryrefslogtreecommitdiff
path: root/src/tw
diff options
context:
space:
mode:
Diffstat (limited to 'src/tw')
-rw-r--r--src/tw/user.rs22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/tw/user.rs b/src/tw/user.rs
index 86fbe3f..4fde026 100644
--- a/src/tw/user.rs
+++ b/src/tw/user.rs
@@ -4,7 +4,11 @@ extern crate serde_json;
pub struct User {
pub id: String,
pub name: String,
- pub handle: String
+ pub handle: String,
+ #[serde(default)]
+ pub protected: bool,
+ #[serde(default)]
+ pub verified: bool
}
impl Default for User {
@@ -12,7 +16,9 @@ impl Default for User {
User {
id: "".to_owned(),
name: "_default_".to_owned(),
- handle: "_default_".to_owned()
+ handle: "_default_".to_owned(),
+ protected: false,
+ verified: false
}
}
}
@@ -23,16 +29,22 @@ impl User {
if let (
Some(id_str),
Some(name),
- Some(screen_name)
+ Some(screen_name),
+ Some(protected),
+ Some(bluecheck)
) = (
json_map.get("id_str").and_then(|x| x.as_str()),
json_map.get("name").and_then(|x| x.as_str()),
- json_map.get("screen_name").and_then(|x| x.as_str())
+ json_map.get("screen_name").and_then(|x| x.as_str()),
+ json_map.get("protected").and_then(|x| x.as_bool()),
+ json_map.get("verified").and_then(|x| x.as_bool())
) {
Ok(User {
id: id_str.to_owned(),
name: name.to_owned(),
- handle: screen_name.to_owned()
+ handle: screen_name.to_owned(),
+ protected: protected.to_owned(),
+ verified: bluecheck.to_owned()
})
} else {
Err("user json missing one of id_str, name, screen_name".to_owned())