Skip to content

Commit

Permalink
update manual from #56
Browse files Browse the repository at this point in the history
  • Loading branch information
lesstif committed Jan 25, 2017
1 parent f62bad2 commit 7bbe146
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 11 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
<?php
require 'vendor/autoload.php';

use JiraRestApi\Issue\IssueService;
use JiraRestApi\JiraException;

$issueKey = "TEST-879";

try {
$issueService = new IssueService();

// if assignee is -1, automatic assignee used.
// A null assignee will remove the assignee.
$assignee = 'newAssigneeName';

$ret = $issueService->changeAssignee($this->key, $assignee);

var_dump($ret);
} catch (JiraException $e) {
$this->assertTrue(FALSE, "Change Assignee Failed : " . $e->getMessage());
}
```

#### Remove Issue

```php
<?php
require 'vendor/autoload.php';

use JiraRestApi\Issue\IssueService;
use JiraRestApi\JiraException;

$issueKey = "TEST-879";

try {
$issueService = new IssueService();

$ret = $issueService->deleteIssue($this->key);

var_dump($ret);
} catch (JiraException $e) {
$this->assertTrue(FALSE, "Change Assignee Failed : " . $e->getMessage());
}
```

#### Add comment

```php
Expand Down
26 changes: 16 additions & 10 deletions src/Issue/IssueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion src/JiraClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7bbe146

Please sign in to comment.