diff --git a/src/jira.js b/src/jira.js index 9844d0d3..372e677a 100644 --- a/src/jira.js +++ b/src/jira.js @@ -869,6 +869,26 @@ export default class JiraApi { })); } + /** Deletes a user as a watcher on an issue + * @name deleteWatcher + * @function= + * @param {string} issueKey - the key of the existing issue + * @param {string} accountId - the accountId of user which should be deleted from the watchers + */ + deleteWatcher(issueKey, accountId){ + const accountIdQuery=`accountId=${accountId}` + return this.doRequest(this.makeRequestHeader(this.makeUri({ + pathname:`/issue/${issueKey}/watchers`, + query: + { + accountIdQuery + } + }), { + method: 'DELETE', + followAllRedirects: true, + })); + } + /** Change an assignee on an issue * [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-assign) * @name assignee diff --git a/test/jira-tests.js b/test/jira-tests.js index 796461bd..9ce2befd 100644 --- a/test/jira-tests.js +++ b/test/jira-tests.js @@ -614,6 +614,11 @@ describe('Jira API Tests', () => { result.should.eql('John Smith'); }); + it('deleteWatcher hits proper url', async() => { + const result = await dummyURLCall('deleteWatcher', ['ZQ-9001', 'some-account-Id']); + result.should.eql('http://jira.somehost.com:8080/rest/api/2.0/issue/ZQ-9001/watchers?accountId=some-account-Id') + }); + it('getIssueChangelog hits proper url', async () => { const result = await dummyURLCall('getIssueChangelog', ['ZQ-9001']); result.should.eql('http://jira.somehost.com:8080/rest/api/2.0/issue/ZQ-9001/changelog?startAt=0&maxResults=50');