From e592121990e9a07186e4e8a68cc60866fc4cb6cf Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 13 Aug 2014 17:09:55 -0700 Subject: [PATCH 1/2] Fixed trailing slash in URL Added regular expression to remove trailing slash if included in URL. Api::__construct --- src/Jira/Api.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Jira/Api.php b/src/Jira/Api.php index 2c642a5..cb8e8fb 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; From 0a3c52affde7738ff3211958a50c32c8cfaca05b Mon Sep 17 00:00:00 2001 From: Marek Knappe Date: Fri, 30 Oct 2015 11:45:44 +1000 Subject: [PATCH 2/2] Added deleteIssue function and changed curlClient to support DELETE request --- src/Jira/Api.php | 18 ++++++++++++++++++ src/Jira/Api/Client/CurlClient.php | 12 +++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/Jira/Api.php b/src/Jira/Api.php index 2c642a5..78c74ef 100644 --- a/src/Jira/Api.php +++ b/src/Jira/Api.php @@ -150,6 +150,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);