Skip to content

Commit 090a967

Browse files
committed
Feat: Get authenticated app
1 parent de2f278 commit 090a967

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-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+
$client->api('apps')->getAuthenticatedApp();
57+
```

lib/Github/Api/Apps.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,15 @@ 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+
return $this->get('/app');
199+
}
189200
}

test/Github/Tests/Api/AppTest.php

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

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

0 commit comments

Comments
 (0)