From 120bbe1397d5515d095d7b48d8ce5565bf9b55dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=B5=D0=BD=D0=B0=D1=82=20=D0=A4=D0=B0=D0=B7=D1=8B?= =?UTF-8?q?=D0=BB=D1=8F=D0=BD=D0=BE=D0=B2?= Date: Fri, 21 Oct 2016 20:20:59 +0300 Subject: [PATCH] add method getIssueWorklog --- README.md | 1 + lib/jira.js | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/README.md b/README.md index c8f94ed4..5d093a85 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ JiraApi options: * Set Max Results * Set Start-At parameter for results * Add a worklog + * Get a worklog * Delete a worklog * Add new estimate for worklog * Add a comment diff --git a/lib/jira.js b/lib/jira.js index 190e2661..1219eb52 100644 --- a/lib/jira.js +++ b/lib/jira.js @@ -2139,4 +2139,85 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor }); }; + // ## Returns all work logs for an issue ## + // ### Takes ### + // + // * issueId: id of issue to get work log + // * callback: for when it's done + // + // ### Returns ### + // + // * error string of the error + // * a collection of worklogs associated with the issue + // + // [Jira Doc](https://docs.atlassian.com/jira/REST/cloud/#api/2/issue-getIssueWorklog) + + /*{ + "startAt": 0, + "maxResults": 1, + "total": 1, + "worklogs": [ + { + "self": "http://www.example.com/jira/rest/api/2/issue/10010/worklog/10000", + "author": { + "self": "http://www.example.com/jira/rest/api/2/user?username=fred", + "name": "fred", + "displayName": "Fred F. User", + "active": false + }, + "updateAuthor": { + "self": "http://www.example.com/jira/rest/api/2/user?username=fred", + "name": "fred", + "displayName": "Fred F. User", + "active": false + }, + "comment": "I did some work here.", + "updated": "2016-10-18T11:05:45.001+0000", + "visibility": { + "type": "group", + "value": "jira-developers" + }, + "started": "2016-10-18T11:05:45.001+0000", + "timeSpent": "3h 20m", + "timeSpentSeconds": 12000, + "id": "100028", + "issueId": "10002" + } + ] + } */ + this.getIssueWorklog = function(issueId, callback) { + + var options = { + rejectUnauthorized: this.strictSSL, + uri: this.makeUri('/issue/' + issueId + '/worklog'), + method: 'GET' + }; + + this.doRequest(options, function(error, response, body) { + + if (error) { + callback(error, null); + return; + } + + if (response.statusCode === 404) { + callback('Invalid issue number.'); + return; + } + + if (response.statusCode !== 200) { + callback(response.statusCode + ': Unable to connect to JIRA during findIssueStatus.'); + return; + } + + if (body === undefined) { + callback('Response body was undefined.'); + return; + } + + callback(null, JSON.parse(body)); + + }); + }; + }).call(JiraApi.prototype);