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; |
13
|
|
|
|
14
|
|
|
use Bitbucket\API; |
15
|
|
|
use Bitbucket\API\Repositories; |
16
|
|
|
use Psr\Http\Message\ResponseInterface; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Provides functionality for interacting with an issue tracker. |
20
|
|
|
* |
21
|
|
|
* @author Alexandru G. <[email protected]> |
22
|
|
|
*/ |
23
|
|
|
class Issues extends API\Api |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* GET a list of issues in a repository's tracker |
27
|
|
|
* |
28
|
|
|
* @access public |
29
|
|
|
* @param string $account The team or individual account owning the repository. |
30
|
|
|
* @param string $repo The repository identifier. |
31
|
|
|
* @param array $options Filtering parameters. |
32
|
|
|
* @return ResponseInterface |
33
|
|
|
* |
34
|
|
|
* @see https://confluence.atlassian.com/x/1w2mEQ |
35
|
|
|
*/ |
36
|
1 |
|
public function all($account, $repo, array $options = array()) |
37
|
|
|
{ |
38
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
39
|
1 |
|
sprintf('/repositories/%s/%s/issues', $account, $repo), |
40
|
1 |
|
$options |
41
|
|
|
); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* GET an individual issue |
46
|
|
|
* |
47
|
|
|
* @access public |
48
|
|
|
* @param string $account The team or individual account owning the repository. |
49
|
|
|
* @param string $repo The repository identifier. |
50
|
|
|
* @param int $issueID The issue identifier. |
51
|
|
|
* @return ResponseInterface |
52
|
|
|
*/ |
53
|
1 |
|
public function get($account, $repo, $issueID) |
54
|
|
|
{ |
55
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->get( |
56
|
1 |
|
sprintf('/repositories/%s/%s/issues/%d', $account, $repo, $issueID) |
57
|
|
|
); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* POST a new issue |
62
|
|
|
* |
63
|
|
|
* @access public |
64
|
|
|
* @param string $account The team or individual account owning the repository. |
65
|
|
|
* @param string $repo The repository identifier. |
66
|
|
|
* @param array $options Issue parameters |
67
|
|
|
* @return ResponseInterface |
68
|
|
|
* |
69
|
1 |
|
* @throws \InvalidArgumentException |
70
|
|
|
* |
71
|
1 |
|
* @see https://confluence.atlassian.com/display/BITBUCKET/issues+Resource#issuesResource-POSTanewissue |
72
|
1 |
|
*/ |
73
|
|
|
public function create($account, $repo, array $options = array()) |
74
|
|
|
{ |
75
|
|
|
if (!isset($options['title']) || !isset($options['content'])) { |
76
|
|
|
throw new \InvalidArgumentException( |
77
|
|
|
'Arguments: "title" and "content" are mandatory.' |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
return $this->getClient()->setApiVersion('2.0')->post( |
82
|
|
|
sprintf('/repositories/%s/%s/issues', $account, $repo), |
83
|
|
|
$options, |
84
|
|
|
['Content-Type' => 'application/json'] |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
3 |
|
* Update existing issue |
90
|
|
|
* |
91
|
3 |
|
* @access public |
92
|
2 |
|
* @param string $account The team or individual account owning the repository. |
93
|
2 |
|
* @param string $repo The repository identifier. |
94
|
|
|
* @param int $issueID The issue identifier. |
95
|
|
|
* @param array $options Issue parameters |
96
|
|
|
* @return ResponseInterface |
97
|
1 |
|
* |
98
|
1 |
|
* @see https://confluence.atlassian.com/display/BITBUCKET/issues+Resource#issuesResource-Updateanexistingissue |
99
|
1 |
|
*/ |
100
|
|
|
public function update($account, $repo, $issueID, array $options) |
101
|
|
|
{ |
102
|
|
|
return $this->getClient()->setApiVersion('2.0')->put( |
103
|
|
|
sprintf('/repositories/%s/%s/issues/%d', $account, $repo, $issueID), |
104
|
|
|
$options, |
105
|
|
|
['Content-Type' => 'application/json'] |
106
|
|
|
); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Delete issue |
111
|
|
|
* |
112
|
|
|
* @access public |
113
|
|
|
* @param string $account The team or individual account owning the repository. |
114
|
|
|
* @param string $repo The repository identifier. |
115
|
1 |
|
* @param int $issueID The issue identifier. |
116
|
|
|
* @return ResponseInterface |
117
|
1 |
|
*/ |
118
|
1 |
|
public function delete($account, $repo, $issueID) |
119
|
1 |
|
{ |
120
|
|
|
return $this->getClient()->setApiVersion('2.0')->delete( |
121
|
|
|
sprintf('/repositories/%s/%s/issues/%d', $account, $repo, $issueID) |
122
|
|
|
); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Get comments |
127
|
|
|
* |
128
|
|
|
* @access public |
129
|
|
|
* @return Repositories\Issues\Comments |
130
|
|
|
* |
131
|
|
|
* @throws \InvalidArgumentException |
132
|
1 |
|
* @codeCoverageIgnore |
133
|
|
|
*/ |
134
|
1 |
|
public function comments() |
135
|
1 |
|
{ |
136
|
|
|
return $this->api(Issues\Comments::class); |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
|