@@ -1168,6 +1168,86 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
11681168
11691169 } ) ;
11701170 } ;
1171+
1172+ // ## Add component to Jira ##
1173+ // ### Takes ###
1174+ //
1175+ // * issue: Properly Formatted Component
1176+ // * callback: for when it's done
1177+ //
1178+ // ### Returns ###
1179+ // * error object (check out the Jira Doc)
1180+ // * success object
1181+ //
1182+ // [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290028)
1183+ this . addNewComponent = function ( component , callback ) {
1184+ var options = {
1185+ rejectUnauthorized : this . strictSSL ,
1186+ uri : this . makeUri ( '/component' ) ,
1187+ method : 'POST' ,
1188+ followAllRedirects : true ,
1189+ json : true ,
1190+ body : component
1191+ } ;
1192+
1193+ this . doRequest ( options , function ( error , response , body ) {
1194+
1195+ if ( error ) {
1196+ callback ( error , null ) ;
1197+ return ;
1198+ }
1199+
1200+ if ( response . statusCode === 400 ) {
1201+ callback ( body ) ;
1202+ return ;
1203+ }
1204+
1205+ if ( ( response . statusCode !== 200 ) && ( response . statusCode !== 201 ) ) {
1206+ callback ( response . statusCode + ': Unable to connect to JIRA during search.' ) ;
1207+ return ;
1208+ }
1209+
1210+ callback ( null , body ) ;
1211+
1212+ } ) ;
1213+ } ;
1214+
1215+ // ## Delete component to Jira ##
1216+ // ### Takes ###
1217+ //
1218+ // * componentId: the Id of the component to delete
1219+ // * callback: for when it's done
1220+ //
1221+ // ### Returns ###
1222+ // * error string
1223+ // * success object
1224+ //
1225+ // [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290791)
1226+ this . deleteComponent = function ( componentNum , callback ) {
1227+ var options = {
1228+ rejectUnauthorized : this . strictSSL ,
1229+ uri : this . makeUri ( '/component/' + componentNum ) ,
1230+ method : 'DELETE' ,
1231+ followAllRedirects : true ,
1232+ json : true
1233+ } ;
1234+
1235+ this . doRequest ( options , function ( error , response ) {
1236+
1237+ if ( error ) {
1238+ callback ( error , null ) ;
1239+ return ;
1240+ }
1241+
1242+ if ( response . statusCode === 204 ) {
1243+ callback ( null , "Success" ) ;
1244+ return ;
1245+ }
1246+
1247+ callback ( response . statusCode + ': Error while deleting' ) ;
1248+
1249+ } ) ;
1250+ } ;
11711251
11721252 // ## List listFields ##
11731253 // ### Takes ###
0 commit comments