Skip to content

Commit a1dcf47

Browse files
committed
Merge pull request #111 from anubhavmishra/master
Added searching for users in a group
2 parents 5079b56 + 8a043fa commit a1dcf47

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
@@ -963,6 +963,54 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
963963
});
964964
};
965965

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

0 commit comments

Comments
 (0)