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