Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add delete watchers method #369

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/jira.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions test/jira-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down