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\Issues; |
13
|
|
|
|
14
|
|
|
use Bitbucket\API; |
15
|
|
|
use Psr\Http\Message\ResponseInterface; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @author Alexandru G. <[email protected]> |
19
|
|
|
*/ |
20
|
|
|
class Comments extends API\Api |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Get all comments for specified issue |
24
|
|
|
* |
25
|
|
|
* Comments are returned in DESC order by posted date. |
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 $issueID The issue identifier. |
31
|
|
|
* @return ResponseInterface |
32
|
|
|
*/ |
33
|
1 |
|
public function all($account, $repo, $issueID) |
34
|
|
|
{ |
35
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
36
|
1 |
|
sprintf('/repositories/%s/%s/issues/%d/comments', $account, $repo, $issueID) |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Get an individual comment for specified issue |
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 $issueID The issue identifier. |
47
|
|
|
* @param int $commentID The comment identifier. |
48
|
|
|
* @return ResponseInterface |
49
|
|
|
*/ |
50
|
1 |
|
public function get($account, $repo, $issueID, $commentID) |
51
|
|
|
{ |
52
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
53
|
1 |
|
sprintf('/repositories/%s/%s/issues/%d/comments/%d', $account, $repo, $issueID, $commentID) |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Add a new comment to specified issue |
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 $issueID The issue identifier. |
64
|
|
|
* @param array $content The comment. |
65
|
|
|
* @return ResponseInterface |
66
|
|
|
*/ |
67
|
1 |
|
public function create($account, $repo, $issueID, $content) |
68
|
|
|
{ |
69
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->post( |
70
|
1 |
|
sprintf('/repositories/%s/%s/issues/%d/comments', $account, $repo, $issueID), |
71
|
1 |
|
['content' => $content], |
72
|
|
|
['Content-Type' => 'application/json'] |
73
|
|
|
); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Update an existing comment to specified issue |
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 $issueID The issue identifier. |
83
|
|
|
* @param array $content The comment. |
84
|
|
|
* @param int $commentID The comment identifier. |
85
|
|
|
* @return ResponseInterface |
86
|
1 |
|
*/ |
87
|
|
|
public function update($account, $repo, $issueID, $commentID, $content) |
88
|
1 |
|
{ |
89
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->put( |
90
|
1 |
|
sprintf('/repositories/%s/%s/issues/%d/comments/%d', $account, $repo, $issueID, $commentID), |
91
|
|
|
['content' => $content], |
92
|
|
|
['Content-Type' => 'application/json'] |
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
|