-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathusers.rs
More file actions
60 lines (51 loc) · 1.33 KB
/
Copy pathusers.rs
File metadata and controls
60 lines (51 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#[allow(unused_attributes)]
use rustc_serialize::json;
use client::Client;
pub struct UserService {
client: Client,
}
impl UserService {
pub fn new(c: Client) -> UserService {
UserService { client: c }
}
pub fn get(self, name: &str) -> User {
let mut url = "https://api.github.com/users/".to_string();
url.push_str(name);
let req = self.client.request(url.as_ref());
let user: User = json::decode(req.as_ref()).unwrap();
return user;
}
}
#[allow(dead_code)]
#[derive(RustcDecodable)]
pub struct User {
pub login: String,
pub id: i32,
pub avatar_url: String,
pub gravatar_id: String,
pub url: String,
pub html_url: String,
pub followers_url: String,
pub following_url: String,
pub gists_url: String,
pub starred_url: String,
pub subscriptions_url: String,
pub organizations_url: String,
pub repos_url: String,
pub events_url: String,
pub received_events_url: String,
pub site_admin: bool,
pub name: String,
pub company: String,
pub blog: String,
pub location: String,
pub email: String,
pub hireable: bool,
pub bio: Option<String>,
pub public_repos: i32,
pub public_gists: i32,
pub followers: i32,
pub following: i32,
pub created_at: String,
pub updated_at: String,
}