Skip to content

Commit f4c7210

Browse files
committed
Update Organization calls and removed user search from API
1 parent 681c7d0 commit f4c7210

File tree

2 files changed

+39
-28
lines changed

2 files changed

+39
-28
lines changed

lib/Github/Api/Organization.php

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ class Organization extends Api
1616
const PUSH = "push";
1717
const PULL = "pull";
1818

19-
static $PERMISSIONS = array(
20-
self::ADMIN,
21-
self::PUSH,
22-
self::PULL
23-
);
24-
2519
/**
2620
* Get extended information about an organization by its name
2721
* http://develop.github.com/p/orgs.html
@@ -31,9 +25,7 @@ class Organization extends Api
3125
*/
3226
public function show($name)
3327
{
34-
$response = $this->get('organizations/'.urlencode($name));
35-
36-
return $response['organization'];
28+
return $this->get('orgs/'.urlencode($name));
3729
}
3830

3931
/**
@@ -66,56 +58,78 @@ public function getPublicRepos($name)
6658

6759
/**
6860
* List all public members of that organization
69-
* http://develop.github.com/p/orgs.html
61+
* @link http://developer.github.com/v3/orgs/members/
7062
*
7163
* @param string $name the organization name
7264
* @return array the members
7365
*/
7466
public function getPublicMembers($name)
7567
{
76-
$response = $this->get('organizations/'.urlencode($name).'/public_members');
68+
return $this->get('orgs/'.urlencode($name).'/members');
69+
}
7770

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));
7982
}
8083

8184
/**
8285
* List all teams of that organization
83-
* http://develop.github.com/p/orgs.html
86+
* @link http://developer.github.com/v3/orgs/teams/
8487
*
8588
* @param string $name the organization name
8689
* @return array the teams
8790
*/
8891
public function getTeams($name)
8992
{
90-
$response = $this->get('organizations/'.urlencode($name).'/teams');
93+
return $this->get('orgs/'.urlencode($name).'/teams');
94+
}
9195

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));
93107
}
94108

95109
/**
96110
* Add a team to that organization
97-
* http://develop.github.com/p/orgs.html
111+
* @link http://developer.github.com/v3/orgs/teams/
98112
*
99-
* @param string $name the organization name
113+
* @param string $organization the organization name
100114
* @param string $team name of the new team
101115
* @param string $permission its permission [PULL|PUSH|ADMIN]
102-
* @param array $name (optionnal) its repositories names
116+
* @param array $repositories (optional) its repositories names
103117
*
104118
* @return array the teams
119+
*
120+
* @throws \InvalidArgumentException
105121
*/
106-
public function addTeam($organization, $team, $permission, array $repositories = array())
122+
public function addTeam($organization, $team, $permission = 'pull', array $repositories = array())
107123
{
108-
if (!in_array($permission, self::$PERMISSIONS)) {
124+
if (!in_array($permission, array(self::ADMIN, self::PUSH, self::PULL))) {
109125
throw new \InvalidArgumentException("Invalid value for the permission variable");
110126
}
111127

112-
$response = $this->post('organizations/'.urlencode($organization).'/teams', array(
113-
'team' => $team,
128+
return $this->post('orgs/'.urlencode($organization).'/teams', array(
129+
'name' => $team,
114130
'permission' => $permission,
115131
'repo_names' => $repositories
116132
));
117-
118-
return $response['teams'];
119133
}
120134

121135
}

lib/Github/Api/User.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,7 @@ class User extends Api
2121
*/
2222
public function search($username)
2323
{
24-
//old api to do
25-
$response = $this->get('user/search/'.urlencode($username));
26-
27-
return $response['users'];
24+
throw new \BadMethodCallException('Method cannot be implemented using new api version');
2825
}
2926

3027
/**

0 commit comments

Comments
 (0)