Skip to content

Commit ba93204

Browse files
committed
Merge pull request #15 from vumik/feature/worklog
Feature/worklog
2 parents 6a274a8 + 570d6c4 commit ba93204

File tree

4 files changed

+140
-7
lines changed

4 files changed

+140
-7
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ copy .env.example file to .env on your project root.
5454
- [Perform a transition on an issue](#perform-a-transition-on-an-issue)
5555
- [Perform an advanced search, using the JQL](#perform-an-advanced-search)
5656
- [Issue time tracking](#issue-time-tracking)
57+
- [Issue worklog](#issue-worklog)
5758

5859
## Get Project Info
5960

@@ -328,6 +329,28 @@ try {
328329
?>
329330
````
330331

332+
## Issue worklog
333+
334+
````php
335+
<?php
336+
require 'vendor/autoload.php';
337+
338+
use JiraRestApi\Issue\IssueService;
339+
340+
$issueKey = 'TEST-961';
341+
342+
try {
343+
$issueService = new IssueService();
344+
345+
// get issue's worklog
346+
$worklogs = $issueService->getWorklog($issueKey)->getWorklogs();
347+
var_dump($ret);
348+
} catch (JIRAException $e) {
349+
$this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
350+
}
351+
?>
352+
````
353+
331354
# License
332355

333356
Apache V2 License

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "lesstif/php-jira-rest-client",
33
"description": "JIRA REST API Client for PHP Users.",
44
"type": "library",
5-
"keywords": ["jira", "jira-php", "jira-rest"],
5+
"keywords": ["jira", "rest", "jira-php", "jira-rest"],
66
"require": {
77
"php": ">=5.4.0",
88
"netresearch/jsonmapper": "~0.5",

src/Issue/IssueService.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ public function search($jql, $startAt=0, $maxResults=15, $fields=[])
224224

225225
/**
226226
* get TimeTracking info
227-
*
228-
* @param type $issueIdOrKey
227+
*
228+
* @param type $issueIdOrKey
229229
* @return type @TimeTracking
230230
*/
231231
public function getTimeTracking($issueIdOrKey)
@@ -249,7 +249,7 @@ public function getTimeTracking($issueIdOrKey)
249249
* @return type @TimeTracking
250250
*/
251251
public function timeTracking($issueIdOrKey, $timeTracking)
252-
{
252+
{
253253
$array = ["update" =>
254254
[
255255
"timetracking" => [
@@ -263,11 +263,25 @@ public function timeTracking($issueIdOrKey, $timeTracking)
263263
$this->log->addDebug("TimeTracking req=$data\n");
264264

265265
// if success, just return HTTP 201.
266-
$ret = $this->exec($this->uri . "/$issueIdOrKey", $data, 'PUT');
266+
$ret = $this->exec($this->uri . "/$issueIdOrKey", $data, 'PUT');
267267

268268
return $ret;
269269
}
270-
}
271270

272-
?>
271+
/**
272+
* get getWorklog
273+
*
274+
* @param mixed $issueIdOrKey
275+
* @return Worklog Return Worklog object
276+
*/
277+
public function getWorklog($issueIdOrKey)
278+
{
279+
$ret = $this->exec($this->uri . "/$issueIdOrKey/worklog");
280+
$this->log->addDebug("getWorklog res=$ret\n");
281+
$worklog = $this->json_mapper->map(
282+
json_decode($ret), new Worklog()
283+
);
284+
return $worklog;
285+
}
273286

287+
}

src/Issue/Worklog.php

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
3+
namespace JiraRestApi\Issue;
4+
5+
/**
6+
* Class Worklog
7+
*
8+
* @package JiraRestApi\Issue
9+
*/
10+
class Worklog
11+
{
12+
/**
13+
* @var int Start at position
14+
*/
15+
protected $startAt;
16+
17+
/**
18+
* @var int Maximum results
19+
*/
20+
protected $maxResults;
21+
22+
/**
23+
* @var int Total results
24+
*/
25+
protected $total;
26+
27+
/**
28+
* @var array Worklogs
29+
*/
30+
protected $worklogs;
31+
32+
/**
33+
* @return int
34+
*/
35+
public function getStartAt()
36+
{
37+
return $this->startAt;
38+
}
39+
40+
/**
41+
* @param int $startAt
42+
*/
43+
public function setStartAt($startAt)
44+
{
45+
$this->startAt = $startAt;
46+
}
47+
48+
/**
49+
* @return int
50+
*/
51+
public function getMaxResults()
52+
{
53+
return $this->maxResults;
54+
}
55+
56+
/**
57+
* @param int $maxResults
58+
*/
59+
public function setMaxResults($maxResults)
60+
{
61+
$this->maxResults = $maxResults;
62+
}
63+
64+
/**
65+
* @return int
66+
*/
67+
public function getTotal()
68+
{
69+
return $this->total;
70+
}
71+
72+
/**
73+
* @param int $total
74+
*/
75+
public function setTotal($total)
76+
{
77+
$this->total = $total;
78+
}
79+
80+
/**
81+
* @return array Worklogs
82+
*/
83+
public function getWorklogs()
84+
{
85+
return $this->worklogs;
86+
}
87+
88+
/**
89+
* @param array $worklogs Worklogs
90+
*/
91+
public function setWorklogs($worklogs)
92+
{
93+
$this->worklogs = $worklogs;
94+
}
95+
96+
}

0 commit comments

Comments
 (0)