Skip to content

Commit 67f507f

Browse files
committed
Merge pull request #347 from phpdreams/master
Add new Organization management methods and tweak caching.
2 parents 29939bb + 6c27bd4 commit 67f507f

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/Github/Api/Organization/Members.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
class Members extends AbstractApi
1212
{
13-
public function all($organization, $type = null, $filter = 'all')
13+
public function all($organization, $type = null, $filter = 'all', $role = null)
1414
{
1515
$parameters = array();
1616
$path = 'orgs/'.rawurlencode($organization).'/';
@@ -19,6 +19,9 @@ public function all($organization, $type = null, $filter = 'all')
1919
if (null !== $filter) {
2020
$parameters['filter'] = $filter;
2121
}
22+
if (null !== $role) {
23+
$parameters['role'] = $role;
24+
}
2225
} else {
2326
$path .= 'public_members';
2427
}
@@ -31,11 +34,21 @@ public function show($organization, $username)
3134
return $this->get('orgs/'.rawurlencode($organization).'/members/'.rawurlencode($username));
3235
}
3336

37+
public function member($organization, $username)
38+
{
39+
return $this->get('orgs/'.rawurlencode($organization).'/memberships/'.rawurlencode($username));
40+
}
41+
3442
public function check($organization, $username)
3543
{
3644
return $this->get('orgs/'.rawurlencode($organization).'/public_members/'.rawurlencode($username));
3745
}
3846

47+
public function addMember($organization, $username)
48+
{
49+
return $this->put('orgs/'.rawurlencode($organization).'/memberships/'.rawurlencode($username));
50+
}
51+
3952
public function publicize($organization, $username)
4053
{
4154
return $this->put('orgs/'.rawurlencode($organization).'/public_members/'.rawurlencode($username));

lib/Github/HttpClient/CachedHttpClient.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ public function request($path, $body = null, $httpMethod = 'GET', array $headers
6868
return $cacheResponse;
6969
}
7070

71-
$this->getCache()->set($this->id, $response);
71+
if (in_array($httpMethod, array('GET', 'HEAD'), true)) {
72+
$this->getCache()->set($this->id, $response);
73+
}
7274

7375
return $response;
7476
}

0 commit comments

Comments
 (0)