@@ -702,6 +702,67 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
702
702
} ) ;
703
703
} ;
704
704
705
+ // ## Update a version ##
706
+ // ### Takes ###
707
+ //
708
+ // * version: an object of the new version
709
+ // * callback: for when it's done
710
+ //
711
+ // ### Returns ###
712
+ //
713
+ // * error: error text
714
+ // * version: should be the same version you passed up
715
+ //
716
+ // [Jira Doc](https://docs.atlassian.com/jira/REST/latest/#d2e510)
717
+ //
718
+ /* {
719
+ * "id": The ID of the version being updated. Required.
720
+ * "description": "An excellent version",
721
+ * "name": "New Version 1",
722
+ * "archived": false,
723
+ * "released": true,
724
+ * "releaseDate": "2010-07-05",
725
+ * "userReleaseDate": "5/Jul/2010",
726
+ * "project": "PXA"
727
+ * }
728
+ */
729
+ this . updateVersion = function ( version , callback ) {
730
+ var options = {
731
+ rejectUnauthorized : this . strictSSL ,
732
+ uri : this . makeUri ( '/version/' + version . id ) ,
733
+ method : 'PUT' ,
734
+ followAllRedirects : true ,
735
+ json : true ,
736
+ body : version
737
+ } ;
738
+
739
+ this . doRequest ( options , function ( error , response , body ) {
740
+
741
+ if ( error ) {
742
+ callback ( error , null ) ;
743
+ return ;
744
+ }
745
+
746
+ if ( response . statusCode === 404 ) {
747
+ callback ( 'Version does not exist or the currently authenticated user does not have permission to view it' ) ;
748
+ return ;
749
+ }
750
+
751
+ if ( response . statusCode === 403 ) {
752
+ callback ( 'The currently authenticated user does not have permission to edit the version' ) ;
753
+ return ;
754
+ }
755
+
756
+ if ( response . statusCode !== 200 ) {
757
+ callback ( response . statusCode + ': Unable to connect to JIRA during updateVersion.' ) ;
758
+ return ;
759
+ }
760
+
761
+ callback ( null , body ) ;
762
+
763
+ } ) ;
764
+ } ;
765
+
705
766
// ## Pass a search query to Jira ##
706
767
// ### Takes ###
707
768
//
0 commit comments