diff --git a/README.md b/README.md index 70a3314d..9a313220 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ copy .env.example file to .env on your project root. - [Perform a transition on an issue](#perform-a-transition-on-an-issue) - [Perform an advanced search, using the JQL](#perform-an-advanced-search) - [Issue time tracking](#issue-time-tracking) +- [Issue worklog](#issue-worklog) ## Get Project Info @@ -328,6 +329,28 @@ try { ?> ```` +## Issue worklog + +````php +getWorklog($issueKey)->getWorklogs(); + var_dump($ret); +} catch (JIRAException $e) { + $this->assertTrue(false, 'testSearch Failed : '.$e->getMessage()); +} +?> +```` + # License Apache V2 License diff --git a/composer.json b/composer.json index a3f6cce7..b2f86cfa 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "lesstif/php-jira-rest-client", "description": "JIRA REST API Client for PHP Users.", "type": "library", - "keywords": ["jira", "jira-php", "jira-rest"], + "keywords": ["jira", "rest", "jira-php", "jira-rest"], "require": { "php": ">=5.4.0", "netresearch/jsonmapper": "~0.5", diff --git a/src/Issue/IssueService.php b/src/Issue/IssueService.php index 20820219..664730c1 100644 --- a/src/Issue/IssueService.php +++ b/src/Issue/IssueService.php @@ -224,8 +224,8 @@ public function search($jql, $startAt=0, $maxResults=15, $fields=[]) /** * get TimeTracking info - * - * @param type $issueIdOrKey + * + * @param type $issueIdOrKey * @return type @TimeTracking */ public function getTimeTracking($issueIdOrKey) @@ -249,7 +249,7 @@ public function getTimeTracking($issueIdOrKey) * @return type @TimeTracking */ public function timeTracking($issueIdOrKey, $timeTracking) - { + { $array = ["update" => [ "timetracking" => [ @@ -263,11 +263,25 @@ public function timeTracking($issueIdOrKey, $timeTracking) $this->log->addDebug("TimeTracking req=$data\n"); // if success, just return HTTP 201. - $ret = $this->exec($this->uri . "/$issueIdOrKey", $data, 'PUT'); + $ret = $this->exec($this->uri . "/$issueIdOrKey", $data, 'PUT'); return $ret; } -} -?> + /** + * get getWorklog + * + * @param mixed $issueIdOrKey + * @return Worklog Return Worklog object + */ + public function getWorklog($issueIdOrKey) + { + $ret = $this->exec($this->uri . "/$issueIdOrKey/worklog"); + $this->log->addDebug("getWorklog res=$ret\n"); + $worklog = $this->json_mapper->map( + json_decode($ret), new Worklog() + ); + return $worklog; + } +} diff --git a/src/Issue/Worklog.php b/src/Issue/Worklog.php new file mode 100644 index 00000000..9d2795ef --- /dev/null +++ b/src/Issue/Worklog.php @@ -0,0 +1,96 @@ +startAt; + } + + /** + * @param int $startAt + */ + public function setStartAt($startAt) + { + $this->startAt = $startAt; + } + + /** + * @return int + */ + public function getMaxResults() + { + return $this->maxResults; + } + + /** + * @param int $maxResults + */ + public function setMaxResults($maxResults) + { + $this->maxResults = $maxResults; + } + + /** + * @return int + */ + public function getTotal() + { + return $this->total; + } + + /** + * @param int $total + */ + public function setTotal($total) + { + $this->total = $total; + } + + /** + * @return array Worklogs + */ + public function getWorklogs() + { + return $this->worklogs; + } + + /** + * @param array $worklogs Worklogs + */ + public function setWorklogs($worklogs) + { + $this->worklogs = $worklogs; + } + +}