From 5eb55ce410e499b505f590aa20492e14fcf252f6 Mon Sep 17 00:00:00 2001 From: Pierre Grimaud Date: Mon, 20 Apr 2020 21:48:06 +0200 Subject: [PATCH] feature #863 Add sort and direction for fetching organizations repos (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 ------- 5c3aee1f68509c91e9ae0d233f9dab37e315678a Add sort and direction for fetching organizations repos 6aa74fbe88cb4e1fe73330622a33ba142c1f285d Fix styleci 041af9203b50d43509b474c010c88f85c846dd60 Set new parameters as null instead of default values 304bd1904214aa220ea94ee90f804ed527d8bb7d Fix styleci --- lib/Github/Api/Notification.php | 1 + lib/Github/Api/Organization.php | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/Github/Api/Notification.php b/lib/Github/Api/Notification.php index 0d73d6076c7..e8c9b246a11 100644 --- a/lib/Github/Api/Notification.php +++ b/lib/Github/Api/Notification.php @@ -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 */ diff --git a/lib/Github/Api/Organization.php b/lib/Github/Api/Organization.php index 29b71d1480e..32eba7d2d87 100644 --- a/lib/Github/Api/Organization.php +++ b/lib/Github/Api/Organization.php @@ -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); } /**