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 Buzz\Message\MessageInterface; |
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 MessageInterface |
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 MessageInterface |
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 MessageInterface |
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
|
|
|
); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Update existing issue |
89
|
3 |
|
* |
90
|
|
|
* @access public |
91
|
3 |
|
* @param string $account The team or individual account owning the repository. |
92
|
2 |
|
* @param string $repo The repository identifier. |
93
|
2 |
|
* @param int $issueID The issue identifier. |
94
|
|
|
* @param array $options Issue parameters |
95
|
|
|
* @return MessageInterface |
96
|
|
|
* |
97
|
1 |
|
* @see https://confluence.atlassian.com/display/BITBUCKET/issues+Resource#issuesResource-Updateanexistingissue |
98
|
1 |
|
*/ |
99
|
1 |
|
public function update($account, $repo, $issueID, array $options) |
100
|
|
|
{ |
101
|
|
|
return $this->getClient()->setApiVersion('2.0')->put( |
102
|
|
|
sprintf('repositories/%s/%s/issues/%d', $account, $repo, $issueID), |
103
|
|
|
$options |
104
|
|
|
); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* Delete issue |
109
|
|
|
* |
110
|
|
|
* @access public |
111
|
|
|
* @param string $account The team or individual account owning the repository. |
112
|
|
|
* @param string $repo The repository identifier. |
113
|
|
|
* @param int $issueID The issue identifier. |
114
|
|
|
* @return MessageInterface |
115
|
1 |
|
*/ |
116
|
|
|
public function delete($account, $repo, $issueID) |
117
|
1 |
|
{ |
118
|
1 |
|
return $this->getClient()->setApiVersion('2.0')->delete( |
119
|
1 |
|
sprintf('repositories/%s/%s/issues/%d', $account, $repo, $issueID) |
120
|
|
|
); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Get comments |
125
|
|
|
* |
126
|
|
|
* @access public |
127
|
|
|
* @return Repositories\Issues\Comments |
128
|
|
|
* |
129
|
|
|
* @throws \InvalidArgumentException |
130
|
|
|
* @codeCoverageIgnore |
131
|
|
|
*/ |
132
|
1 |
|
public function comments() |
133
|
|
|
{ |
134
|
1 |
|
return $this->api('Repositories\\Issues\\Comments'); |
135
|
1 |
|
} |
136
|
|
|
} |
137
|
|
|
|