Skip to content

Commit 7bbe146

Browse files
committed
update manual from #56
1 parent f62bad2 commit 7bbe146

File tree

3 files changed

+67
-11
lines changed

3 files changed

+67
-11
lines changed

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ $iss = new IssueService(new ArrayConfiguration(
104104
- [Create Sub Task](#create-sub-task)
105105
- [Add Attachment](#add-attachment)
106106
- [Update issue](#update-issue)
107+
- [Change assignee](#change-assignee)
108+
- [Remove issue](#remove-issue)
107109
- [Add comment](#add-comment)
108110
- [Perform a transition on an issue](#perform-a-transition-on-an-issue)
109111
- [Perform an advanced search, using the JQL](#perform-an-advanced-search)
@@ -494,6 +496,54 @@ try {
494496

495497
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.
496498

499+
#### Change Assignee
500+
501+
```php
502+
<?php
503+
require 'vendor/autoload.php';
504+
505+
use JiraRestApi\Issue\IssueService;
506+
use JiraRestApi\JiraException;
507+
508+
$issueKey = "TEST-879";
509+
510+
try {
511+
$issueService = new IssueService();
512+
513+
// if assignee is -1, automatic assignee used.
514+
// A null assignee will remove the assignee.
515+
$assignee = 'newAssigneeName';
516+
517+
$ret = $issueService->changeAssignee($this->key, $assignee);
518+
519+
var_dump($ret);
520+
} catch (JiraException $e) {
521+
$this->assertTrue(FALSE, "Change Assignee Failed : " . $e->getMessage());
522+
}
523+
```
524+
525+
#### Remove Issue
526+
527+
```php
528+
<?php
529+
require 'vendor/autoload.php';
530+
531+
use JiraRestApi\Issue\IssueService;
532+
use JiraRestApi\JiraException;
533+
534+
$issueKey = "TEST-879";
535+
536+
try {
537+
$issueService = new IssueService();
538+
539+
$ret = $issueService->deleteIssue($this->key);
540+
541+
var_dump($ret);
542+
} catch (JiraException $e) {
543+
$this->assertTrue(FALSE, "Change Assignee Failed : " . $e->getMessage());
544+
}
545+
```
546+
497547
#### Add comment
498548

499549
```php

src/Issue/IssueService.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -203,23 +203,29 @@ public function addComment($issueIdOrKey, $comment)
203203

204204
return $comment;
205205
}
206-
206+
207207
/**
208-
* Change a issue assignee
209-
*
210-
* @param issueIdOrKey Issue id or key
211-
* @param assignee array of assigne field informations
212-
*
213-
*/
214-
public function changeAssignee($issueIdOrKey, $assignee)
208+
* Change a issue assignee
209+
*
210+
* @param Issue $issueIdOrKey
211+
* @param Assigns $assigneeName Assigns an issue to a user.
212+
* If the assigneeName is "-1" automatic assignee is used.
213+
* A null name will remove the assignee.
214+
* @return true | false
215+
* @throws JiraException
216+
*
217+
*/
218+
public function changeAssignee($issueIdOrKey, $assigneeName)
215219
{
216220
$this->log->addInfo("changeAssignee=\n");
217221

218-
$data = json_encode($assignee);
222+
$ar = ['name' => $assigneeName];
223+
224+
$data = json_encode($ar);
219225

220226
$ret = $this->exec($this->uri."/$issueIdOrKey/assignee", $data, 'PUT');
221227

222-
$this->log->addInfo('change assignee of '.$issueIdOrKey.' to '.json_encode($assignee).' result='.var_export($ret, true));
228+
$this->log->addInfo('change assignee of '.$issueIdOrKey.' to ' . $assigneeName .' result='.var_export($ret, true));
223229

224230
return $ret;
225231
}

src/JiraClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public function exec($context, $post_data = null, $custom_request = null)
193193

194194
//The server successfully processed the request, but is not returning any content.
195195
if ($this->http_response == 204) {
196-
return '';
196+
return true;
197197
}
198198

199199
// HostNotFound, No route to Host, etc Network error

0 commit comments

Comments
 (0)