Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Added support for gist comments
  • Loading branch information
greydnls committed Mar 28, 2015
commit 6bbe4d819b58aeb9e247745e47f4e483837fdc18
17 changes: 5 additions & 12 deletions lib/Github/Api/Gist/Comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,33 @@
use Github\Api\AbstractApi;

/**
*
* @link https://developer.github.com/v3/gists/comments/
* @author Kayla Daniels <[email protected]>
* @author Edoardo Rivello <edoardo.rivello at gmail dot com>
*/
class Comments extends AbstractApi
{
// GET /gists/:gist_id/comments
public function all($gist)
{
return $this->get('gists/'.rawurlencode($gist)."/comments");
return $this->get('gists/'.rawurlencode($gist).'/comments');
}

//GET /gists/:gist_id/comments/:id
public function show($gist, $comment)
{
return $this->get('gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment));
}

//POST /gists/:gist_id/comments
public function create($gist, $body)
{
return $this->post('gists/'.rawurlencode($gist)."/comments", array($body));
return $this->post('gists/'.rawurlencode($gist).'/comments', array($body));
}

//PATCH /gists/:gist_id/comments/:id
public function update($gist, $comment_id, $body)
{
return $this->patch('gists/'.rawurlencode($gist)."/comments/".rawurlencode($comment_id), array($body));
return $this->patch('gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment_id), array($body));
}

//DELETE /gists/:gist_id/comments/:id
public function remove($gist, $comment)
{
return $this->delete('gists/'.rawurlencode($gist)."/comments/".rawurlencode($comment));
return $this->delete('gists/'.rawurlencode($gist).'/comments/'.rawurlencode($comment));
}
}
}
3 changes: 1 addition & 2 deletions lib/Github/Api/Gists.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function unstar($id)
}

/**
* List an gists comments.
* Get a gist's comments.
*
* @link http://developer.github.com/v3/gists/comments/
*
Expand All @@ -85,5 +85,4 @@ public function comments()
{
return new Comments($this->client);
}

}
10 changes: 3 additions & 7 deletions test/Github/Tests/Api/Gist/CommentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class CommentsTest extends TestCase
/**
* @test
*/

// GET /gists/:gist_id/comments
public function shouldGetAllGistComments()
{
$expectedValue = array(array('comment1data'), array('comment2data'));
Expand Down Expand Up @@ -40,7 +38,6 @@ public function shouldShowGistComment()
$this->assertEquals($expectedValue, $api->show(123, 123));
}


/**
* @test
*/
Expand All @@ -51,13 +48,12 @@ public function shouldCreateGistComment()
$api = $this->getApiMock();
$api->expects($this->once())
->method('post')
->with('gists/123/comments', array("Test body"))
->with('gists/123/comments', array('Test body'))
->will($this->returnValue($expectedValue));

$this->assertEquals($expectedValue, $api->create('123', "Test body"));
$this->assertEquals($expectedValue, $api->create('123', 'Test body'));
}


/**
* @test
*/
Expand Down Expand Up @@ -95,4 +91,4 @@ protected function getApiClass()
{
return 'Github\Api\Gist\Comments';
}
}
}
2 changes: 1 addition & 1 deletion test/Github/Tests/Api/GistsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,4 @@ protected function getApiClass()
{
return 'Github\Api\Gists';
}
}
}