1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace JiraRestApi\Request; |
4
|
|
|
|
5
|
|
|
use JiraRestApi\Configuration\ConfigurationInterface; |
6
|
|
|
use JiraRestApi\JiraException; |
7
|
|
|
use JiraRestApi\ServiceDeskTrait; |
8
|
|
|
use Psr\Log\LoggerInterface; |
9
|
|
|
|
10
|
|
|
class RequestService extends \JiraRestApi\JiraClient |
11
|
|
|
{ |
12
|
|
|
use ServiceDeskTrait; |
13
|
|
|
|
14
|
|
|
private $uri = '/request'; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Constructor. |
18
|
|
|
* |
19
|
|
|
* @param ConfigurationInterface $configuration |
20
|
|
|
* @param LoggerInterface $logger |
21
|
|
|
* @param string $path |
22
|
|
|
* |
23
|
|
|
* @throws JiraException |
24
|
|
|
* @throws \Exception |
25
|
|
|
*/ |
26
|
|
|
public function __construct(ConfigurationInterface $configuration = null, LoggerInterface $logger = null, $path = './') |
27
|
|
|
{ |
28
|
|
|
parent::__construct($configuration, $logger, $path); |
29
|
|
|
$this->setupAPIUri(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* Add the given comment to the specified request based on the provided $issueIdOrKey value. Returns a new |
34
|
|
|
* RequestComment with the response. |
35
|
|
|
* |
36
|
|
|
* @param string|int $issueIdOrKey |
37
|
|
|
* @param RequestComment $requestComment |
38
|
|
|
* |
39
|
|
|
* @throws JiraException |
40
|
|
|
* @throws \JsonMapper_Exception |
41
|
|
|
* |
42
|
|
|
* @return RequestComment |
43
|
|
|
*/ |
44
|
|
|
public function addComment($issueIdOrKey, RequestComment $requestComment): RequestComment |
45
|
|
|
{ |
46
|
|
|
$this->log->info("addComment=\n"); |
47
|
|
|
|
48
|
|
|
if (empty($requestComment->body)) { |
49
|
|
|
throw new JiraException('comment param must be an instance of RequestComment and have body text.'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$data = json_encode($requestComment); |
53
|
|
|
|
54
|
|
|
$ret = $this->exec($this->uri."/$issueIdOrKey/comment", $data); |
55
|
|
|
|
56
|
|
|
$this->log->debug('add comment result='.var_export($ret, true)); |
57
|
|
|
$requestComment = $this->json_mapper->map( |
58
|
|
|
json_decode($ret), |
|
|
|
|
59
|
|
|
new RequestComment() |
60
|
|
|
); |
61
|
|
|
|
62
|
|
|
return $requestComment; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|