Skip to content

Commit 325b315

Browse files
authored
Merge pull request #803 from acrobat/gist-missing-endpoints
Missing gist revision api endpoint
2 parents d189dbd + f800ad3 commit 325b315

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

doc/gists.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ $gists = $github->api('gists')->all();
3737
$gist = $github->api('gists')->show(1);
3838
```
3939

40+
#### Get a specific revision of a gist
41+
42+
```php
43+
$gist = $github->api('gists')->show(1, 'd189dbd4c5d96442db74ebcb62bb38e661a0c8ce');
44+
```
45+
4046
#### Get commits for a single gist
4147

4248
```php

lib/Github/Api/Gists.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ public function show($number)
5151
return $this->get('/gists/'.rawurlencode($number));
5252
}
5353

54+
/**
55+
* Get a specific revision of a gist.
56+
*
57+
* @param int $number
58+
* @param string $sha
59+
*
60+
* @link https://developer.github.com/v3/gists/#get-a-specific-revision-of-a-gist
61+
*
62+
* @return array
63+
*/
64+
public function revision($number, $sha)
65+
{
66+
return $this->get('/gists/'.rawurlencode($number).'/'.rawurlencode($sha));
67+
}
68+
5469
public function create(array $params)
5570
{
5671
if (!isset($params['files']) || (!is_array($params['files']) || 0 === count($params['files']))) {

test/Github/Tests/Api/GistsTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ public function shouldShowGist()
5252
$this->assertEquals($expectedArray, $api->show(123));
5353
}
5454

55+
/**
56+
* @test
57+
*/
58+
public function shouldShowGistWithSpecificReference()
59+
{
60+
$expectedArray = ['id' => '123', 'sha' => 'd189dbd4c5d96442db74ebcb62bb38e661a0c8ce'];
61+
62+
$api = $this->getApiMock();
63+
$api->expects($this->once())
64+
->method('get')
65+
->with('/gists/123/d189dbd4c5d96442db74ebcb62bb38e661a0c8ce')
66+
->will($this->returnValue($expectedArray));
67+
68+
$this->assertEquals($expectedArray, $api->revision(123, 'd189dbd4c5d96442db74ebcb62bb38e661a0c8ce'));
69+
}
70+
5571
/**
5672
* @test
5773
*/

0 commit comments

Comments
 (0)