Skip to content

Commit 6508138

Browse files
authored
feature KnpLabs#1041 Feature get authenticated app (kdaniel95)
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
1 parent 7ad600d commit 6508138

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed

doc/apps.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,9 @@ $client->api('apps')->addRepository($installationId, $repositoryId);
4949
```php
5050
$client->api('apps')->removeRepository($installationId, $repositoryId);
5151
```
52+
53+
### Get authenticated app
54+
55+
```php
56+
$authenticatedApp = $client->api('apps')->getAuthenticatedApp();
57+
```

lib/Github/Api/Apps.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,16 @@ public function removeRepository($installationId, $repositoryId)
186186

187187
return $this->delete('/installations/'.$installationId.'/repositories/'.$repositoryId);
188188
}
189+
190+
/**
191+
* Get the currently authenticated app.
192+
*
193+
* @link https://docs.github.com/en/rest/reference/apps#get-the-authenticated-app
194+
*
195+
* @return array
196+
*/
197+
public function getAuthenticatedApp()
198+
{
199+
return $this->get('/app');
200+
}
189201
}

test/Github/Tests/Api/AppTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,23 @@ public function shouldRemoveRepositoryToInstallation()
160160
$api->removeRepository('1234', '5678');
161161
}
162162

163+
/**
164+
* @test
165+
*/
166+
public function shouldGetAuthenticatedApp()
167+
{
168+
$api = $this->getApiMock();
169+
170+
$result = ['authenticatedApp1'];
171+
172+
$api->expects($this->once())
173+
->method('get')
174+
->with('/app')
175+
->willReturn($result);
176+
177+
$this->assertEquals($result, $api->getAuthenticatedApp());
178+
}
179+
163180
/**
164181
* @return string
165182
*/

0 commit comments

Comments
 (0)