@@ -16,12 +16,6 @@ class Organization extends Api
16
16
const PUSH = "push " ;
17
17
const PULL = "pull " ;
18
18
19
- static $ PERMISSIONS = array (
20
- self ::ADMIN ,
21
- self ::PUSH ,
22
- self ::PULL
23
- );
24
-
25
19
/**
26
20
* Get extended information about an organization by its name
27
21
* http://develop.github.com/p/orgs.html
@@ -31,9 +25,7 @@ class Organization extends Api
31
25
*/
32
26
public function show ($ name )
33
27
{
34
- $ response = $ this ->get ('organizations/ ' .urlencode ($ name ));
35
-
36
- return $ response ['organization ' ];
28
+ return $ this ->get ('orgs/ ' .urlencode ($ name ));
37
29
}
38
30
39
31
/**
@@ -66,56 +58,78 @@ public function getPublicRepos($name)
66
58
67
59
/**
68
60
* List all public members of that organization
69
- * http://develop .i.8713187.xyz/p /orgs.html
61
+ * @link http://developer .i.8713187.xyz/v3 /orgs/members/
70
62
*
71
63
* @param string $name the organization name
72
64
* @return array the members
73
65
*/
74
66
public function getPublicMembers ($ name )
75
67
{
76
- $ response = $ this ->get ('organizations/ ' .urlencode ($ name ).'/public_members ' );
68
+ return $ this ->get ('orgs/ ' .urlencode ($ name ).'/members ' );
69
+ }
77
70
78
- return $ response ['users ' ];
71
+ /**
72
+ * Check that user is in that organization
73
+ * @link http://developer.github.com/v3/orgs/members/
74
+ *
75
+ * @param string $name the organization name
76
+ * @param string $user the user
77
+ * @return array the members
78
+ */
79
+ public function getPublicMember ($ name , $ user )
80
+ {
81
+ return $ this ->get ('orgs/ ' .urlencode ($ name ).'/members/ ' .urlencode ($ user ));
79
82
}
80
83
81
84
/**
82
85
* List all teams of that organization
83
- * http://develop .i.8713187.xyz/p /orgs.html
86
+ * @link http://developer .i.8713187.xyz/v3 /orgs/teams/
84
87
*
85
88
* @param string $name the organization name
86
89
* @return array the teams
87
90
*/
88
91
public function getTeams ($ name )
89
92
{
90
- $ response = $ this ->get ('organizations/ ' .urlencode ($ name ).'/teams ' );
93
+ return $ this ->get ('orgs/ ' .urlencode ($ name ).'/teams ' );
94
+ }
91
95
92
- return $ response ['teams ' ];
96
+ /**
97
+ * Get team with given id of that organization
98
+ * @link http://developer.github.com/v3/orgs/teams/
99
+ *
100
+ * @param string $name the organization name
101
+ * @param string $id id of team
102
+ * @return array the team
103
+ */
104
+ public function getTeam ($ name , $ id )
105
+ {
106
+ return $ this ->get ('orgs/ ' .urlencode ($ name ).'/teams/ ' .urlencode ($ id ));
93
107
}
94
108
95
109
/**
96
110
* Add a team to that organization
97
- * http://develop .i.8713187.xyz/p /orgs.html
111
+ * @link http://developer .i.8713187.xyz/v3 /orgs/teams/
98
112
*
99
- * @param string $name the organization name
113
+ * @param string $organization the organization name
100
114
* @param string $team name of the new team
101
115
* @param string $permission its permission [PULL|PUSH|ADMIN]
102
- * @param array $name (optionnal ) its repositories names
116
+ * @param array $repositories (optional ) its repositories names
103
117
*
104
118
* @return array the teams
119
+ *
120
+ * @throws \InvalidArgumentException
105
121
*/
106
- public function addTeam ($ organization , $ team , $ permission , array $ repositories = array ())
122
+ public function addTeam ($ organization , $ team , $ permission = ' pull ' , array $ repositories = array ())
107
123
{
108
- if (!in_array ($ permission , self ::$ PERMISSIONS )) {
124
+ if (!in_array ($ permission , array ( self ::ADMIN , self :: PUSH , self :: PULL ) )) {
109
125
throw new \InvalidArgumentException ("Invalid value for the permission variable " );
110
126
}
111
127
112
- $ response = $ this ->post ('organizations / ' .urlencode ($ organization ).'/teams ' , array (
113
- 'team ' => $ team ,
128
+ return $ this ->post ('orgs / ' .urlencode ($ organization ).'/teams ' , array (
129
+ 'name ' => $ team ,
114
130
'permission ' => $ permission ,
115
131
'repo_names ' => $ repositories
116
132
));
117
-
118
- return $ response ['teams ' ];
119
133
}
120
134
121
135
}
0 commit comments