Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -328,6 +329,28 @@ try {
?>
````

## Issue worklog

````php
<?php
require 'vendor/autoload.php';

use JiraRestApi\Issue\IssueService;

$issueKey = 'TEST-961';

try {
$issueService = new IssueService();

// get issue's worklog
$worklogs = $issueService->getWorklog($issueKey)->getWorklogs();
var_dump($ret);
} catch (JIRAException $e) {
$this->assertTrue(false, 'testSearch Failed : '.$e->getMessage());
}
?>
````

# License

Apache V2 License
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
26 changes: 20 additions & 6 deletions src/Issue/IssueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -249,7 +249,7 @@ public function getTimeTracking($issueIdOrKey)
* @return type @TimeTracking
*/
public function timeTracking($issueIdOrKey, $timeTracking)
{
{
$array = ["update" =>
[
"timetracking" => [
Expand All @@ -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;
}

}
96 changes: 96 additions & 0 deletions src/Issue/Worklog.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php

namespace JiraRestApi\Issue;

/**
* Class Worklog
*
* @package JiraRestApi\Issue
*/
class Worklog
{
/**
* @var int Start at position
*/
protected $startAt;

/**
* @var int Maximum results
*/
protected $maxResults;

/**
* @var int Total results
*/
protected $total;

/**
* @var array Worklogs
*/
protected $worklogs;

/**
* @return int
*/
public function getStartAt()
{
return $this->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;
}

}