|
112 | 112 | // * _0.0.3 Added APIs and Docco documentation_
|
113 | 113 | // * _0.0.2 Initial version_
|
114 | 114 | var url = require('url'),
|
| 115 | + FormData = require('form-data'), |
| 116 | + fs = require('fs'), |
115 | 117 | logger = console;
|
116 | 118 |
|
117 | 119 |
|
@@ -867,14 +869,23 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
|
867 | 869 | });
|
868 | 870 | };
|
869 | 871 |
|
| 872 | +<<<<<<< HEAD |
870 | 873 | // ## List Components ##
|
871 | 874 | // ### Takes ###
|
872 | 875 | //
|
873 | 876 | // * project: key for the project
|
| 877 | +======= |
| 878 | + // ## Assign issue in Jira ## |
| 879 | + // ### Takes ### |
| 880 | + // |
| 881 | + // * issueId: the Id of the issue to delete |
| 882 | + // * issueUpdate: username of the assignee |
| 883 | +>>>>>>> bbae5ff8ea8893449ee2d00000eb91dde4860dfc |
874 | 884 | // * callback: for when it's done
|
875 | 885 | //
|
876 | 886 | // ### Returns ###
|
877 | 887 | // * error string
|
| 888 | +<<<<<<< HEAD |
878 | 889 | // * array of components
|
879 | 890 | //
|
880 | 891 | // [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#id290489)
|
@@ -910,12 +921,28 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
|
910 | 921 | };
|
911 | 922 |
|
912 | 923 | this.request(options, function(error, response, body) {
|
| 924 | +======= |
| 925 | + // * success string |
| 926 | + // |
| 927 | + // [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#idp1342720) |
| 928 | + this.assign = function(issueNum, assignee, callback) { |
| 929 | + var options = { |
| 930 | + rejectUnauthorized: this.strictSSL, |
| 931 | + uri: this.makeUri('/issue/' + issueNum + '/assignee'), |
| 932 | + json: {name: assignee}, |
| 933 | + method: 'PUT', |
| 934 | + followAllRedirects: true |
| 935 | + }; |
| 936 | + |
| 937 | + this.request(options, function(error, response) { |
| 938 | +>>>>>>> bbae5ff8ea8893449ee2d00000eb91dde4860dfc |
913 | 939 |
|
914 | 940 | if (error) {
|
915 | 941 | callback(error, null);
|
916 | 942 | return;
|
917 | 943 | }
|
918 | 944 |
|
| 945 | +<<<<<<< HEAD |
919 | 946 | if (response.statusCode === 200) {
|
920 | 947 | callback(null, body);
|
921 | 948 | return;
|
@@ -1027,6 +1054,14 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
|
1027 | 1054 | }
|
1028 | 1055 |
|
1029 | 1056 | callback(response.statusCode + ': Error while updating');
|
| 1057 | +======= |
| 1058 | + if (response.statusCode === 204) { |
| 1059 | + callback(null, "Success"); |
| 1060 | + return; |
| 1061 | + } |
| 1062 | + |
| 1063 | + callback(response.statusCode + ': Error while assigning'); |
| 1064 | +>>>>>>> bbae5ff8ea8893449ee2d00000eb91dde4860dfc |
1030 | 1065 |
|
1031 | 1066 | });
|
1032 | 1067 | };
|
@@ -1146,6 +1181,61 @@ var JiraApi = exports.JiraApi = function(protocol, host, port, username, passwor
|
1146 | 1181 | });
|
1147 | 1182 | };
|
1148 | 1183 |
|
| 1184 | +<<<<<<< HEAD |
| 1185 | +======= |
| 1186 | + // ## Add attachment to issue ## |
| 1187 | + // ### Takes ### |
| 1188 | + // |
| 1189 | + // * issueId: the Id of the issue to delete |
| 1190 | + // * path: local path to the attachment |
| 1191 | + // * callback: for when it's done |
| 1192 | + // |
| 1193 | + // ### Returns ### |
| 1194 | + // * error string |
| 1195 | + // * success string |
| 1196 | + // |
| 1197 | + // [Jira Doc](http://docs.atlassian.com/jira/REST/latest/#idp2051136) |
| 1198 | + this.attachToIssue = function(issueNum, path, callback) { |
| 1199 | + var self = this; |
| 1200 | + var options = { |
| 1201 | + rejectUnauthorized: this.strictSSL, |
| 1202 | + uri: this.makeUri('/issue/' + issueNum + '/attachments'), |
| 1203 | + method: 'POST', |
| 1204 | + followAllRedirects: true, |
| 1205 | + json: true, |
| 1206 | + headers: { |
| 1207 | + 'x-atlassian-token': 'nocheck' |
| 1208 | + } |
| 1209 | + }; |
| 1210 | + |
| 1211 | + var form = new FormData(); |
| 1212 | + form.append('file', fs.createReadStream(path)); |
| 1213 | + |
| 1214 | + form.getLength(function(err, length) { |
| 1215 | + |
| 1216 | + var form_request = self.request(options, function(error, response) { |
| 1217 | + if (error) { |
| 1218 | + callback(error, null); |
| 1219 | + return; |
| 1220 | + } |
| 1221 | + |
| 1222 | + if (response.statusCode === 200) { |
| 1223 | + callback(null, "Success"); |
| 1224 | + return; |
| 1225 | + } |
| 1226 | + |
| 1227 | + callback(response.statusCode + ': Error while uploading'); |
| 1228 | + |
| 1229 | + }); |
| 1230 | + |
| 1231 | + form_request.setHeader('Content-Length', length); |
| 1232 | + form = form_request.form(); |
| 1233 | + form.append('file', fs.createReadStream(path)); |
| 1234 | + }); |
| 1235 | + |
| 1236 | + }; |
| 1237 | + |
| 1238 | +>>>>>>> bbae5ff8ea8893449ee2d00000eb91dde4860dfc |
1149 | 1239 | // ## List all Viewable Projects ##
|
1150 | 1240 | // ### Takes ###
|
1151 | 1241 | //
|
|
0 commit comments