Skip to content

Commit

Permalink
changes based on @acrobat's suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
lolos committed Apr 20, 2020
1 parent 6ecdb0a commit 6ceeb55
Showing 1 changed file with 35 additions and 22 deletions.
57 changes: 35 additions & 22 deletions lib/Github/Api/Organization/Teams.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

/**
* @link http://developer.github.com/v3/orgs/teams/
*
* @author Joseph Bielawski <stloyd@gmail.com>
*/
class Teams extends AbstractApi
Expand Down Expand Up @@ -37,11 +36,13 @@ public function create($organization, array $params)
*/
public function show($team, $organization = null)
{
if ($organization) {
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
if (null === $organization) {
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);

return $this->get('/teams/'.rawurlencode($team));
}

return $this->get('/teams/'.rawurlencode($team));
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
}

/**
Expand All @@ -56,71 +57,83 @@ public function update($team, array $params, $organization = null)
$params['permission'] = 'pull';
}

if ($organization) {
return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params);
if (null === $organization) {
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);

return $this->patch('/teams/'.rawurlencode($team), $params);
}

return $this->patch('/teams/'.rawurlencode($team), $params);
return $this->patch('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team), $params);
}

/**
* @link https://developer.github.com/v3/teams/#delete-team
*/
public function remove($team, $organization = null)
{
if ($organization) {
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
if (null === $organization) {
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);

return $this->delete('/teams/'.rawurlencode($team));
}

return $this->delete('/teams/'.rawurlencode($team));
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team));
}

/**
* @link https://developer.github.com/v3/teams/members/#list-team-members
*/
public function members($team, $organization = null)
{
if ($organization) {
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members');
if (null === $organization) {
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);

return $this->get('/teams/'.rawurlencode($team).'/members');
}

return $this->get('/teams/'.rawurlencode($team).'/members');
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/members');
}

/**
* @link https://developer.github.com/v3/teams/members/#get-team-membership
*/
public function check($team, $username, $organization = null)
{
if ($organization) {
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
if (null === $organization) {
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);

return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
}

return $this->get('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
return $this->get('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
}

/**
* @link https://developer.github.com/v3/teams/members/#add-or-update-team-membership
*/
public function addMember($team, $username, $organization = null)
{
if ($organization) {
return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
if (null === $organization) {
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);

return $this->put('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
}

return $this->put('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
return $this->put('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
}

/**
* @link https://developer.github.com/v3/teams/members/#remove-team-membership
*/
public function removeMember($team, $username, $organization = null)
{
if ($organization) {
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
if (null === $organization) {
@trigger_error('Not passing the $organisation parameter is deprecated in knpLabs/php-github-api v2.14 and will be mandatory in v3.0.', E_USER_DEPRECATED);

return $this->delete('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
}

return $this->delete('/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
return $this->delete('/orgs/'.rawurlencode($organization).'/teams/'.rawurlencode($team).'/memberships/'.rawurlencode($username));
}

public function repositories($team)
Expand Down

0 comments on commit 6ceeb55

Please sign in to comment.