-
Notifications
You must be signed in to change notification settings - Fork 123
Added API methods. Added DELETE support for curl. #36
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
Changes from all commits
5956d70
390964e
8445c07
37b1c37
ac763e1
05b3c07
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 |
|---|---|---|
|
|
@@ -35,7 +35,8 @@ class Api | |
| const REQUEST_POST = "POST"; | ||
| const REQUEST_PUT = "PUT"; | ||
| const REQUEST_DELETE = "DELETE"; | ||
|
|
||
|
|
||
| const TRANSITION_DELIMITER = 'transition:'; | ||
|
|
||
| const AUTOMAP_FIELDS = 0x01; | ||
|
|
||
|
|
@@ -574,4 +575,51 @@ public function closeIssue($issueKey) | |
| } | ||
| return $result; | ||
| } | ||
|
|
||
| /** | ||
| * create JIRA Worklog | ||
| * | ||
| * @param $issue | ||
| * @param $filename | ||
| * @param array $options | ||
| * @return mixed | ||
| */ | ||
| public function createWorklog($issueKey, $time, $options = array()) | ||
| { | ||
|
|
||
|
Member
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. |
||
| $options = array_merge( | ||
| array( | ||
| "timeSpent" => $time, | ||
| ), | ||
| $options | ||
| ); | ||
|
|
||
| return $this->api(self::REQUEST_POST, sprintf("/rest/api/2/issue/%s/worklog", $issueKey), $options); | ||
| } | ||
|
|
||
| /** | ||
| * get JIRA Worklogs for a given issue key | ||
| * | ||
| * @param $issueKey | ||
| * @return mixed | ||
| */ | ||
| public function getWorklogs($issueKey) | ||
|
Member
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 rebase, because this function was already added as part of #37 and now there is branch conflict that prevents your PR merging. |
||
| { | ||
| return $this->api(self::REQUEST_GET, sprintf("/rest/api/2/issue/%s/worklog", $issueKey)); | ||
| } | ||
|
|
||
| /** | ||
| * remove a JIRA Worklog | ||
| * | ||
| * @param $issueKey | ||
| * @return mixed | ||
| */ | ||
| public function removeWorklog($issueKey, $worklogId) | ||
| { | ||
| $options = array( | ||
| "adjustEstimate" => "auto" | ||
| ); | ||
|
|
||
| return $this->api(self::REQUEST_DELETE, sprintf("/rest/api/2/issue/%s/worklog/%s", $issueKey, $worklogId), $options); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,8 +83,8 @@ public function sendRequest($method, $url, $data = array(), $endpoint, Authentic | |
| curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); | ||
| } | ||
| } else { | ||
| if ($method == "PUT") { | ||
| curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT"); | ||
| if ($method == "PUT" || $method == "DELETE") { | ||
|
Member
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. Instead please do like here: https://github.com/chobie/jira-api-restclient/pull/53/files#diff-bac9579c3d575193a096385b414bc909
Member
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 already addressed in #76. |
||
| curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); | ||
| curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data)); | ||
| } | ||
| } | ||
|
|
||

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.
Is this needed? I see no usage of this constant in added code.