Skip to content
Closed
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
50 changes: 49 additions & 1 deletion src/Jira/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class Api
const REQUEST_POST = "POST";
const REQUEST_PUT = "PUT";
const REQUEST_DELETE = "DELETE";


const TRANSITION_DELIMITER = 'transition:';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? I see no usage of this constant in added code.


const AUTOMAP_FIELDS = 0x01;

Expand Down Expand Up @@ -574,4 +575,51 @@ public function closeIssue($issueKey)
}
return $result;
}

/**
* create JIRA Worklog
*
* @param $issue
* @param $filename
* @param array $options
* @return mixed
*/
public function createWorklog($issueKey, $time, $options = array())
{

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this empty line.

$options = array_merge(
array(
"timeSpent" => $time,
),
$options
);

return $this->api(self::REQUEST_POST, sprintf("/rest/api/2/issue/%s/worklog", $issueKey), $options);
}

/**
* get JIRA Worklogs for a given issue key
*
* @param $issueKey
* @return mixed
*/
public function getWorklogs($issueKey)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase, because this function was already added as part of #37 and now there is branch conflict that prevents your PR merging.

{
return $this->api(self::REQUEST_GET, sprintf("/rest/api/2/issue/%s/worklog", $issueKey));
}

/**
* remove a JIRA Worklog
*
* @param $issueKey
* @return mixed
*/
public function removeWorklog($issueKey, $worklogId)
{
$options = array(
"adjustEstimate" => "auto"
);

return $this->api(self::REQUEST_DELETE, sprintf("/rest/api/2/issue/%s/worklog/%s", $issueKey, $worklogId), $options);
}
}
4 changes: 2 additions & 2 deletions src/Jira/Api/Client/CurlClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public function sendRequest($method, $url, $data = array(), $endpoint, Authentic
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
}
} else {
if ($method == "PUT") {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
if ($method == "PUT" || $method == "DELETE") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already addressed in #76.

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
}
}
Expand Down