Skip to content

Commit

Permalink
feature KnpLabs#1041 Feature get authenticated app (kdaniel95)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 3.4.x-dev branch.

Discussion
----------

https://docs.github.com/en/rest/reference/apps#get-the-authenticated-app

Create endpoint to get authenticated app. 

Commits
-------

090a967 Feat: Get authenticated app
ce3d0fd Fix endpoint doc
d666ddb Fix StyleCI issues
bb14d05 Merge remote-tracking branch 'origin/feature-get-authenticated-app' into feature-get-authenticated-app
  • Loading branch information
kdaniel95 authored Dec 3, 2021
1 parent 7ad600d commit 6508138
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
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

0 comments on commit 6508138

Please sign in to comment.