File tree Expand file tree Collapse file tree 2 files changed +23
-14
lines changed Expand file tree Collapse file tree 2 files changed +23
-14
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,16 @@ impl GitHubClient {
25
25
self . request ( "/user" , auth)
26
26
}
27
27
28
+ pub fn team_by_name (
29
+ & self ,
30
+ org_name : & str ,
31
+ team_name : & str ,
32
+ auth : & AccessToken ,
33
+ ) -> AppResult < GitHubTeam > {
34
+ let url = format ! ( "/orgs/{}/teams/{}" , org_name, team_name) ;
35
+ self . request ( & url, auth)
36
+ }
37
+
28
38
pub fn team_membership (
29
39
& self ,
30
40
org_id : i32 ,
@@ -106,6 +116,18 @@ pub struct GithubUser {
106
116
pub name : Option < String > ,
107
117
}
108
118
119
+ #[ derive( Debug , Deserialize , Copy ) ]
120
+ pub struct GitHubOrganization {
121
+ pub id : i32 , // unique GH id (needed for membership queries)
122
+ }
123
+
124
+ #[ derive( Debug , Deserialize ) ]
125
+ pub struct GitHubTeam {
126
+ pub id : i32 , // unique GH id (needed for membership queries)
127
+ pub name : Option < String > , // Pretty name
128
+ pub organization : GitHubOrganization ,
129
+ }
130
+
109
131
#[ derive( Debug , Deserialize ) ]
110
132
pub struct GitHubTeamMembership {
111
133
pub state : String ,
Original file line number Diff line number Diff line change @@ -138,23 +138,10 @@ impl Team {
138
138
) ) ) ;
139
139
}
140
140
141
- #[ derive( Deserialize ) ]
142
- struct GithubOrganization {
143
- id : i32 , // unique GH id (needed for membership queries)
144
- }
145
-
146
- #[ derive( Deserialize ) ]
147
- struct GithubTeam {
148
- id : i32 , // unique GH id (needed for membership queries)
149
- name : Option < String > , // Pretty name
150
- organization : GithubOrganization ,
151
- }
152
-
153
- let url = format ! ( "/orgs/{}/teams/{}" , org_name, team_name) ;
154
141
let token = AccessToken :: new ( req_user. gh_access_token . clone ( ) ) ;
155
142
let team = app
156
143
. github
157
- . request :: < GithubTeam > ( & url , & token)
144
+ . team_by_name ( org_name , team_name , & token)
158
145
. map_err ( |_| {
159
146
cargo_err ( & format_args ! (
160
147
"could not find the github team {}/{}" ,
You can’t perform that action at this time.
0 commit comments