Skip to content

Commit 4dd10ea

Browse files
authored
Merge pull request #472 from seferov/master
Added 'user/repos' missing endpoint
2 parents c387af1 + 97b4114 commit 4dd10ea

File tree

3 files changed

+35
-5
lines changed

3 files changed

+35
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
1313
- API for Repo\Cards
1414
- API for Repo\Columns
1515
- API for Repo\Projects
16+
- API for User\MyRepositories
1617
- Methods in Repo API for frequency and participation
1718

1819
### Changed

lib/Github/Api/User.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ public function subscriptions($username)
145145
}
146146

147147
/**
148-
* Get the repositories of a user.
148+
* List public repositories for the specified user.
149149
*
150-
* @link http://developer.github.com/v3/repos/
150+
* @link https://developer.github.com/v3/repos/#list-user-repositories
151151
*
152152
* @param string $username the username
153153
* @param string $type role in the repository
@@ -158,11 +158,25 @@ public function subscriptions($username)
158158
*/
159159
public function repositories($username, $type = 'owner', $sort = 'full_name', $direction = 'asc')
160160
{
161-
return $this->get('/users/'.rawurlencode($username).'/repos', array(
161+
return $this->get('/users/'.rawurlencode($username).'/repos', [
162162
'type' => $type,
163163
'sort' => $sort,
164-
'direction' => $direction
165-
));
164+
'direction' => $direction,
165+
]);
166+
}
167+
168+
/**
169+
* List repositories that are accessible to the authenticated user.
170+
*
171+
* @link https://developer.github.com/v3/repos/#list-your-repositories
172+
*
173+
* @param array $params visibility, affiliation, type, sort, direction
174+
*
175+
* @return array list of the user repositories
176+
*/
177+
public function myRepositories(array $params = [])
178+
{
179+
return $this->get('/user/repos', $params);
166180
}
167181

168182
/**

test/Github/Tests/Api/UserTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ public function shouldGetUserRepositories()
145145
$this->assertEquals($expectedArray, $api->repositories('l3l0'));
146146
}
147147

148+
/**
149+
* @test
150+
*/
151+
public function shouldGetMyRepositories()
152+
{
153+
$expectedArray = [['id' => 1, 'name' => 'l3l0repo']];
154+
155+
$api = $this->getApiMock();
156+
$api->expects($this->once())
157+
->method('get')->with('/user/repos', [])
158+
->will($this->returnValue($expectedArray));
159+
160+
$this->assertEquals($expectedArray, $api->myRepositories());
161+
}
162+
148163
/**
149164
* @test
150165
*/

0 commit comments

Comments
 (0)