Skip to content

Commit c9f14d4

Browse files
author
Steven Surowiec
committed
Merge pull request #48 from Woellchen/feature/retrieve_backlog
add a method that allows to retrieve a backlog by the rapid view id
2 parents 266b855 + 5afa9b2 commit c9f14d4

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

lib/jira.js

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,5 +1660,95 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
16601660
});
16611661
};
16621662

1663+
// ## Retrieve the backlog of a certain Rapid View ##
1664+
// ### Takes ###
1665+
// * rapidViewId: rapid view id
1666+
// * callback: for when it's done
1667+
//
1668+
// ### Returns ###
1669+
// * error string
1670+
// * backlog object
1671+
/*
1672+
* Backlog item is in the format:
1673+
* {
1674+
* "sprintMarkersMigrated": true,
1675+
* "issues": [
1676+
* {
1677+
* "id": 67890,
1678+
* "key": "KEY-1234",
1679+
* "summary": "Issue Summary",
1680+
* ...
1681+
* }
1682+
* ],
1683+
* "rankCustomFieldId": 12345,
1684+
* "sprints": [
1685+
* {
1686+
* "id": 123,
1687+
* "name": "Sprint Name",
1688+
* "state": "FUTURE",
1689+
* ...
1690+
* }
1691+
* ],
1692+
* "supportsPages": true,
1693+
* "projects": [
1694+
* {
1695+
* "id": 567,
1696+
* "key": "KEY",
1697+
* "name": "Project Name"
1698+
* }
1699+
* ],
1700+
* "epicData": {
1701+
* "epics": [
1702+
* {
1703+
* "id": 9876,
1704+
* "key": "KEY-4554",
1705+
* "typeName": "Epic",
1706+
* ...
1707+
* }
1708+
* ],
1709+
* "canEditEpics": true,
1710+
* "supportsPages": true
1711+
* },
1712+
* "canManageSprints": true,
1713+
* "maxIssuesExceeded": false,
1714+
* "queryResultLimit": 2147483647,
1715+
* "versionData": {
1716+
* "versionsPerProject": {
1717+
* "567": [
1718+
* {
1719+
* "id": 8282,
1720+
* "name": "Version Name",
1721+
* ...
1722+
* }
1723+
* ]
1724+
* },
1725+
* "canCreateVersion": true
1726+
* }
1727+
* }
1728+
*/
1729+
this.getBacklogForRapidView = function(rapidViewId, callback) {
1730+
var options = {
1731+
rejectUnauthorized: this.strictSSL,
1732+
uri: this.makeUri('/xboard/plan/backlog/data?rapidViewId=' + rapidViewId, 'rest/greenhopper/'),
1733+
method: 'GET',
1734+
json: true
1735+
};
1736+
1737+
this.doRequest(options, function(error, response) {
1738+
if (error) {
1739+
callback(error, null);
1740+
1741+
return;
1742+
}
1743+
1744+
if (response.statusCode === 200) {
1745+
callback(null, response.body);
1746+
1747+
return;
1748+
}
1749+
1750+
callback(response.statusCode + ': Error while retrieving backlog');
1751+
});
1752+
};
16631753

16641754
}).call(JiraApi.prototype);

spec/jira.spec.coffee

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,3 +548,23 @@ describe "Node Jira Tests", ->
548548
# Successful Request
549549
@jira.request.mostRecentCall.args[1] null, statusCode:200, "body"
550550
expect(@cb).toHaveBeenCalledWith null, "body"
551+
552+
it "Retrieves a Rapid View Backlog", ->
553+
options =
554+
rejectUnauthorized: true
555+
uri: makeUrl("xboard/plan/backlog/data?rapidViewId=123", true)
556+
method: 'GET'
557+
json: true
558+
auth:
559+
user: 'test'
560+
pass: 'test'
561+
562+
@jira.getBacklogForRapidView 123, @cb
563+
expect(@jira.request).toHaveBeenCalledWith options, jasmine.any(Function)
564+
565+
@jira.request.mostRecentCall.args[1] null, statusCode:500
566+
expect(@cb).toHaveBeenCalledWith '500: Error while retrieving backlog'
567+
568+
# Successful Request
569+
@jira.request.mostRecentCall.args[1] null, statusCode:200, body: issues: ['test']
570+
expect(@cb).toHaveBeenCalledWith null, issues: ['test']

0 commit comments

Comments
 (0)