File tree Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Expand file tree Collapse file tree 3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,7 @@ $iss = new IssueService(new ArrayConfiguration(
149149- [ Edit worklog in Issue] ( #edit-worklog-in-issue )
150150- [ Get Issue worklog] ( #get-issue-worklog )
151151- [ Add watcher to Issue] ( #add-watcher-to-issue )
152+ - [ Remove watcher from Issue] ( #remove-watcher-from-issue )
152153- [ Send a notification to the recipients] ( #issue-notify )
153154
154155### Comment
@@ -1393,6 +1394,32 @@ try {
13931394}
13941395```
13951396
1397+ #### Remove watcher from Issue
1398+
1399+ [ See Jira API reference] ( https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/issue-removeWatcher )
1400+
1401+ ``` php
1402+ <?php
1403+ require 'vendor/autoload.php';
1404+
1405+ use JiraRestApi\Issue\IssueService;
1406+ use JiraRestApi\JiraException;
1407+
1408+ $issueKey = 'TEST-961';
1409+
1410+ try {
1411+ $issueService = new IssueService();
1412+
1413+ // watcher's id
1414+ $watcher = 'lesstif';
1415+
1416+ $issueService->removeWatcher($issueKey, $watcher);
1417+
1418+ } catch (JiraException $e) {
1419+ $this->assertTrue(false, 'add watcher Failed : '.$e->getMessage());
1420+ }
1421+ ```
1422+
13961423#### issue notify
13971424
13981425[ See Jira API reference] ( https://docs.atlassian.com/software/jira/docs/api/REST/latest/#api/2/issue-notify )
Original file line number Diff line number Diff line change @@ -764,6 +764,27 @@ public function addWatcher($issueIdOrKey, $watcher)
764764 return $ this ->http_response == 204 ? true : false ;
765765 }
766766
767+ /**
768+ * remove watcher from issue.
769+ *
770+ * @param string|int $issueIdOrKey
771+ * @param string $watcher watcher id
772+ *
773+ * @throws JiraException
774+ *
775+ * @return bool
776+ */
777+ public function removeWatcher ($ issueIdOrKey , $ watcher )
778+ {
779+ $ this ->log ->addInfo ("removeWatcher= \n" );
780+
781+ $ ret = $ this ->exec ($ this ->uri ."/ $ issueIdOrKey/watchers/?username= $ watcher " , '' , 'DELETE ' );
782+
783+ $ this ->log ->addInfo ('remove watcher ' .$ issueIdOrKey .' result= ' .var_export ($ ret , true ));
784+
785+ return $ this ->http_response == 204 ? true : false ;
786+ }
787+
767788 /**
768789 * Get the meta data for creating issues.
769790 *
Original file line number Diff line number Diff line change @@ -22,4 +22,18 @@ public function testAddWatcherLog()
2222 $ this ->assertTrue (false , 'testAddWatcherLog Failed : ' .$ e ->getMessage ());
2323 }
2424 }
25+
26+ public function testRemoveWatcherLog ()
27+ {
28+ try {
29+ $ issueService = new IssueService ();
30+
31+ // remove issue watcher
32+ $ ret = $ issueService ->removeWatcher ($ this ->issueKey , 'lesstif ' );
33+
34+ Dumper::dump ($ ret );
35+ } catch (JiraException $ e ) {
36+ $ this ->assertTrue (false , 'testRemoveWatcherLog Failed : ' .$ e ->getMessage ());
37+ }
38+ }
2539}
You can’t perform that action at this time.
0 commit comments