Skip to content

Commit ca63e29

Browse files
committed
fixes backward compatibility check
1 parent 7742bd1 commit ca63e29

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

lib/Github/Api/Organization/Teams.php

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@ public function create($organization, array $params)
3535
/**
3636
* @link https://developer.github.com/v3/teams/#list-teams
3737
*/
38-
public function show($team, $organization)
38+
public function show($team, $organization = null)
3939
{
40-
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
40+
if ($organization) {
41+
return $this->get('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team));
42+
}
43+
44+
return $this->get('/teams/'.rawurlencode($team));
4145
}
4246

4347
/**
4448
* @link https://developer.github.com/v3/teams/#edit-team
4549
*/
46-
public function update($team, array $params, $organization)
50+
public function update($team, array $params, $organization = null)
4751
{
4852
if (!isset($params['name'])) {
4953
throw new MissingArgumentException('name');
@@ -52,47 +56,71 @@ public function update($team, array $params, $organization)
5256
$params['permission'] = 'pull';
5357
}
5458

55-
return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params);
59+
if ($organization) {
60+
return $this->patch('/teams/' . rawurlencode($team), $params);
61+
}
62+
63+
return $this->patch('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team), $params);
5664
}
5765

5866
/**
5967
* @link https://developer.github.com/v3/teams/#delete-team
6068
*/
61-
public function remove($team, $organization)
69+
public function remove($team, $organization = null)
6270
{
63-
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
71+
if ($organization) {
72+
return $this->delete('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team));
73+
}
74+
75+
return $this->delete('/teams/' . rawurlencode($team));
6476
}
6577

6678
/**
6779
* @link https://developer.github.com/v3/teams/members/#list-team-members
6880
*/
69-
public function members($team, $organization)
81+
public function members($team, $organization = null)
7082
{
71-
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members');
83+
if ($organization) {
84+
return $this->get('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/members');
85+
}
86+
87+
return $this->get('/teams/' . rawurlencode($team) . '/members');
7288
}
7389

7490
/**
7591
* @link https://developer.github.com/v3/teams/members/#get-team-membership
7692
*/
77-
public function check($team, $username, $organization)
93+
public function check($team, $username, $organization = null)
7894
{
79-
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
95+
if ($organization) {
96+
return $this->get('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username));
97+
}
98+
99+
return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
80100
}
81101

82102
/**
83103
* @link https://developer.github.com/v3/teams/members/#add-or-update-team-membership
84104
*/
85-
public function addMember($team, $username, $organization)
105+
public function addMember($team, $username, $organization = null)
86106
{
87-
return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
107+
if ($organization) {
108+
return $this->put('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username));
109+
}
110+
111+
return $this->put('/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username));
88112
}
89113

90114
/**
91115
* @link https://developer.github.com/v3/teams/members/#remove-team-membership
92116
*/
93-
public function removeMember($team, $username, $organization)
117+
public function removeMember($team, $username, $organization = null)
94118
{
95-
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
119+
if ($organization) {
120+
return $this->delete('/orgs/' . rawurlencode($organization) . '/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username));
121+
}
122+
123+
return $this->delete('/teams/' . rawurlencode($team) . '/memberships/' . rawurlencode($username));
96124
}
97125

98126
public function repositories($team)

0 commit comments

Comments
 (0)