Skip to content

Some features added #29

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions src/Jira/Api.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,13 @@ public function getAttachment($attachmentId)
return $result;
}

public function deleteAttachment($attachmentId)
{
$result = $this->api(self::REQUEST_DELETE, "/rest/api/2/attachment/$attachmentId");

return $result;
}

public function getProjects()
{
return $this->api(self::REQUEST_GET, "/rest/api/2/project");
Expand Down Expand Up @@ -239,6 +246,21 @@ public function addComment($issueKey, $params)
return $this->api(self::REQUEST_POST, sprintf("/rest/api/2/issue/%s/comment", $issueKey), $params);
}

/**
* delete comment from a ticket
*
* issue key should be YOURPROJ-221
*
* @param $issueKey
* @param $commentId
* @return mixed
*/
public function deleteComment($issueKey, $commentId)
{
return $this->api(self::REQUEST_DELETE, sprintf("/rest/api/2/issue/%s/comment/%s", $issueKey, $commentId));
}


/**
* get available transitions for a ticket
*
Expand Down Expand Up @@ -541,6 +563,22 @@ public function setWatchers($issueKey, $watchers)
return $result;
}

/**
* remove watchers in a ticket
*
* @param $issueKey
* @param $watchers
* @return mixed
*/
public function deleteWatchers($issueKey, $watchers)
{
$result = array();
foreach($watchers as $w){
$result[] = $this->api(self::REQUEST_DELETE, sprintf("/rest/api/2/issue/%s/watchers", $issueKey), $w);
}
return $result;
}

/**
* close issue
*
Expand Down Expand Up @@ -574,4 +612,73 @@ public function closeIssue($issueKey)
}
return $result;
}

/**
* reopen issue
*
* @param $issueKey
* @return mixed
*
* @TODO: should have parameters? (e.g comment)
*/
public function reopenIssue($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'] == "Reopen Issue") {
$result = $this->transition(
$issueKey,
array(
'transition' => array(
'id' => $v['id']
)
)
);
break;
}
}
return $result;
}

/**
* resolve issue
*
* @param $issueKey
* @return mixed
*
* @TODO: should have parameters? (e.g comment)
*/
public function resolveIssue($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'] == "Resolve Issue") {
$result = $this->transition(
$issueKey,
array(
'transition' => array(
'id' => $v['id']
)
)
);
break;
}
}
return $result;
}

}
2 changes: 2 additions & 0 deletions src/Jira/Api/Client/CurlClient.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function sendRequest($method, $url, $data = array(), $endpoint, Authentic
} else {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
}
} else if($method == "DELETE") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already addressed in #76.

curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
} else {
if ($method == "PUT") {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
Expand Down