diff --git a/src/Jira/Api.php b/src/Jira/Api.php index 2c642a5..e63d61a 100644 --- a/src/Jira/Api.php +++ b/src/Jira/Api.php @@ -35,7 +35,8 @@ class Api const REQUEST_POST = "POST"; const REQUEST_PUT = "PUT"; const REQUEST_DELETE = "DELETE"; - + + const TRANSITION_DELIMITER = 'transition:'; const AUTOMAP_FIELDS = 0x01; @@ -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()) + { + + $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) + { + 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); + } } diff --git a/src/Jira/Api/Client/CurlClient.php b/src/Jira/Api/Client/CurlClient.php index 4a30d41..c7e8fd0 100644 --- a/src/Jira/Api/Client/CurlClient.php +++ b/src/Jira/Api/Client/CurlClient.php @@ -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") { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); } }