Skip to content
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
14 changes: 13 additions & 1 deletion doc/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@ $token = $client->api('integrations')->createInstallationToken(123, 456);

Find all installations for the authenticated integration.
```php
Installations = $client->api('integrations')->findInstallations();
$installations = $client->api('integrations')->findInstallations();
```

### Find installations for a user

```php
$installations = $client->api('current_user')->installations();
```

### List repositories
Expand All @@ -28,6 +34,12 @@ List repositories that are accessible to the authenticated installation.
$repositories = $client->api('integrations')->listRepositories(456);
```

### List repositories for a given installation and user

```
$repositories = $client->api('current_user')->repositoriesByInstallation(456);
```

### Add repository to installation
Add a single repository to an installation.
```php
Expand Down
11 changes: 11 additions & 0 deletions lib/Github/Api/CurrentUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,4 +178,15 @@ public function installations(array $params = array())
{
return $this->get('/user/installations', array_merge(array('page' => 1), $params));
}

/**
* @link https://developer.github.com/v3/integrations/installations/#list-repositories-accessible-to-the-user-for-an-installation
*
* @param string $installationId the ID of the Installation
* @param array $params
*/
public function repositoriesByInstallation($installationId, array $params = array())
{
return $this->get(sprintf('/user/installations/%s/repositories', $installationId), array_merge(array('page' => 1), $params));
}
}
18 changes: 17 additions & 1 deletion test/Github/Tests/Api/CurrentUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function shouldGetWatchedRepositories()
/**
* @test
*/
public function shouldGetInstallationsForUser()
public function shouldGetInstallations()
{
$result = ['installation1', 'installation2'];

Expand All @@ -100,6 +100,22 @@ public function shouldGetInstallationsForUser()
$this->assertEquals($result, $api->installations());
}

/**
* @test
*/
public function shouldGetRepositoriesByInstallation()
{
$expectedArray = array(array('id' => 1, 'name' => 'l3l0repo'));

$api = $this->getApiMock();
$api->expects($this->once())
->method('get')
->with('/user/installations/42/repositories', array('page' => 1))
->will($this->returnValue($expectedArray));

$this->assertEquals($expectedArray, $api->repositoriesByInstallation(42));
}

/**
* @test
*/
Expand Down