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