Skip to content

Commit 72cf7fd

Browse files
authored
Merge pull request #155 from alvar0hurtad0/feature/154/CreatePrioritiesService
Create priorities Service.
2 parents ace84ba + 89afc19 commit 72cf7fd

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

src/Priority/Priority.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
3+
namespace JiraRestApi\Priority;
4+
5+
use JiraRestApi\ClassSerialize;
6+
7+
/**
8+
* Description of Priority.
9+
*/
10+
class Priority implements \JsonSerializable
11+
{
12+
use ClassSerialize;
13+
14+
/**
15+
* uri which was hit.
16+
*
17+
* @var string
18+
*/
19+
public $self;
20+
21+
/**
22+
* @var string
23+
*/
24+
public $statusColor;
25+
26+
/**
27+
* @var string
28+
*/
29+
public $description;
30+
31+
/**
32+
* @var string
33+
*/
34+
public $iconUrl;
35+
36+
/**
37+
* @var string
38+
*/
39+
public $name;
40+
41+
/**
42+
* @var string
43+
*/
44+
public $id;
45+
46+
public function jsonSerialize()
47+
{
48+
return array_filter(get_object_vars($this));
49+
}
50+
51+
/**
52+
* Priority constructor.
53+
*
54+
* @param array $array priority info array.
55+
*/
56+
public function __construct($array = [])
57+
{
58+
foreach ($array as $key => $value) {
59+
$this->{$key} = $value;
60+
}
61+
}
62+
}

src/Priority/PriorityService.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
namespace JiraRestApi\Priority;
4+
5+
/**
6+
* Class to query priority.
7+
*/
8+
class PriorityService extends \JiraRestApi\JiraClient
9+
{
10+
private $uri = '/priority';
11+
12+
/**
13+
* Function to get all priorities.
14+
*
15+
* @throws \JiraRestApi\JiraException
16+
* @throws \JsonMapper_Exception
17+
*
18+
* @return Priority|object Priority class
19+
*/
20+
public function getAll()
21+
{
22+
$queryParam = '?'.http_build_query();
23+
24+
$ret = $this->exec($this->uri, null);
25+
26+
$this->log->addInfo("Result=\n".$ret);
27+
28+
$priorityData = json_decode($ret);
29+
$priorities = [];
30+
31+
foreach ($priorityData as $priority) {
32+
$priorities[] = $this->json_mapper->map($priority, new Priority());
33+
}
34+
35+
return $priorities;
36+
}
37+
}

0 commit comments

Comments
 (0)