From 7bbe1464b1a94e0b5d204496a5182a57452a8f0b Mon Sep 17 00:00:00 2001 From: KwangSeob Jeong Date: Wed, 25 Jan 2017 15:30:08 +0900 Subject: [PATCH] update manual from #56 --- README.md | 50 ++++++++++++++++++++++++++++++++++++++ src/Issue/IssueService.php | 26 ++++++++++++-------- src/JiraClient.php | 2 +- 3 files changed, 67 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 9ed16cbc..36e1987a 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,8 @@ $iss = new IssueService(new ArrayConfiguration( - [Create Sub Task](#create-sub-task) - [Add Attachment](#add-attachment) - [Update issue](#update-issue) +- [Change assignee](#change-assignee) +- [Remove issue](#remove-issue) - [Add comment](#add-comment) - [Perform a transition on an issue](#perform-a-transition-on-an-issue) - [Perform an advanced search, using the JQL](#perform-an-advanced-search) @@ -494,6 +496,54 @@ try { If you want to change the custom field type when updating an issue, you can call the *addCustomField* function just as you did for creating issue. +#### Change Assignee + +```php +changeAssignee($this->key, $assignee); + + var_dump($ret); +} catch (JiraException $e) { + $this->assertTrue(FALSE, "Change Assignee Failed : " . $e->getMessage()); +} +``` + +#### Remove Issue + +```php +deleteIssue($this->key); + + var_dump($ret); +} catch (JiraException $e) { + $this->assertTrue(FALSE, "Change Assignee Failed : " . $e->getMessage()); +} +``` + #### Add comment ```php diff --git a/src/Issue/IssueService.php b/src/Issue/IssueService.php index a9a31612..808680a5 100644 --- a/src/Issue/IssueService.php +++ b/src/Issue/IssueService.php @@ -203,23 +203,29 @@ public function addComment($issueIdOrKey, $comment) return $comment; } - + /** - * Change a issue assignee - * - * @param issueIdOrKey Issue id or key - * @param assignee array of assigne field informations - * - */ - public function changeAssignee($issueIdOrKey, $assignee) + * Change a issue assignee + * + * @param Issue $issueIdOrKey + * @param Assigns $assigneeName Assigns an issue to a user. + * If the assigneeName is "-1" automatic assignee is used. + * A null name will remove the assignee. + * @return true | false + * @throws JiraException + * + */ + public function changeAssignee($issueIdOrKey, $assigneeName) { $this->log->addInfo("changeAssignee=\n"); - $data = json_encode($assignee); + $ar = ['name' => $assigneeName]; + + $data = json_encode($ar); $ret = $this->exec($this->uri."/$issueIdOrKey/assignee", $data, 'PUT'); - $this->log->addInfo('change assignee of '.$issueIdOrKey.' to '.json_encode($assignee).' result='.var_export($ret, true)); + $this->log->addInfo('change assignee of '.$issueIdOrKey.' to ' . $assigneeName .' result='.var_export($ret, true)); return $ret; } diff --git a/src/JiraClient.php b/src/JiraClient.php index 8fe9db99..94ef2e7a 100644 --- a/src/JiraClient.php +++ b/src/JiraClient.php @@ -193,7 +193,7 @@ public function exec($context, $post_data = null, $custom_request = null) //The server successfully processed the request, but is not returning any content. if ($this->http_response == 204) { - return ''; + return true; } // HostNotFound, No route to Host, etc Network error