|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the bitbucket-api package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Alexandru G. <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Bitbucket\API\Repositories\PullRequests; |
|
13
|
|
|
|
|
14
|
|
|
use Bitbucket\API; |
|
15
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* Manage the comments on pull requests. |
|
19
|
|
|
* |
|
20
|
|
|
* @author Alexandru G. <[email protected]> |
|
21
|
|
|
*/ |
|
22
|
|
|
class Comments extends API\Api |
|
23
|
|
|
{ |
|
24
|
|
|
/** |
|
25
|
|
|
* Get a list of a pull request comments |
|
26
|
|
|
* |
|
27
|
|
|
* @access public |
|
28
|
|
|
* @param string $account The team or individual account owning the repository. |
|
29
|
|
|
* @param string $repo The repository identifier. |
|
30
|
|
|
* @param int $id ID of the pull request |
|
31
|
|
|
* @return ResponseInterface |
|
32
|
|
|
*/ |
|
33
|
1 |
|
public function all($account, $repo, $id) |
|
34
|
|
|
{ |
|
35
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
|
36
|
1 |
|
sprintf('/repositories/%s/%s/pullrequests/%d/comments', $account, $repo, $id) |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Get an individual pull request comment |
|
42
|
|
|
* |
|
43
|
|
|
* @access public |
|
44
|
|
|
* @param string $account The team or individual account owning the repository. |
|
45
|
|
|
* @param string $repo The repository identifier. |
|
46
|
|
|
* @param int $requestID An integer representing an id for the request. |
|
47
|
|
|
* @param int $commentID The comment identifier. |
|
48
|
|
|
* @return ResponseInterface |
|
49
|
|
|
*/ |
|
50
|
1 |
|
public function get($account, $repo, $requestID, $commentID) |
|
51
|
|
|
{ |
|
52
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
|
53
|
1 |
|
sprintf('/repositories/%s/%s/pullrequests/%d/comments/%d', $account, $repo, $requestID, $commentID) |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Add a new comment |
|
59
|
|
|
* |
|
60
|
|
|
* @access public |
|
61
|
|
|
* @param string $account The team or individual account owning the repository. |
|
62
|
|
|
* @param string $repo The repository identifier. |
|
63
|
|
|
* @param int $requestID An integer representing an id for the request. |
|
64
|
|
|
* @param string $content The comment. |
|
65
|
|
|
* @return ResponseInterface |
|
66
|
|
|
*/ |
|
67
|
1 |
|
public function create($account, $repo, $requestID, $content) |
|
68
|
|
|
{ |
|
69
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->post( |
|
70
|
1 |
|
sprintf('/repositories/%s/%s/pullrequests/%d/comments', $account, $repo, $requestID), |
|
71
|
1 |
|
json_encode(array('content' => array('raw' => $content))), |
|
72
|
1 |
|
array('Content-Type' => 'application/json') |
|
73
|
|
|
); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Update an existing comment |
|
78
|
|
|
* |
|
79
|
|
|
* @access public |
|
80
|
|
|
* @param string $account The team or individual account owning the repository. |
|
81
|
|
|
* @param string $repo The repository identifier. |
|
82
|
|
|
* @param int $requestID An integer representing an id for the request. |
|
83
|
|
|
* @param string $content The comment. |
|
84
|
|
|
* @param int $commentID The comment identifier. |
|
85
|
|
|
* @return ResponseInterface |
|
86
|
|
|
*/ |
|
87
|
1 |
|
public function update($account, $repo, $requestID, $commentID, $content) |
|
88
|
|
|
{ |
|
89
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->put( |
|
90
|
1 |
|
sprintf('/repositories/%s/%s/pullrequests/%d/comments/%d', $account, $repo, $requestID, $commentID), |
|
91
|
1 |
|
json_encode(array('content' => array('raw' => $content))), |
|
92
|
1 |
|
array('Content-Type' => 'application/json') |
|
93
|
|
|
); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Delete a pull request comment |
|
98
|
|
|
* |
|
99
|
|
|
* @access public |
|
100
|
|
|
* @param string $account The team or individual account owning the repository. |
|
101
|
|
|
* @param string $repo The repository identifier. |
|
102
|
|
|
* @param int $requestID An integer representing an id for the request. |
|
103
|
|
|
* @param int $commentID The comment identifier. |
|
104
|
|
|
* @return ResponseInterface |
|
105
|
|
|
*/ |
|
106
|
1 |
|
public function delete($account, $repo, $requestID, $commentID) |
|
107
|
|
|
{ |
|
108
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->delete( |
|
109
|
1 |
|
sprintf('/repositories/%s/%s/pullrequests/%d/comments/%d', $account, $repo, $requestID, $commentID) |
|
110
|
|
|
); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|