Skip to content

Commit bce8f22

Browse files
committed
Merge pull request #3 from Keanor/master
fixed incorrect json mapping && add timetracking entity
2 parents 59bcedf + c681cc8 commit bce8f22

File tree

5 files changed

+197
-29
lines changed

5 files changed

+197
-29
lines changed

src/Issue/Issue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Issue implements \JsonSerializable
2020
/* @var string */
2121
public $key;
2222

23-
/* @var IssueField */
23+
/** @var IssueField */
2424
public $fields;
2525

2626
public function jsonSerialize()

src/Issue/IssueField.php

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public function __construct($updateIssue = false)
1414
$this->versions = array();
1515

1616
$this->issuetype = new \JiraRestApi\Issue\IssueType();
17+
$this->timetracking = new \JiraRestApi\Issue\TimeTracking();
1718
}
1819
}
1920

@@ -45,17 +46,6 @@ public function setProjectId($id)
4546
return $this;
4647
}
4748

48-
public function setIssueType($name)
49-
{
50-
if (is_null($this->issuetype)) {
51-
$this->issuetype = new \JiraRestApi\Issue\IssueType();
52-
}
53-
54-
$this->issuetype->name = $name;
55-
56-
return $this;
57-
}
58-
5949
public function setSummary($summary)
6050
{
6151
$this->summary = $summary;
@@ -144,7 +134,7 @@ public function addLabel($label)
144134
/** @var string */
145135
//public $progress;
146136

147-
/** @var string */
137+
/** @var Timetracking */
148138
public $timetracking;
149139

150140
/** @var IssueType */
@@ -156,10 +146,10 @@ public function addLabel($label)
156146
/** @var Reporter */
157147
public $reporter;
158148

159-
/** @var DateTime */
149+
/** @var \DateTime */
160150
public $created;
161151

162-
/** @var DateTime */
152+
/** @var \DateTime */
163153
public $updated;
164154

165155
/** @var string */
@@ -168,48 +158,57 @@ public function addLabel($label)
168158
/** @var Priority */
169159
public $priority;
170160

171-
/** @var IssueStatus */
161+
/** @var object */
172162
public $status;
173163

174-
/** @var string */
164+
/** @var object[] */
175165
public $labels;
176166

177-
/** @var JiraRestApi\Project\Project */
167+
/** @var \JiraRestApi\Project\Project */
178168
public $project;
179169

180170
/** @var string */
181171
public $environment;
182172

183-
/** @var string */
173+
/** @var string[] */
184174
public $components;
185175

186176
/** @var Comments */
187177
public $comments;
188178

189-
/** @var string */
179+
/** @var object */
190180
public $votes;
191181

192-
/** @var string */
182+
/** @var object */
193183
public $resolution;
194184

195-
/** @var string */
185+
/** @var string[] */
196186
public $fixVersions;
197187

198188
/** @var Reporter */
199189
public $creator;
200190

201-
/** @var string */
191+
/** @var object */
202192
public $watches;
203193

204-
/** @var string */
194+
/** @var object */
205195
public $worklog;
206196

207197
/** @var Reporter */
208198
public $assignee;
209199

210-
/* @var VersionList[\JiraRestApi\Issue\Version] */
200+
/** @var \JiraRestApi\Issue\Version[] */
211201
public $versions;
212202

213-
/** @var AttachmentList[\JiraRestApi\Issue\Attachment] */
203+
/** @var \JiraRestApi\Issue\Attachment[] */
214204
public $attachments;
205+
206+
/** @var string */
207+
public $aggregatetimespent;
208+
209+
/** @var string */
210+
public $timeestimate;
211+
212+
/** @var string */
213+
public $aggregatetimeoriginalestimate;
215214
}

src/Issue/IssueService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public function transition($issueIdOrKey, $transition)
207207
* @param int $maxResults
208208
* @param array $fields
209209
*
210-
* @return object
210+
* @return IssueSearchResult
211211
*/
212212
public function search($jql, $startAt=0, $maxResults=15, $fields=[])
213213
{

src/Issue/TimeTracking.php

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: keanor
5+
* Date: 29.07.15
6+
* Time: 21:27
7+
*/
8+
namespace JiraRestApi\Issue;
9+
10+
/**
11+
* Class TimeTracking
12+
*
13+
* @package JiraRestApi\Issue
14+
*/
15+
class TimeTracking implements \JsonSerializable
16+
{
17+
/**
18+
* Original estimate
19+
*
20+
* @var string (ex 90m, 2h, 1d 2h 30m)
21+
*/
22+
public $originalEstimate;
23+
24+
/**
25+
* Remaining estimate
26+
*
27+
* @var string (ex 90m, 2h, 1d 2h 30m)
28+
*/
29+
public $remainingEstimate;
30+
31+
/**
32+
* Time spent
33+
*
34+
* @var string (ex 90m, 2h, 1d 2h 30m)
35+
*/
36+
public $timeSpent;
37+
38+
/**
39+
* Original estimate in seconds, generated in jira
40+
* for create/update issue set $this->originalEstimate
41+
*
42+
* @var int
43+
*/
44+
public $originalEstimateSeconds;
45+
46+
/**
47+
* Remaining estimate in seconds, generated in jira
48+
* for create/update issue set $this->remainingEstimate
49+
*
50+
* @var int
51+
*/
52+
public $remainingEstimateSeconds;
53+
54+
/**
55+
* Time spent in seconds, generated in jira
56+
* for create/update issue set $this->timeSpent
57+
*
58+
* @var int
59+
*/
60+
public $timeSpentSeconds;
61+
62+
/**
63+
* @return string
64+
*/
65+
public function getOriginalEstimate()
66+
{
67+
return $this->originalEstimate;
68+
}
69+
70+
/**
71+
* @param string $originalEstimate
72+
*/
73+
public function setOriginalEstimate($originalEstimate)
74+
{
75+
$this->originalEstimate = $originalEstimate;
76+
}
77+
78+
/**
79+
* @return string
80+
*/
81+
public function getRemainingEstimate()
82+
{
83+
return $this->remainingEstimate;
84+
}
85+
86+
/**
87+
* @param string $remainingEstimate
88+
*/
89+
public function setRemainingEstimate($remainingEstimate)
90+
{
91+
$this->remainingEstimate = $remainingEstimate;
92+
}
93+
94+
/**
95+
* @return string
96+
*/
97+
public function getTimeSpent()
98+
{
99+
return $this->timeSpent;
100+
}
101+
102+
/**
103+
* @param string $timeSpent
104+
*/
105+
public function setTimeSpent($timeSpent)
106+
{
107+
$this->timeSpent = $timeSpent;
108+
}
109+
110+
/**
111+
* @return int
112+
*/
113+
public function getOriginalEstimateSeconds()
114+
{
115+
return $this->originalEstimateSeconds;
116+
}
117+
118+
/**
119+
* @param int $originalEstimateSeconds
120+
*/
121+
public function setOriginalEstimateSeconds($originalEstimateSeconds)
122+
{
123+
$this->originalEstimateSeconds = $originalEstimateSeconds;
124+
}
125+
126+
/**
127+
* @return int
128+
*/
129+
public function getRemainingEstimateSeconds()
130+
{
131+
return $this->remainingEstimateSeconds;
132+
}
133+
134+
/**
135+
* @param int $remainingEstimateSeconds
136+
*/
137+
public function setRemainingEstimateSeconds($remainingEstimateSeconds)
138+
{
139+
$this->remainingEstimateSeconds = $remainingEstimateSeconds;
140+
}
141+
142+
/**
143+
* @return int
144+
*/
145+
public function getTimeSpentSeconds()
146+
{
147+
return $this->timeSpentSeconds;
148+
}
149+
150+
/**
151+
* @param int $timeSpentSeconds
152+
*/
153+
public function setTimeSpentSeconds($timeSpentSeconds)
154+
{
155+
$this->timeSpentSeconds = $timeSpentSeconds;
156+
}
157+
158+
/**
159+
* (PHP 5 &gt;= 5.4.0)<br/>
160+
* Specify data which should be serialized to JSON
161+
*
162+
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
163+
* @return mixed data which can be serialized by <b>json_encode</b>,
164+
* which is a value of any type other than a resource.
165+
*/
166+
function jsonSerialize()
167+
{
168+
return array_filter(get_object_vars($this));
169+
}
170+
}

src/JiraClient.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,12 @@ protected function filterNullVariable($haystack)
8484

8585
public function __construct($path = '.')
8686
{
87-
$dotenv = Dotenv::load($path);
87+
Dotenv::load($path);
8888

8989
// not available in dotenv 1.1
9090
// $dotenv->required(['JIRA_HOST', 'JIRA_USER', 'JIRA_PASS']);
9191

9292
$this->json_mapper = new \JsonMapper();
93-
$this->json_mapper->bExceptionOnUndefinedProperty = true;
9493

9594
$this->host = $this->env('JIRA_HOST');
9695
$this->username = $this->env('JIRA_USER');

0 commit comments

Comments
 (0)