Skip to content

Commit 8a043fa

Browse files
author
Anubhav Mishra
committed
Added searching for users in a group
1 parent efc81d4 commit 8a043fa

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

lib/jira.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,54 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
962962
});
963963
};
964964

965+
// ## Get all users in group on Jira ##
966+
// ### Takes ###
967+
//
968+
// groupName: A query string used to search users in group
969+
// startAt: The index of the first user to return (0-based)
970+
// maxResults: The maximum number of users to return (defaults to 50).
971+
//
972+
// ### Returns ###
973+
//
974+
// * error: string if there's an error
975+
// * users: array of users for the user
976+
977+
this.getUsersInGroup = function(groupName, startAt, maxResults, callback) {
978+
startAt = (startAt !== undefined) ? startAt : 0;
979+
maxResults = (maxResults !== undefined) ? maxResults : 50;
980+
981+
var options = {
982+
rejectUnauthorized: this.strictSSL,
983+
uri: this.makeUri(
984+
'/group?groupname=' + groupName +
985+
'&expand=users[' + startAt + ':' + maxResults + ']'),
986+
method: 'GET',
987+
json: true,
988+
followAllRedirects: true
989+
};
990+
991+
this.doRequest(options, function(error, response, body) {
992+
993+
if (error) {
994+
callback(error, null);
995+
return;
996+
}
997+
998+
if (response.statusCode === 400) {
999+
callback('Unable to search');
1000+
return;
1001+
}
1002+
1003+
if (response.statusCode !== 200) {
1004+
callback(response.statusCode + ': Unable to connect to JIRA during search.');
1005+
return;
1006+
}
1007+
1008+
callback(null, body);
1009+
1010+
});
1011+
};
1012+
9651013
// ## Get issues related to a user ##
9661014
// ### Takes ###
9671015
//

0 commit comments

Comments
 (0)