authscape 1.0.242 → 1.0.243

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -2934,7 +2934,10 @@ var apiService = function apiService() {
2934
2934
  }(),
2935
2935
  DownloadFile: function () {
2936
2936
  var _DownloadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(url, fileName, completed) {
2937
- var passData,
2937
+ var method,
2938
+ data,
2939
+ mimeType,
2940
+ passData,
2938
2941
  defaultOptions,
2939
2942
  options,
2940
2943
  response,
@@ -2942,20 +2945,40 @@ var apiService = function apiService() {
2942
2945
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
2943
2946
  while (1) switch (_context9.prev = _context9.next) {
2944
2947
  case 0:
2945
- passData = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : false;
2946
- _context9.prev = 1;
2948
+ method = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : "get";
2949
+ data = _args9.length > 4 && _args9[4] !== undefined ? _args9[4] : {};
2950
+ mimeType = _args9.length > 5 && _args9[5] !== undefined ? _args9[5] : "application/octet-stream";
2951
+ passData = _args9.length > 6 && _args9[6] !== undefined ? _args9[6] : false;
2952
+ _context9.prev = 4;
2947
2953
  //let defaultOptions = await setupDefaultOptions();
2948
2954
  defaultOptions = {};
2949
2955
  options = {
2950
2956
  responseType: "blob"
2951
2957
  };
2952
- _context9.next = 6;
2958
+ response = null;
2959
+ if (!(method == "get")) {
2960
+ _context9.next = 14;
2961
+ break;
2962
+ }
2963
+ _context9.next = 11;
2953
2964
  return instance.get(url, _objectSpread(_objectSpread({}, defaultOptions), options));
2954
- case 6:
2965
+ case 11:
2955
2966
  response = _context9.sent;
2956
- if (response.status === 200) {
2967
+ _context9.next = 18;
2968
+ break;
2969
+ case 14:
2970
+ if (!(method == "post")) {
2971
+ _context9.next = 18;
2972
+ break;
2973
+ }
2974
+ _context9.next = 17;
2975
+ return instance.post(url, data, _objectSpread(_objectSpread({}, defaultOptions), options));
2976
+ case 17:
2977
+ response = _context9.sent;
2978
+ case 18:
2979
+ if (response != null && response.status === 200) {
2957
2980
  if (!passData) {
2958
- (0, _jsFileDownload["default"])(response.data, fileName);
2981
+ (0, _jsFileDownload["default"])(response.data, fileName, mimeType);
2959
2982
  if (completed !== undefined) {
2960
2983
  completed();
2961
2984
  }
@@ -2963,20 +2986,20 @@ var apiService = function apiService() {
2963
2986
  completed(response.data);
2964
2987
  }
2965
2988
  }
2966
- _context9.next = 14;
2989
+ _context9.next = 25;
2967
2990
  break;
2968
- case 10:
2969
- _context9.prev = 10;
2970
- _context9.t0 = _context9["catch"](1);
2991
+ case 21:
2992
+ _context9.prev = 21;
2993
+ _context9.t0 = _context9["catch"](4);
2971
2994
  console.error(_context9.t0);
2972
2995
  if (completed !== undefined) {
2973
2996
  completed();
2974
2997
  }
2975
- case 14:
2998
+ case 25:
2976
2999
  case "end":
2977
3000
  return _context9.stop();
2978
3001
  }
2979
- }, _callee9, null, [[1, 10]]);
3002
+ }, _callee9, null, [[4, 21]]);
2980
3003
  }));
2981
3004
  function DownloadFile(_x10, _x11, _x12) {
2982
3005
  return _DownloadFile.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.242",
3
+ "version": "1.0.243",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -229,19 +229,29 @@ export const apiService = (ctx = null) => {
229
229
  }
230
230
  return null;
231
231
  },
232
- DownloadFile: async (url, fileName, completed, passData = false) => {
233
-
232
+ DownloadFile : async (url, fileName, completed, method = "get", data = {}, mimeType = "application/octet-stream", passData = false) => {
233
+
234
234
  try
235
235
  {
236
236
  //let defaultOptions = await setupDefaultOptions();
237
237
  let defaultOptions = {};
238
238
  let options = { responseType: "blob" };
239
- let response = await instance.get(url, { ...defaultOptions, ...options });
240
- if (response.status === 200) {
239
+
240
+ let response = null;
241
+ if (method == "get")
242
+ {
243
+ response = await instance.get(url, { ...defaultOptions, ...options });
244
+ }
245
+ else if (method == "post")
246
+ {
247
+ response = await instance.post(url, data, { ...defaultOptions, ...options });
248
+ }
249
+
250
+ if (response != null && response.status === 200) {
241
251
 
242
252
  if (!passData)
243
253
  {
244
- fileDownload(response.data, fileName);
254
+ fileDownload(response.data, fileName, mimeType);
245
255
  if (completed !== undefined) {
246
256
  completed();
247
257
  }
@@ -259,6 +269,7 @@ export const apiService = (ctx = null) => {
259
269
  completed();
260
270
  }
261
271
  }
272
+
262
273
  }
263
274
  }
264
275
  }