Skip to content

Commit e721fc4

Browse files
committed
rename removeLink() into getRemoteLinks()
add createRemoteLink
1 parent 5514832 commit e721fc4

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

lib/jira.js

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
606606
* @param issueNumber - The internal id (not the issue key) of the issue
607607
* @param callback
608608
*/
609-
this.remoteLink = function remoteLink(issueNumber, callback) {
609+
this.getRemoteLinks = function getRemoteLinks(issueNumber, callback) {
610610

611611
var options = {
612612
rejectUnauthorized: this.strictSSL,
@@ -635,7 +635,50 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
635635
callback(null, response.body);
636636

637637
});
638-
}
638+
};
639+
640+
/**
641+
* Retrieves the remote links associated with the given issue.
642+
*
643+
* @param issueNumber - The internal id (not the issue key) of the issue
644+
* @param callback
645+
*/
646+
this.createRemoteLink = function createRemoteLink(issueNumber, remoteLink, callback) {
647+
648+
var options = {
649+
rejectUnauthorized: this.strictSSL,
650+
uri: this.makeUri('/issue/' + issueNumber + '/remotelink'),
651+
method: 'POST',
652+
json: true,
653+
body: remoteLink
654+
};
655+
656+
this.doRequest(options, function(error, response) {
657+
658+
if (error) {
659+
callback(error, null);
660+
return;
661+
}
662+
663+
if (response.statusCode === 404) {
664+
callback('Cannot create remote link. Invalid issue.');
665+
return;
666+
}
667+
668+
if (response.statusCode === 400) {
669+
callback('Cannot create remote link. ' + response.body.errors.title);
670+
return;
671+
}
672+
673+
if (response.statusCode !== 200) {
674+
callback(response.statusCode + ': Unable to connect to JIRA during request.');
675+
return;
676+
}
677+
678+
callback(null, response.body);
679+
680+
});
681+
};
639682

640683

641684
// ## Get Versions for a project ##

0 commit comments

Comments
 (0)