glitch-javascript-sdk 0.0.3 → 0.0.4

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/dist/cjs/index.js CHANGED
@@ -15623,15 +15623,21 @@ var Requests = /** @class */ (function () {
15623
15623
  Requests.setAuthToken = function (token) {
15624
15624
  this.authToken = token;
15625
15625
  };
15626
- Requests.request = function (method, url, data) {
15626
+ Requests.request = function (method, url, data, fileData) {
15627
+ var headers = {
15628
+ 'Content-Type': 'application/json',
15629
+ };
15630
+ if (this.authToken) {
15631
+ headers['Authorization'] = "Bearer ".concat(this.authToken);
15632
+ }
15633
+ if (fileData) {
15634
+ headers['Content-Type'] = 'multipart/form-data';
15635
+ }
15627
15636
  var axiosPromise = axios({
15628
15637
  method: method,
15629
15638
  url: "".concat(this.baseUrl).concat(url),
15630
- data: data,
15631
- headers: {
15632
- Authorization: "Bearer ".concat(this.authToken),
15633
- 'Content-Type': 'application/json',
15634
- },
15639
+ data: fileData || data,
15640
+ headers: headers,
15635
15641
  });
15636
15642
  return axiosPromise;
15637
15643
  };
@@ -15653,6 +15659,22 @@ var Requests = /** @class */ (function () {
15653
15659
  Requests.delete = function (url) {
15654
15660
  return this.request('DELETE', url);
15655
15661
  };
15662
+ Requests.uploadFile = function (url, filename, file, data) {
15663
+ var formData = new FormData();
15664
+ formData.append(filename, file);
15665
+ for (var key in data) {
15666
+ formData.append(key, data[key]);
15667
+ }
15668
+ return this.request('POST', url, data, formData);
15669
+ };
15670
+ Requests.uploadBlob = function (url, filename, blob, data) {
15671
+ var formData = new FormData();
15672
+ formData.append(filename, blob);
15673
+ for (var key in data) {
15674
+ formData.append(key, data[key]);
15675
+ }
15676
+ return this.request('POST', url, data, formData);
15677
+ };
15656
15678
  /**
15657
15679
  * The Route class contains the method and url, thereforce items can be
15658
15680
  * automatically routed depending on the configuration.