files.com 1.0.202 → 1.0.203

Sign up to get free protection for your applications and to get access to all the features.
package/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.202
1
+ 1.0.203
package/lib/Api.js CHANGED
@@ -203,10 +203,10 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
203
203
  sessionId,
204
204
  isCreatingSession,
205
205
  apiKey,
206
+ updatedOptions,
206
207
  requestPath,
207
208
  hasParams,
208
209
  pairs,
209
- updatedOptions,
210
210
  response,
211
211
  _args3 = arguments;
212
212
  return _regenerator.default.wrap(function _callee3$(_context3) {
@@ -216,8 +216,9 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
216
216
  params = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : null;
217
217
  options = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : {};
218
218
  metadata = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : null;
219
- headers = _objectSpread(_objectSpread({}, options.headers), {}, {
220
- Accept: 'application/json',
219
+ headers = _objectSpread(_objectSpread({
220
+ Accept: 'application/json'
221
+ }, options.headers), {}, {
221
222
  'User-Agent': 'Files.com JavaScript SDK v1.0'
222
223
  });
223
224
  isExternal = /^[a-zA-Z]+:\/\//.test(path);
@@ -259,6 +260,9 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
259
260
  headers['X-FilesAPI-Key'] = apiKey;
260
261
 
261
262
  case 17:
263
+ updatedOptions = _objectSpread(_objectSpread({}, options), {}, {
264
+ headers: headers
265
+ });
262
266
  requestPath = path;
263
267
  hasParams = (0, _utils.isObject)(params) && !(0, _utils.isEmpty)(params);
264
268
 
@@ -274,7 +278,7 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
274
278
  requestPath += path.includes('?') ? '&' : '?';
275
279
  requestPath += pairs.join('&');
276
280
  } else {
277
- options.data = JSON.stringify(params);
281
+ updatedOptions.data = JSON.stringify(params);
278
282
  headers['Content-Type'] = 'application/json';
279
283
  }
280
284
  }
@@ -282,7 +286,7 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
282
286
  if (_Files.default.shouldDebugRequest()) {
283
287
  _Logger.default.debug('Request Options:');
284
288
 
285
- _Logger.default.debug(_objectSpread(_objectSpread({}, options), {}, {
289
+ _Logger.default.debug(_objectSpread(_objectSpread({}, updatedOptions), {}, {
286
290
  data: hasParams ? "payload keys: ".concat(Object.keys(params).join(', ')) : '(none)',
287
291
  headers: _objectSpread(_objectSpread({}, headers), {}, {
288
292
  'X-FilesAPI-Key': '<redacted>'
@@ -290,9 +294,6 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
290
294
  }));
291
295
  }
292
296
 
293
- updatedOptions = _objectSpread(_objectSpread({}, options), {}, {
294
- headers: headers
295
- });
296
297
  _context3.next = 24;
297
298
  return Api._sendVerbatim(requestPath, verb, updatedOptions);
298
299
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.0.202",
3
+ "version": "1.0.203",
4
4
  "description": "Files.com SDK for JavaScript",
5
5
  "keywords": [
6
6
  "files.com",
package/src/Api.js CHANGED
@@ -117,8 +117,8 @@ class Api {
117
117
 
118
118
  static sendRequest = async (path, verb, params = null, options = {}, metadata = null) => {
119
119
  const headers = {
120
- ...options.headers,
121
120
  Accept: 'application/json',
121
+ ...options.headers,
122
122
  'User-Agent': 'Files.com JavaScript SDK v1.0',
123
123
  }
124
124
 
@@ -145,6 +145,11 @@ class Api {
145
145
  }
146
146
  }
147
147
 
148
+ const updatedOptions = {
149
+ ...options,
150
+ headers,
151
+ }
152
+
148
153
  let requestPath = path
149
154
  const hasParams = isObject(params) && !isEmpty(params)
150
155
 
@@ -154,7 +159,7 @@ class Api {
154
159
  requestPath += path.includes('?') ? '&' : '?'
155
160
  requestPath += pairs.join('&')
156
161
  } else {
157
- options.data = JSON.stringify(params)
162
+ updatedOptions.data = JSON.stringify(params)
158
163
  headers['Content-Type'] = 'application/json'
159
164
  }
160
165
  }
@@ -162,7 +167,7 @@ class Api {
162
167
  if (Files.shouldDebugRequest()) {
163
168
  Logger.debug('Request Options:')
164
169
  Logger.debug({
165
- ...options,
170
+ ...updatedOptions,
166
171
  data: hasParams
167
172
  ? `payload keys: ${Object.keys(params).join(', ')}`
168
173
  : '(none)',
@@ -173,11 +178,6 @@ class Api {
173
178
  })
174
179
  }
175
180
 
176
- const updatedOptions = {
177
- ...options,
178
- headers,
179
- }
180
-
181
181
  const response = await Api._sendVerbatim(requestPath, verb, updatedOptions)
182
182
 
183
183
  return Api._autoPaginate(path, verb, params, updatedOptions, response, metadata)