Repository: jira-node/node-jira-client (js)

Issue:
Get Comments by ID
The Jira API supports getting comments by ID, but this does not seem to be implemented in the library.

[Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-comment-list-post)

Pull request description:
Allow getting and deleting comments
A few functions regarding Comments from the API that wasn't implemented yet..

Closes #279 

Patch:
diff --git a/src/jira.js b/src/jira.js
index 1e7b6fe..e77f64b 100644
--- a/src/jira.js
+++ b/src/jira.js
@@ -1158,6 +1158,50 @@ export default class JiraApi {
     }));
   }
 
+  /**
+   * @name getComments
+   * @function
+   * Get Comments by IssueId. 
+   * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-comment-list-post)
+   * @param {number} issueId - this issue this comment is on
+   */
+  getComments(issueId) {
+    return this.doRequest(this.makeRequestHeader(this.makeUri({
+      pathname: `/issue/${issueId}/comment`,
+    })));
+  }
+
+  /**
+   * @name getComment
+   * @function
+   * Get Comment by Id. 
+   * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-comment-list-post)
+   * @param {number} issueId - this issue this comment is on
+   * @param {number} commentId - the id of the comment
+   */
+  getComment(issueId, commentId) {
+    return this.doRequest(this.makeRequestHeader(this.makeUri({
+      pathname: `/issue/${issueId}/comment/${commentId}`,
+    })));
+  }
+
+  /**
+   * @name deleteComment
+   * @function
+   * Delete Comments by Id. 
+   * [Jira Doc](https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-rest-api-3-comment-list-post)
+   * @param {number} issueId - this issue this comment is on
+   * @param {number} commentId - the id of the comment
+   */
+  deleteComment(issueId, commentId) {
+    return this.doRequest(this.makeRequestHeader(this.makeUri({
+      pathname: `/issue/${issueId}/comment/${commentId}`,
+    }), {
+      method: 'DELETE',
+      followAllRedirects: true,
+    }));
+  }
+
   /** Add a worklog to a project
    * [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id291617)
    * @name addWorklog


Test patch:
diff --git a/test/jira-tests.js b/test/jira-tests.js
index 240c930..5de91a4 100644
--- a/test/jira-tests.js
+++ b/test/jira-tests.js
@@ -726,6 +726,21 @@ describe('Jira API Tests', () => {
       result.should.eql('http://jira.somehost.com:8080/rest/api/2.0/issue/someIssueNumber/comment/someCommentNumber');
     });
 
+    it('getComments hits proper url', async () => {
+      const result = await dummyURLCall('getComments', ['someIssueNumber']);
+      result.should.eql('http://jira.somehost.com:8080/rest/api/2.0/issue/someIssueNumber/comment');
+    });
+
+    it('getComment hits proper url', async () => {
+      const result = await dummyURLCall('getComment', ['someIssueNumber', 'someCommentNumber']);
+      result.should.eql('http://jira.somehost.com:8080/rest/api/2.0/issue/someIssueNumber/comment/someCommentNumber');
+    });
+
+    it('deleteComment hits proper url', async () => {
+      const result = await dummyURLCall('deleteComment', ['someIssueNumber', 'someCommentNumber']);
+      result.should.eql('http://jira.somehost.com:8080/rest/api/2.0/issue/someIssueNumber/comment/someCommentNumber');
+    });
+
     it('addWorklog hits proper url', async () => {
       const result = await dummyURLCall('addWorklog', [
         'someIssueNumber',