@@ -606,7 +606,7 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
606
606
* @param issueNumber - The internal id (not the issue key) of the issue
607
607
* @param callback
608
608
*/
609
- this . remoteLink = function remoteLink ( issueNumber , callback ) {
609
+ this . getRemoteLinks = function getRemoteLinks ( issueNumber , callback ) {
610
610
611
611
var options = {
612
612
rejectUnauthorized : this . strictSSL ,
@@ -635,7 +635,50 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
635
635
callback ( null , response . body ) ;
636
636
637
637
} ) ;
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
+ } ;
639
682
640
683
641
684
// ## Get Versions for a project ##
0 commit comments