Skip to content

Commit ae29bf9

Browse files
committed
Added deleteRemoteLink method.
1 parent 35d3088 commit ae29bf9

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

lib/jira.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,50 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
678678
});
679679
};
680680

681+
/**
682+
* Deletes the remote links associated with the given issue.
683+
*
684+
* @param issueNumber - The internal id (not the issue key) of the issue
685+
* @param globalId - The global id of the remote link
686+
* @param callback
687+
*/
688+
this.deleteRemoteLink = function deleteRemoteLink(issueNumber, remoteLinkGID, callback) {
689+
690+
var options = {
691+
rejectUnauthorized: this.strictSSL,
692+
uri: this.makeUri('/issue/' + issueNumber + '/remotelink'),
693+
method: 'DELETE',
694+
qs: {globalId: remoteLinkGID},
695+
json: true
696+
};
697+
698+
this.doRequest(options, function(error, response) {
699+
700+
if (error) {
701+
callback(error, null);
702+
return;
703+
}
704+
705+
if (response.statusCode === 404) {
706+
callback('Cannot delete remote link. Invalid issue.');
707+
return;
708+
}
709+
710+
if (response.statusCode === 400) {
711+
callback('Cannot create remote link. ' + response.body.errors.title);
712+
return;
713+
}
714+
715+
if ([200, 201].indexOf(response.statusCode) < 0) {
716+
callback(response.statusCode + ': Unable to connect to JIRA during request.');
717+
return;
718+
}
719+
720+
callback(null, response.body);
721+
722+
});
723+
};
724+
681725

682726
// ## Get Versions for a project ##
683727
// ### Takes ###

0 commit comments

Comments
 (0)