Skip to content
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
81 changes: 81 additions & 0 deletions lib/jira.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);