Skip to content

Add missing parameters for User/CurrentUser Repositories #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/Github/Api/CurrentUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,22 @@ public function teams()
/**
* @link http://developer.github.com/v3/repos/#list-your-repositories
*
* @param string $type role in the repository
* @param string $sort sort by
* @param string $direction direction of sort, asc or desc
* @param string $type role in the repository
* @param string $sort sort by
* @param string $direction direction of sort, asc or desc
* @param string $visibility visibility of repository
* @param string $affiliation relationship to repository
*
* @return array
*/
public function repositories($type = 'owner', $sort = 'full_name', $direction = 'asc')
public function repositories($type = 'owner', $sort = 'full_name', $direction = 'asc', $visibility = 'all', $affiliation = 'owner,collaborator,organization_member')
{
return $this->get('/user/repos', [
'type' => $type,
'sort' => $sort,
'direction' => $direction,
'visibility' => $visibility,
'affiliation' => $affiliation,
]);
}

Expand Down
2 changes: 2 additions & 0 deletions lib/Github/Api/Repository/Collaborators.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,11 @@ public function remove($username, $repository, $collaborator)

/**
* @link https://developer.github.com/v3/repos/collaborators/#review-a-users-permission-level
*
* @param $username
* @param $repository
* @param $collaborator
*
* @return array|string
*/
public function permission($username, $repository, $collaborator)
Expand Down
14 changes: 9 additions & 5 deletions lib/Github/Api/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,19 +173,23 @@ public function subscriptions($username)
*
* @link https://developer.github.com/v3/repos/#list-user-repositories
*
* @param string $username the username
* @param string $type role in the repository
* @param string $sort sort by
* @param string $direction direction of sort, asc or desc
* @param string $username the username
* @param string $type role in the repository
* @param string $sort sort by
* @param string $direction direction of sort, asc or desc
* @param string $visibility visibility of repository
* @param string $affiliation relationship to repository
*
* @return array list of the user repositories
*/
public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc')
public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc', $visibility = 'all', $affiliation = 'owner,collaborator,organization_member')
{
return $this->get('/users/'.rawurlencode($username).'/repos', [
'type' => $type,
'sort' => $sort,
'direction' => $direction,
'visibility' => $visibility,
'affiliation' => $affiliation,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion test/Github/Tests/Api/Repository/CollaboratorsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function shouldRemoveRepositoryCollaborator()
*/
public function shouldGetRepositoryCollaboratorPermission()
{
$expectedValue = array(array('permission' => 'admin', 'user' => 'l3l0'));
$expectedValue = [['permission' => 'admin', 'user' => 'l3l0']];

$api = $this->getApiMock();
$api->expects($this->once())
Expand Down
2 changes: 1 addition & 1 deletion test/Github/Tests/Api/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function shouldGetUserRepositories()
$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/users/l3l0/repos', ['type' => 'owner', 'sort' => 'full_name', 'direction' => 'asc'])
->with('/users/l3l0/repos', ['type' => 'owner', 'sort' => 'full_name', 'direction' => 'asc', 'visibility' => 'all', 'affiliation' => 'owner,collaborator,organization_member'])
->will($this->returnValue($expectedArray));

$this->assertEquals($expectedArray, $api->repositories('l3l0'));
Expand Down