-
Notifications
You must be signed in to change notification settings - Fork 123
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
Added "deleteIssue" function and changed "CurlClient" to support DELETE request #53
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trick that JIRA needs boolean specified as strings is it's internal thing and doesn't need to be exposed via API client interface. This way please replace |
||
{ | ||
return $this->api( | ||
self::REQUEST_DELETE, sprintf("/rest/api/2/issue/%s", $issueKey), | ||
array ( | ||
'deleteSubtasks' => $deleteSubtasks | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change |
||
) | ||
); | ||
} | ||
|
||
|
||
public function getAttachment($attachmentId) | ||
{ | ||
$result = $this->api(self::REQUEST_GET, "/rest/api/2/attachment/$attachmentId", array(), true); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The DELETE calls can have parameters. The correct implementation is done in #76. |
||
|
||
} elseif ($method == "PUT") { | ||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); | ||
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); | ||
} | ||
|
||
|
||
$data = curl_exec($curl); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By replace code with solution below no explanatory comment is needed:
Sounds like useful change, but not sure how it's related to this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually just remove it from this PR, because there is another PR doing the same thing: #25 .