Skip to content

Commit

Permalink
feature #863 Add sort and direction for fetching organizations repos …
Browse files Browse the repository at this point in the history
…(pgrimaud)

This PR was squashed before being merged into the 2.13.x-dev branch.

Discussion
----------

Hi,

It's possible to sort repositories of organizations here : https://developer.github.com/v3/repos/#list-organization-repositories.

I added `$sort` and `$direction` parameters after actual parameters to avoid BC.

Associated tests are updated too.

Commits
-------

5c3aee1 Add sort and direction for fetching organizations repos
6aa74fb Fix styleci
041af92 Set new parameters as null instead of default values
304bd19 Fix styleci
  • Loading branch information
Pierre Grimaud committed Apr 20, 2020
1 parent 1cb5115 commit 5eb55ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/Github/Api/Notification.php
Expand Up @@ -23,6 +23,7 @@ class Notification extends AbstractApi
* @param bool $includingRead
* @param bool $participating
* @param DateTime|null $since
* @param DateTime|null $before
*
* @return array array of notifications
*/
Expand Down
18 changes: 15 additions & 3 deletions lib/Github/Api/Organization.php
Expand Up @@ -53,15 +53,27 @@ public function update($organization, array $params)
* @param string $organization the user name
* @param string $type the type of repositories
* @param int $page the page
* @param string $sort sort by
* @param string $direction direction of sort, asc or desc
*
* @return array the repositories
*/
public function repositories($organization, $type = 'all', $page = 1)
public function repositories($organization, $type = 'all', $page = 1, $sort = null, $direction = null)
{
return $this->get('/orgs/'.rawurlencode($organization).'/repos', [
$parameters = [
'type' => $type,
'page' => $page,
]);
];

if ($sort !== null) {
$parameters['sort'] = $sort;
}

if ($direction !== null) {
$parameters['direction'] = $direction;
}

return $this->get('/orgs/'.rawurlencode($organization).'/repos', $parameters);
}

/**
Expand Down

0 comments on commit 5eb55ce

Please sign in to comment.