optional = optional || {};
if (Array.isArray(optional)) {
optional = { fields: optional };
}
var options = {
rejectUnauthorized: this.strictSSL,
uri: this.makeUri('/search'),
method: 'POST',
json: true,
followAllRedirects: true,
body: {
jql: searchString,
startAt: optional.startAt || 0,
maxResults: optional.maxResults || 50,
fields: optional.fields || ["summary", "status", "assignee", "description"]
}
};
this.doRequest(options, function(error, response, body) {
if (error) {
callback(error, null);
return;
}
if (response.statusCode === 400) {
callback('Problem with the JQL query');
return;
}
if (response.statusCode !== 200) {
callback(response.statusCode + ': Unable to connect to JIRA during search.');
return;
}
callback(null, body);
});
};