diff --git a/CHANGELOG.md b/CHANGELOG.md index 49e6cee0644..70cd9c67047 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee - API for Repo\Cards - API for Repo\Columns - API for Repo\Projects +- API for User\MyRepositories - Methods in Repo API for frequency and participation ### Changed diff --git a/lib/Github/Api/User.php b/lib/Github/Api/User.php index d866c93050b..b5003667dac 100644 --- a/lib/Github/Api/User.php +++ b/lib/Github/Api/User.php @@ -145,9 +145,9 @@ public function subscriptions($username) } /** - * Get the repositories of a user. + * List public repositories for the specified user. * - * @link http://developer.github.com/v3/repos/ + * @link https://developer.github.com/v3/repos/#list-user-repositories * * @param string $username the username * @param string $type role in the repository @@ -158,11 +158,25 @@ public function subscriptions($username) */ public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc') { - return $this->get('/users/'.rawurlencode($username).'/repos', array( + return $this->get('/users/'.rawurlencode($username).'/repos', [ 'type' => $type, 'sort' => $sort, - 'direction' => $direction - )); + 'direction' => $direction, + ]); + } + + /** + * List repositories that are accessible to the authenticated user. + * + * @link https://developer.github.com/v3/repos/#list-your-repositories + * + * @param array $params visibility, affiliation, type, sort, direction + * + * @return array list of the user repositories + */ + public function myRepositories(array $params = []) + { + return $this->get('/user/repos', $params); } /** diff --git a/test/Github/Tests/Api/UserTest.php b/test/Github/Tests/Api/UserTest.php index 711c50ecba6..99b32c8ac52 100644 --- a/test/Github/Tests/Api/UserTest.php +++ b/test/Github/Tests/Api/UserTest.php @@ -145,6 +145,21 @@ public function shouldGetUserRepositories() $this->assertEquals($expectedArray, $api->repositories('l3l0')); } + /** + * @test + */ + public function shouldGetMyRepositories() + { + $expectedArray = [['id' => 1, 'name' => 'l3l0repo']]; + + $api = $this->getApiMock(); + $api->expects($this->once()) + ->method('get')->with('/user/repos', []) + ->will($this->returnValue($expectedArray)); + + $this->assertEquals($expectedArray, $api->myRepositories()); + } + /** * @test */