From a94a389fe734e745cad269200a6c34b6ab609df0 Mon Sep 17 00:00:00 2001 From: ExE Date: Mon, 25 Dec 2017 00:30:31 +0200 Subject: [PATCH 1/3] Added function to get issue watchers --- src/Issue/IssueService.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Issue/IssueService.php b/src/Issue/IssueService.php index d64afb37..c9a42669 100644 --- a/src/Issue/IssueService.php +++ b/src/Issue/IssueService.php @@ -616,6 +616,29 @@ public function getCustomFields($priorityId) return $prio; } + + /** + * get watchers + * + * @param $issueIdOrKey + * @return Watcher[] + */ + public function getWatchers($issueIdOrKey) + { + $this->log->addInfo("getWatchers=\n"); + + $url = $this->uri . "/$issueIdOrKey/watchers"; + + $ret = $this->exec($url, null); + + $watchers = $this->json_mapper->mapArray( + json_decode($ret, false)->watchers, new \ArrayObject(), '\JiraRestApi\Issue\Watcher' + ); + + return $watchers; + } + + /** * add watcher to issue. * From 17e976fb48112c8a971a11ae41483ed15e5a0d82 Mon Sep 17 00:00:00 2001 From: ExE Date: Mon, 25 Dec 2017 00:49:07 +0200 Subject: [PATCH 2/3] Added fields to the Watcher class --- src/Issue/Watcher.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Issue/Watcher.php b/src/Issue/Watcher.php index e95ceb6f..35f4d7d2 100644 --- a/src/Issue/Watcher.php +++ b/src/Issue/Watcher.php @@ -13,6 +13,13 @@ class Watcher implements \JsonSerializable /** @var string */ public $name; + /** @var string */ + public $displayName; + /** @var string */ + public $emailAddress; + /** @var bool */ + public $active; + public function __construct($name) { From cb955f9623370aa42717995e2bc553b01f88f60a Mon Sep 17 00:00:00 2001 From: ExE Date: Mon, 25 Dec 2017 00:58:52 +0200 Subject: [PATCH 3/3] Apply StyleCI fixes --- src/Issue/IssueService.php | 7 +++---- src/Issue/Watcher.php | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Issue/IssueService.php b/src/Issue/IssueService.php index c9a42669..e4c4eacc 100644 --- a/src/Issue/IssueService.php +++ b/src/Issue/IssueService.php @@ -616,18 +616,18 @@ public function getCustomFields($priorityId) return $prio; } - /** - * get watchers + * get watchers. * * @param $issueIdOrKey + * * @return Watcher[] */ public function getWatchers($issueIdOrKey) { $this->log->addInfo("getWatchers=\n"); - $url = $this->uri . "/$issueIdOrKey/watchers"; + $url = $this->uri."/$issueIdOrKey/watchers"; $ret = $this->exec($url, null); @@ -638,7 +638,6 @@ public function getWatchers($issueIdOrKey) return $watchers; } - /** * add watcher to issue. * diff --git a/src/Issue/Watcher.php b/src/Issue/Watcher.php index 35f4d7d2..26d33bce 100644 --- a/src/Issue/Watcher.php +++ b/src/Issue/Watcher.php @@ -20,7 +20,6 @@ class Watcher implements \JsonSerializable /** @var bool */ public $active; - public function __construct($name) { $this->name = $name;