Permalink
Browse files

added new methods:

- addNewComponent
- deleteComponent
  • Loading branch information...
Fabio
Fabio committed Oct 22, 2015
1 parent efc81d4 commit f8ae35c7226ed86148f98164a3f9c44c91f2ec71
Showing with 82 additions and 1 deletion.
  1. +2 −1 docs/jira.html
  2. +80 −0 lib/jira.js
View
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<head>
@@ -70,6 +70,7 @@ <h2 id="implemented-apis">Implemented APIs</h2>
<li>Pulling a project</li>
<li>List all projects viewable to the user</li>
<li>List Components</li>
<li>Add a new component</li>
<li>List Fields</li>
<li>List Priorities</li>
</ul>
View
@@ -1167,6 +1167,86 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
});
};
// ## Add component to Jira ##
// ### Takes ###
//
// * issue: Properly Formatted Component
// * callback: for when it's done
//
// ### Returns ###
// * error object (check out the Jira Doc)
// * success object
//
// [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290028)
this.addNewComponent = function (component, callback) {
var options = {
rejectUnauthorized: this.strictSSL,
uri: this.makeUri('/component'),
method: 'POST',
followAllRedirects: true,
json: true,
body: component
};
this.doRequest(options, function (error, response, body) {
if (error) {
callback(error, null);
return;
}
if (response.statusCode === 400) {
callback(body);
return;
}
if ((response.statusCode !== 200) && (response.statusCode !== 201)) {
callback(response.statusCode + ': Unable to connect to JIRA during search.');
return;
}
callback(null, body);
});
};
// ## Delete component to Jira ##
// ### Takes ###
//
// * componentId: the Id of the component to delete
// * callback: for when it's done
//
// ### Returns ###
// * error string
// * success object
//
// [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290791)
this.deleteComponent = function (componentNum, callback) {
var options = {
rejectUnauthorized: this.strictSSL,
uri: this.makeUri('/component/' + componentNum),
method: 'DELETE',
followAllRedirects: true,
json: true
};
this.doRequest(options, function (error, response) {
if (error) {
callback(error, null);
return;
}
if (response.statusCode === 204) {
callback(null, "Success");
return;
}
callback(response.statusCode + ': Error while deleting');
});
};
// ## List listFields ##
// ### Takes ###

0 comments on commit f8ae35c

Please sign in to comment.