|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JiraRestApi\Board; |
|
4
|
|
|
|
|
5
|
|
|
use JiraRestApi\AgileApiTrait; |
|
6
|
|
|
use JiraRestApi\Configuration\ConfigurationInterface; |
|
7
|
|
|
use JiraRestApi\Epic\Epic; |
|
8
|
|
|
use JiraRestApi\Issue\AgileIssue; |
|
9
|
|
|
use JiraRestApi\Sprint\Sprint; |
|
10
|
|
|
use Psr\Log\LoggerInterface; |
|
11
|
|
|
|
|
12
|
|
|
class BoardService extends \JiraRestApi\JiraClient |
|
13
|
|
|
{ |
|
14
|
|
|
use AgileApiTrait; |
|
15
|
|
|
|
|
16
|
|
|
private $uri = '/board'; |
|
17
|
|
|
|
|
18
|
|
|
public function __construct(ConfigurationInterface $configuration = null, LoggerInterface $logger = null, $path = './') |
|
19
|
|
|
{ |
|
20
|
|
|
parent::__construct($configuration, $logger, $path); |
|
21
|
|
|
$this->setupAPIUri(); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* get all boards list. |
|
26
|
|
|
* |
|
27
|
|
|
* @param array $paramArray |
|
28
|
|
|
* |
|
29
|
|
|
* @throws \JiraRestApi\JiraException |
|
30
|
|
|
* |
|
31
|
|
|
* @return \ArrayObject|Board[]|null array of Board class |
|
32
|
|
|
*/ |
|
33
|
|
|
public function getBoardList($paramArray = []): ?\ArrayObject |
|
34
|
|
|
{ |
|
35
|
|
|
$json = $this->exec($this->uri.$this->toHttpQueryParameter($paramArray), null); |
|
36
|
|
|
|
|
37
|
|
|
try { |
|
38
|
|
|
return $this->json_mapper->mapArray( |
|
39
|
|
|
json_decode($json, false, 512, $this->getJsonOptions())->values, |
|
40
|
|
|
new \ArrayObject(), |
|
41
|
|
|
Board::class |
|
42
|
|
|
); |
|
43
|
|
|
} catch (\JsonException $exception) { |
|
44
|
|
|
$this->log->error("Response cannot be decoded from json\nException: {$exception->getMessage()}"); |
|
45
|
|
|
|
|
46
|
|
|
return null; |
|
47
|
|
|
} |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function getBoard($id, $paramArray = []): ?Board |
|
51
|
|
|
{ |
|
52
|
|
|
$json = $this->exec($this->uri.'/'.$id.$this->toHttpQueryParameter($paramArray), null); |
|
53
|
|
|
|
|
54
|
|
|
try { |
|
55
|
|
|
return $this->json_mapper->map( |
|
56
|
|
|
json_decode($json, false, 512, $this->getJsonOptions()), |
|
57
|
|
|
new Board() |
|
58
|
|
|
); |
|
59
|
|
|
} catch (\JsonException $exception) { |
|
60
|
|
|
$this->log->error("Response cannot be decoded from json\nException: {$exception->getMessage()}"); |
|
61
|
|
|
|
|
62
|
|
|
return null; |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @return \ArrayObject|AgileIssue[]|null |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getBoardIssues($id, $paramArray = []): ?\ArrayObject |
|
70
|
|
|
{ |
|
71
|
|
|
$json = $this->exec($this->uri.'/'.$id.'/issue'.$this->toHttpQueryParameter($paramArray), null); |
|
72
|
|
|
|
|
73
|
|
|
try { |
|
74
|
|
|
return $this->json_mapper->mapArray( |
|
75
|
|
|
json_decode($json, false, 512, $this->getJsonOptions())->issues, |
|
76
|
|
|
new \ArrayObject(), |
|
77
|
|
|
AgileIssue::class |
|
78
|
|
|
); |
|
79
|
|
|
} catch (\JsonException $exception) { |
|
80
|
|
|
$this->log->error("Response cannot be decoded from json\nException: {$exception->getMessage()}"); |
|
81
|
|
|
|
|
82
|
|
|
return null; |
|
83
|
|
|
} |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @return \ArrayObject|AgileIssue[]|null |
|
88
|
|
|
*/ |
|
89
|
|
|
public function getBoardBacklogIssues($id, array $paramArray = []): ?\ArrayObject |
|
90
|
|
|
{ |
|
91
|
|
|
$json = $this->exec($this->uri.'/'.$id.'/backlog'.$this->toHttpQueryParameter($paramArray), null); |
|
92
|
|
|
|
|
93
|
|
|
try { |
|
94
|
|
|
return $this->json_mapper->mapArray( |
|
95
|
|
|
json_decode($json, false, 512, JSON_THROW_ON_ERROR)->issues, |
|
96
|
|
|
new \ArrayObject(), |
|
97
|
|
|
AgileIssue::class |
|
98
|
|
|
); |
|
99
|
|
|
} catch (\JsonException $exception) { |
|
100
|
|
|
$this->log->error("Response cannot be decoded from json\nException: {$exception->getMessage()}"); |
|
101
|
|
|
|
|
102
|
|
|
return null; |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return \ArrayObject|Sprint[]|null |
|
108
|
|
|
*/ |
|
109
|
|
|
public function getBoardSprints($boardId, $paramArray = []): ?\ArrayObject |
|
110
|
|
|
{ |
|
111
|
|
|
$json = $this->exec($this->uri.'/'.$boardId.'/sprint'.$this->toHttpQueryParameter($paramArray), null); |
|
112
|
|
|
|
|
113
|
|
|
try { |
|
114
|
|
|
return $this->json_mapper->mapArray( |
|
115
|
|
|
json_decode($json, false, 512, $this->getJsonOptions())->values, |
|
116
|
|
|
new \ArrayObject(), |
|
117
|
|
|
Sprint::class |
|
118
|
|
|
); |
|
119
|
|
|
} catch (\JsonException $exception) { |
|
120
|
|
|
$this->log->error("Response cannot be decoded from json\nException: {$exception->getMessage()}"); |
|
121
|
|
|
|
|
122
|
|
|
return null; |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
/** |
|
127
|
|
|
* @return \ArrayObject|Epic[]|null |
|
128
|
|
|
*/ |
|
129
|
|
|
public function getBoardEpics($boardId, $paramArray = []): ?\ArrayObject |
|
130
|
|
|
{ |
|
131
|
|
|
$json = $this->exec($this->uri.'/'.$boardId.'/epic'.$this->toHttpQueryParameter($paramArray), null); |
|
132
|
|
|
|
|
133
|
|
|
try { |
|
134
|
|
|
return $this->json_mapper->mapArray( |
|
135
|
|
|
json_decode($json, false, 512, $this->getJsonOptions())->values, |
|
136
|
|
|
new \ArrayObject(), |
|
137
|
|
|
Epic::class |
|
138
|
|
|
); |
|
139
|
|
|
} catch (\JsonException $exception) { |
|
140
|
|
|
$this->log->error("Response cannot be decoded from json\nException: {$exception->getMessage()}"); |
|
141
|
|
|
|
|
142
|
|
|
return null; |
|
143
|
|
|
} |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|