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
6 changes: 6 additions & 0 deletions doc/apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,9 @@ $client->api('apps')->addRepository($installationId, $repositoryId);
```php
$client->api('apps')->removeRepository($installationId, $repositoryId);
```

### Get authenticated app

```php
$authenticatedApp = $client->api('apps')->getAuthenticatedApp();
```
12 changes: 12 additions & 0 deletions lib/Github/Api/Apps.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,16 @@ public function removeRepository($installationId, $repositoryId)

return $this->delete('/installations/'.$installationId.'/repositories/'.$repositoryId);
}

/**
* Get the currently authenticated app.
*
* @link https://docs.github.com/en/rest/reference/apps#get-the-authenticated-app
*
* @return array
*/
public function getAuthenticatedApp()
{
return $this->get('/app');
}
}
17 changes: 17 additions & 0 deletions test/Github/Tests/Api/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@ public function shouldRemoveRepositoryToInstallation()
$api->removeRepository('1234', '5678');
}

/**
* @test
*/
public function shouldGetAuthenticatedApp()
{
$api = $this->getApiMock();

$result = ['authenticatedApp1'];

$api->expects($this->once())
->method('get')
->with('/app')
->willReturn($result);

$this->assertEquals($result, $api->getAuthenticatedApp());
}

/**
* @return string
*/
Expand Down