diff --git a/src/Jira/Api.php b/src/Jira/Api.php index 07f1639..f9a277c 100644 --- a/src/Jira/Api.php +++ b/src/Jira/Api.php @@ -72,6 +72,9 @@ public function __construct( AuthenticationInterface $authentication, ClientInterface $client = null ) { + //Regular expression to remove trailing slash + $endpoint = preg_replace('{/$}', '', $endpoint); + $this->setEndPoint($endpoint); $this->authentication = $authentication; @@ -150,6 +153,24 @@ public function editIssue($issueKey, $params) } + /** + * Delete issue + * + * @param $issueKey should be YOURPROJ-221 + * @param $deleteSubtasks if all subtask should be deleted + * @return mixed + */ + public function deleteIssue($issueKey, $deleteSubtasks = 'true') + { + return $this->api( + self::REQUEST_DELETE, sprintf("/rest/api/2/issue/%s", $issueKey), + array ( + 'deleteSubtasks' => $deleteSubtasks + ) + ); + } + + public function getAttachment($attachmentId) { $result = $this->api(self::REQUEST_GET, "/rest/api/2/attachment/$attachmentId", array(), true); diff --git a/src/Jira/Api/Client/CurlClient.php b/src/Jira/Api/Client/CurlClient.php index 4a30d41..e5c595c 100644 --- a/src/Jira/Api/Client/CurlClient.php +++ b/src/Jira/Api/Client/CurlClient.php @@ -82,12 +82,14 @@ public function sendRequest($method, $url, $data = array(), $endpoint, Authentic } else { curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); } - } else { - if ($method == "PUT") { - curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); - curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); - } + } elseif ($method == "DELETE") { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE"); + + } elseif ($method == "PUT") { + curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); } + $data = curl_exec($curl);