Skip to content

fixed incorrect json mapping && add timetracking entity #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 31, 2015
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
2 changes: 1 addition & 1 deletion src/Issue/Issue.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Issue implements \JsonSerializable
/* @var string */
public $key;

/* @var IssueField */
/** @var IssueField */
public $fields;

public function jsonSerialize()
Expand Down
49 changes: 24 additions & 25 deletions src/Issue/IssueField.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function __construct($updateIssue = false)
$this->versions = array();

$this->issuetype = new \JiraRestApi\Issue\IssueType();
$this->timetracking = new \JiraRestApi\Issue\TimeTracking();
}
}

Expand Down Expand Up @@ -45,17 +46,6 @@ public function setProjectId($id)
return $this;
}

public function setIssueType($name)
{
if (is_null($this->issuetype)) {
$this->issuetype = new \JiraRestApi\Issue\IssueType();
}

$this->issuetype->name = $name;

return $this;
}

public function setSummary($summary)
{
$this->summary = $summary;
Expand Down Expand Up @@ -144,7 +134,7 @@ public function addLabel($label)
/** @var string */
//public $progress;

/** @var string */
/** @var Timetracking */
public $timetracking;

/** @var IssueType */
Expand All @@ -156,10 +146,10 @@ public function addLabel($label)
/** @var Reporter */
public $reporter;

/** @var DateTime */
/** @var \DateTime */
public $created;

/** @var DateTime */
/** @var \DateTime */
public $updated;

/** @var string */
Expand All @@ -168,48 +158,57 @@ public function addLabel($label)
/** @var Priority */
public $priority;

/** @var IssueStatus */
/** @var object */
public $status;

/** @var string */
/** @var object[] */
public $labels;

/** @var JiraRestApi\Project\Project */
/** @var \JiraRestApi\Project\Project */
public $project;

/** @var string */
public $environment;

/** @var string */
/** @var string[] */
public $components;

/** @var Comments */
public $comments;

/** @var string */
/** @var object */
public $votes;

/** @var string */
/** @var object */
public $resolution;

/** @var string */
/** @var string[] */
public $fixVersions;

/** @var Reporter */
public $creator;

/** @var string */
/** @var object */
public $watches;

/** @var string */
/** @var object */
public $worklog;

/** @var Reporter */
public $assignee;

/* @var VersionList[\JiraRestApi\Issue\Version] */
/** @var \JiraRestApi\Issue\Version[] */
public $versions;

/** @var AttachmentList[\JiraRestApi\Issue\Attachment] */
/** @var \JiraRestApi\Issue\Attachment[] */
public $attachments;

/** @var string */
public $aggregatetimespent;

/** @var string */
public $timeestimate;

/** @var string */
public $aggregatetimeoriginalestimate;
}
2 changes: 1 addition & 1 deletion src/Issue/IssueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public function transition($issueIdOrKey, $transition)
* @param int $maxResults
* @param array $fields
*
* @return object
* @return IssueSearchResult
*/
public function search($jql, $startAt=0, $maxResults=15, $fields=[])
{
Expand Down
170 changes: 170 additions & 0 deletions src/Issue/TimeTracking.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?php
/**
* Created by PhpStorm.
* User: keanor
* Date: 29.07.15
* Time: 21:27
*/
namespace JiraRestApi\Issue;

/**
* Class TimeTracking
*
* @package JiraRestApi\Issue
*/
class TimeTracking implements \JsonSerializable
{
/**
* Original estimate
*
* @var string (ex 90m, 2h, 1d 2h 30m)
*/
public $originalEstimate;

/**
* Remaining estimate
*
* @var string (ex 90m, 2h, 1d 2h 30m)
*/
public $remainingEstimate;

/**
* Time spent
*
* @var string (ex 90m, 2h, 1d 2h 30m)
*/
public $timeSpent;

/**
* Original estimate in seconds, generated in jira
* for create/update issue set $this->originalEstimate
*
* @var int
*/
public $originalEstimateSeconds;

/**
* Remaining estimate in seconds, generated in jira
* for create/update issue set $this->remainingEstimate
*
* @var int
*/
public $remainingEstimateSeconds;

/**
* Time spent in seconds, generated in jira
* for create/update issue set $this->timeSpent
*
* @var int
*/
public $timeSpentSeconds;

/**
* @return string
*/
public function getOriginalEstimate()
{
return $this->originalEstimate;
}

/**
* @param string $originalEstimate
*/
public function setOriginalEstimate($originalEstimate)
{
$this->originalEstimate = $originalEstimate;
}

/**
* @return string
*/
public function getRemainingEstimate()
{
return $this->remainingEstimate;
}

/**
* @param string $remainingEstimate
*/
public function setRemainingEstimate($remainingEstimate)
{
$this->remainingEstimate = $remainingEstimate;
}

/**
* @return string
*/
public function getTimeSpent()
{
return $this->timeSpent;
}

/**
* @param string $timeSpent
*/
public function setTimeSpent($timeSpent)
{
$this->timeSpent = $timeSpent;
}

/**
* @return int
*/
public function getOriginalEstimateSeconds()
{
return $this->originalEstimateSeconds;
}

/**
* @param int $originalEstimateSeconds
*/
public function setOriginalEstimateSeconds($originalEstimateSeconds)
{
$this->originalEstimateSeconds = $originalEstimateSeconds;
}

/**
* @return int
*/
public function getRemainingEstimateSeconds()
{
return $this->remainingEstimateSeconds;
}

/**
* @param int $remainingEstimateSeconds
*/
public function setRemainingEstimateSeconds($remainingEstimateSeconds)
{
$this->remainingEstimateSeconds = $remainingEstimateSeconds;
}

/**
* @return int
*/
public function getTimeSpentSeconds()
{
return $this->timeSpentSeconds;
}

/**
* @param int $timeSpentSeconds
*/
public function setTimeSpentSeconds($timeSpentSeconds)
{
$this->timeSpentSeconds = $timeSpentSeconds;
}

/**
* (PHP 5 &gt;= 5.4.0)<br/>
* Specify data which should be serialized to JSON
*
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
*/
function jsonSerialize()
{
return array_filter(get_object_vars($this));
}
}
3 changes: 1 addition & 2 deletions src/JiraClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ protected function filterNullVariable($haystack)

public function __construct($path = '.')
{
$dotenv = Dotenv::load($path);
Dotenv::load($path);

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

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

$this->host = $this->env('JIRA_HOST');
$this->username = $this->env('JIRA_USER');
Expand Down