From 1502a5adb6eb1f1476dbf1dd9a77a148f83af5c9 Mon Sep 17 00:00:00 2001 From: aa Date: Mon, 1 May 2017 17:28:06 +0200 Subject: [PATCH 1/2] Add support for pagination and parameters to review comments API. --- lib/Github/Api/PullRequest/Comments.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Github/Api/PullRequest/Comments.php b/lib/Github/Api/PullRequest/Comments.php index 161c629909e..306939182cc 100644 --- a/lib/Github/Api/PullRequest/Comments.php +++ b/lib/Github/Api/PullRequest/Comments.php @@ -38,13 +38,18 @@ public function configure($bodyType = null, $apiVersion = null) return $this; } - public function all($username, $repository, $pullRequest = null) + public function all($username, $repository, $pullRequest = null, array $params = []) { if (null !== $pullRequest) { return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($pullRequest).'/comments'); } - return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments'); + $parameters = array_merge([ + 'page' => 1, + 'per_page' => 30 + ], $params); + + return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments', $parameters); } public function show($username, $repository, $comment) From e2c19d9592a7a151e143b0425be3f3a18f7a4d72 Mon Sep 17 00:00:00 2001 From: aa Date: Tue, 2 May 2017 23:01:07 +0200 Subject: [PATCH 2/2] Add doc blocks and links. --- lib/Github/Api/PullRequest/Comments.php | 64 +++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/lib/Github/Api/PullRequest/Comments.php b/lib/Github/Api/PullRequest/Comments.php index 306939182cc..18679ca133e 100644 --- a/lib/Github/Api/PullRequest/Comments.php +++ b/lib/Github/Api/PullRequest/Comments.php @@ -38,6 +38,20 @@ public function configure($bodyType = null, $apiVersion = null) return $this; } + /** + * Get a listing of a pull request's comments by the username, repository and pull request number + * or all repository comments by the username and repository. + * + * @link https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request + * @link https://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository + * + * @param string $username the username + * @param string $repository the repository + * @param int|null $pullRequest the pull request number + * @param array $params a list of extra parameters. + * + * @return array + */ public function all($username, $repository, $pullRequest = null, array $params = []) { if (null !== $pullRequest) { @@ -52,11 +66,36 @@ public function all($username, $repository, $pullRequest = null, array $params = return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments', $parameters); } + /** + * Get a single pull request comment by the username, repository and comment id. + * + * @link https://developer.github.com/v3/pulls/comments/#get-a-single-comment + * + * @param string $username the username + * @param string $repository the repository + * @param int $comment the comment id + * + * @return array + */ public function show($username, $repository, $comment) { return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments/'.rawurlencode($comment)); } + /** + * Create a pull request comment by the username, repository and pull request number. + * + * @link https://developer.github.com/v3/pulls/comments/#create-a-comment + * + * @param string $username the username + * @param string $repository the repository + * @param int $pullRequest the pull request number + * @param array $params a list of extra parameters. + * + * @throws MissingArgumentException + * + * @return array + */ public function create($username, $repository, $pullRequest, array $params) { if (!isset($params['body'])) { @@ -71,6 +110,20 @@ public function create($username, $repository, $pullRequest, array $params) return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/'.rawurlencode($pullRequest).'/comments', $params); } + /** + * Update a pull request comment by the username, repository and comment id. + * + * @link https://developer.github.com/v3/pulls/comments/#edit-a-comment + * + * @param string $username the username + * @param string $repository the repository + * @param int $comment the comment id + * @param array $params a list of extra parameters. + * + * @throws MissingArgumentException + * + * @return array + */ public function update($username, $repository, $comment, array $params) { if (!isset($params['body'])) { @@ -80,6 +133,17 @@ public function update($username, $repository, $comment, array $params) return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments/'.rawurlencode($comment), $params); } + /** + * Delete a pull request comment by the username, repository and comment id. + * + * @link https://developer.github.com/v3/pulls/comments/#delete-a-comment + * + * @param string $username the username + * @param string $repository the repository + * @param int $comment the comment id + * + * @return string + */ public function remove($username, $repository, $comment) { return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/pulls/comments/'.rawurlencode($comment));