-
Notifications
You must be signed in to change notification settings - Fork 123
Feature/jira transitionbyname #57
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
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 |
---|---|---|
|
@@ -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); | ||
|
@@ -253,6 +271,8 @@ public function getTransitions($issueKey, $params) | |
return $this->api(self::REQUEST_GET, sprintf("/rest/api/2/issue/%s/transitions", $issueKey), $params); | ||
} | ||
|
||
|
||
|
||
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 remove extra line, because methods should separated by 1 line, not 2. |
||
/** | ||
* transation a ticket | ||
* | ||
|
@@ -267,6 +287,43 @@ public function transition($issueKey, $params) | |
return $this->api(self::REQUEST_POST, sprintf("/rest/api/2/issue/%s/transitions", $issueKey), $params); | ||
} | ||
|
||
/** | ||
* transation by step name | ||
* | ||
* | ||
* @param $issueKey like YOURPROJ-22 | ||
* @param $stepName Step name like 'Done' or 'To Do' | ||
* @param $params (array of parameters from JIRA API) | ||
* @return mixed | ||
*/ | ||
public function transitionByStepName($issueKey, $stepName, $params = array()) | ||
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. Where does 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.
I think, that Anyway we're not making a release tomorrow, so we can rename this one later on as well. P.S. |
||
{ | ||
$result = array(); | ||
// get available transitions | ||
$tmp_transitions = $this->getTransitions($issueKey, array()); | ||
$tmp_transitions_result = $tmp_transitions->getResult(); | ||
$transitions = $tmp_transitions_result['transitions']; | ||
|
||
// search id for closing ticket | ||
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 comment is a copy/paste and only adds a confusion. |
||
foreach ($transitions as $v) { | ||
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. Boy scout rule: rename the |
||
// Close ticket if required id was found | ||
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 comment is a copy/paste and only adds a confusion. |
||
if ($v['name'] == $stepName) { | ||
$result = $this->transition( | ||
$issueKey, | ||
array_merge($params, | ||
array( | ||
'transition' => array( | ||
'id' => $v['id'] | ||
) | ||
) | ||
) | ||
); | ||
break; | ||
} | ||
} | ||
return $result; | ||
} | ||
|
||
/** | ||
* get available issue types | ||
* | ||
|
@@ -547,31 +604,9 @@ public function setWatchers($issueKey, $watchers) | |
* @param $issueKey | ||
* @return mixed | ||
* | ||
* @TODO: should have parameters? (e.g comment) | ||
*/ | ||
public function closeIssue($issueKey) | ||
{ | ||
$result = array(); | ||
// get available transitions | ||
$tmp_transitions = $this->getTransitions($issueKey, array()); | ||
$tmp_transitions_result = $tmp_transitions->getResult(); | ||
$transitions = $tmp_transitions_result['transitions']; | ||
|
||
// search id for closing ticket | ||
foreach ($transitions as $v) { | ||
// Close ticket if required id was found | ||
if ($v['name'] == "Close Issue") { | ||
$result = $this->transition( | ||
$issueKey, | ||
array( | ||
'transition' => array( | ||
'id' => $v['id'] | ||
) | ||
) | ||
); | ||
break; | ||
} | ||
} | ||
return $result; | ||
return $this->transitionByStepName($issueKey,'Close Issue'); | ||
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. Missing space after comma. |
||
} | ||
} |
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") { | ||
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. This is submitted as #53 PR and surely must be removed from here. |
||
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. Please remove this empty line. |
||
} 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.
This is submitted as #53 PR and surely must be removed from here.