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
86
87
88
89
90
91
92
93
94
95
96
use self::super::{Github, Result};
use teams::OrgTeams;
use repositories::OrgRepositories;
pub struct Organization<'a> {
github: &'a Github,
org: String,
}
impl<'a> Organization<'a> {
pub fn new<O>(github: &'a Github, org: O) -> Self
where O: Into<String>
{
Organization {
github: github,
org: org.into(),
}
}
pub fn teams(&self) -> OrgTeams {
OrgTeams::new(self.github, self.org.clone())
}
pub fn repos(&self) -> OrgRepositories {
OrgRepositories::new(self.github, self.org.clone())
}
}
pub struct Organizations<'a> {
github: &'a Github,
}
impl<'a> Organizations<'a> {
pub fn new(github: &'a Github) -> Organizations<'a> {
Organizations { github: github }
}
fn path(&self, more: &str) -> String {
format!("/user/orgs{}", more)
}
pub fn list(&self) -> Result<Vec<Org>> {
self.github.get::<Vec<Org>>(&self.path(""))
}
}
pub struct UserOrganizations<'a> {
github: &'a Github,
user: String,
}
impl<'a> UserOrganizations<'a> {
pub fn new<U>(github: &'a Github, user: U) -> UserOrganizations<'a>
where U: Into<String>
{
UserOrganizations {
github: github,
user: user.into(),
}
}
fn path(&self, more: &str) -> String {
format!("/users/{}/orgs{}", self.user, more)
}
pub fn list(&self) -> Result<Vec<Org>> {
self.github.get::<Vec<Org>>(&self.path(""))
}
}
#[derive(Debug, Deserialize)]
pub struct Org {
pub login: String,
pub id: u64,
pub url: String,
pub repos_url: String,
pub events_url: String,
pub hooks_url: String,
pub issues_url: String,
pub members_url: String,
pub public_members_url: String,
pub avatar_url: String,
pub description: Option<String>,
}