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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
use error::Result;
use api::{self, ResourceState, AccessToken};
use http;
#[derive(Debug, RustcDecodable)]
pub struct Club {
id: i32,
resource_state: ResourceState,
name: String,
profile_medium: Option<String>,
profile: Option<String>,
cover_photo: Option<String>,
cover_photo_small: Option<String>,
sport_type: Option<SportType>,
city: Option<String>,
state: Option<String>,
country: Option<String>,
private: Option<bool>,
member_count: Option<i32>,
featured: Option<bool>,
verified: Option<bool>,
url: Option<String>,
description: Option<String>,
club_type: Option<ClubType>,
membership: Option<String>,
admin: Option<bool>,
owner: Option<bool>,
following_count: Option<i32>,
}
impl Club {
pub fn get(token: &AccessToken, id: String) -> Result <Club> {
let url = api::v3(token, format!("clubs/{}", id));
http::get::<Club>(&url[..])
}
}
#[derive(Debug, RustcDecodable)]
#[allow(non_camel_case_types)]
pub enum SportType {
cycling,
running,
triathlon,
other,
}
#[derive(Debug, RustcDecodable)]
#[allow(non_camel_case_types)]
pub enum ClubType {
casual_club,
racing_team,
shop,
company,
other,
}
#[cfg(feature = "api_test")]
#[cfg(test)]
mod api_tests {
use super::Club;
use api::AccessToken;
#[test]
#[test]
fn get_club() {
let id = "1".to_string();
let token = AccessToken::new_from_env().unwrap();
let club = Club::get(&token,id);
println!("{:?}",club);
}
}