files.com 1.0.149 → 1.0.153

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.
@@ -0,0 +1,504 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.default = void 0;
7
+
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
14
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
15
+
16
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
17
+
18
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
+
20
+ var _Api = _interopRequireDefault(require("../Api"));
21
+
22
+ var _Logger = _interopRequireDefault(require("../Logger"));
23
+
24
+ var _utils = require("../utils");
25
+
26
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
+
28
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
+
30
+ /**
31
+ * Class As2Station
32
+ */
33
+ var As2Station = /*#__PURE__*/(0, _createClass2.default)(function As2Station() {
34
+ var _this = this;
35
+
36
+ var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
37
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
38
+ (0, _classCallCheck2.default)(this, As2Station);
39
+ (0, _defineProperty2.default)(this, "attributes", {});
40
+ (0, _defineProperty2.default)(this, "options", {});
41
+ (0, _defineProperty2.default)(this, "isLoaded", function () {
42
+ return !!_this.attributes.id;
43
+ });
44
+ (0, _defineProperty2.default)(this, "getId", function () {
45
+ return _this.attributes.id;
46
+ });
47
+ (0, _defineProperty2.default)(this, "setId", function (value) {
48
+ _this.attributes.id = value;
49
+ });
50
+ (0, _defineProperty2.default)(this, "getName", function () {
51
+ return _this.attributes.name;
52
+ });
53
+ (0, _defineProperty2.default)(this, "setName", function (value) {
54
+ _this.attributes.name = value;
55
+ });
56
+ (0, _defineProperty2.default)(this, "getUri", function () {
57
+ return _this.attributes.uri;
58
+ });
59
+ (0, _defineProperty2.default)(this, "setUri", function (value) {
60
+ _this.attributes.uri = value;
61
+ });
62
+ (0, _defineProperty2.default)(this, "getDomain", function () {
63
+ return _this.attributes.domain;
64
+ });
65
+ (0, _defineProperty2.default)(this, "setDomain", function (value) {
66
+ _this.attributes.domain = value;
67
+ });
68
+ (0, _defineProperty2.default)(this, "getPublicCertificate", function () {
69
+ return _this.attributes.public_certificate;
70
+ });
71
+ (0, _defineProperty2.default)(this, "setPublicCertificate", function (value) {
72
+ _this.attributes.public_certificate = value;
73
+ });
74
+ (0, _defineProperty2.default)(this, "getPublicCertificateMd5", function () {
75
+ return _this.attributes.public_certificate_md5;
76
+ });
77
+ (0, _defineProperty2.default)(this, "setPublicCertificateMd5", function (value) {
78
+ _this.attributes.public_certificate_md5 = value;
79
+ });
80
+ (0, _defineProperty2.default)(this, "getPrivateKeyMd5", function () {
81
+ return _this.attributes.private_key_md5;
82
+ });
83
+ (0, _defineProperty2.default)(this, "setPrivateKeyMd5", function (value) {
84
+ _this.attributes.private_key_md5 = value;
85
+ });
86
+ (0, _defineProperty2.default)(this, "getPrivateKey", function () {
87
+ return _this.attributes.private_key;
88
+ });
89
+ (0, _defineProperty2.default)(this, "setPrivateKey", function (value) {
90
+ _this.attributes.private_key = value;
91
+ });
92
+ (0, _defineProperty2.default)(this, "update", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
93
+ var params,
94
+ _args = arguments;
95
+ return _regenerator.default.wrap(function _callee$(_context) {
96
+ while (1) {
97
+ switch (_context.prev = _context.next) {
98
+ case 0:
99
+ params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
100
+
101
+ if (_this.attributes.id) {
102
+ _context.next = 3;
103
+ break;
104
+ }
105
+
106
+ throw new Error('Current object has no id');
107
+
108
+ case 3:
109
+ if ((0, _utils.isObject)(params)) {
110
+ _context.next = 5;
111
+ break;
112
+ }
113
+
114
+ throw new Error("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
115
+
116
+ case 5:
117
+ params.id = _this.attributes.id;
118
+
119
+ if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
120
+ _context.next = 8;
121
+ break;
122
+ }
123
+
124
+ throw new Error("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
125
+
126
+ case 8:
127
+ if (!(params['name'] && !(0, _utils.isString)(params['name']))) {
128
+ _context.next = 10;
129
+ break;
130
+ }
131
+
132
+ throw new Error("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(name)));
133
+
134
+ case 10:
135
+ if (!(params['domain'] && !(0, _utils.isString)(params['domain']))) {
136
+ _context.next = 12;
137
+ break;
138
+ }
139
+
140
+ throw new Error("Bad parameter: domain must be of type String, received ".concat((0, _utils.getType)(domain)));
141
+
142
+ case 12:
143
+ if (!(params['uri'] && !(0, _utils.isString)(params['uri']))) {
144
+ _context.next = 14;
145
+ break;
146
+ }
147
+
148
+ throw new Error("Bad parameter: uri must be of type String, received ".concat((0, _utils.getType)(uri)));
149
+
150
+ case 14:
151
+ if (!(params['public_certificate'] && !(0, _utils.isString)(params['public_certificate']))) {
152
+ _context.next = 16;
153
+ break;
154
+ }
155
+
156
+ throw new Error("Bad parameter: public_certificate must be of type String, received ".concat((0, _utils.getType)(public_certificate)));
157
+
158
+ case 16:
159
+ if (!(params['private_key'] && !(0, _utils.isString)(params['private_key']))) {
160
+ _context.next = 18;
161
+ break;
162
+ }
163
+
164
+ throw new Error("Bad parameter: private_key must be of type String, received ".concat((0, _utils.getType)(private_key)));
165
+
166
+ case 18:
167
+ if (params['id']) {
168
+ _context.next = 24;
169
+ break;
170
+ }
171
+
172
+ if (!_this.attributes.id) {
173
+ _context.next = 23;
174
+ break;
175
+ }
176
+
177
+ params['id'] = _this.id;
178
+ _context.next = 24;
179
+ break;
180
+
181
+ case 23:
182
+ throw new Error('Parameter missing: id');
183
+
184
+ case 24:
185
+ return _context.abrupt("return", _Api.default.sendRequest("/as2_stations/".concat(params['id']), 'PATCH', params, _this.options));
186
+
187
+ case 25:
188
+ case "end":
189
+ return _context.stop();
190
+ }
191
+ }
192
+ }, _callee);
193
+ })));
194
+ (0, _defineProperty2.default)(this, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
195
+ var params,
196
+ _args2 = arguments;
197
+ return _regenerator.default.wrap(function _callee2$(_context2) {
198
+ while (1) {
199
+ switch (_context2.prev = _context2.next) {
200
+ case 0:
201
+ params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
202
+
203
+ if (_this.attributes.id) {
204
+ _context2.next = 3;
205
+ break;
206
+ }
207
+
208
+ throw new Error('Current object has no id');
209
+
210
+ case 3:
211
+ if ((0, _utils.isObject)(params)) {
212
+ _context2.next = 5;
213
+ break;
214
+ }
215
+
216
+ throw new Error("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
217
+
218
+ case 5:
219
+ params.id = _this.attributes.id;
220
+
221
+ if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
222
+ _context2.next = 8;
223
+ break;
224
+ }
225
+
226
+ throw new Error("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
227
+
228
+ case 8:
229
+ if (params['id']) {
230
+ _context2.next = 14;
231
+ break;
232
+ }
233
+
234
+ if (!_this.attributes.id) {
235
+ _context2.next = 13;
236
+ break;
237
+ }
238
+
239
+ params['id'] = _this.id;
240
+ _context2.next = 14;
241
+ break;
242
+
243
+ case 13:
244
+ throw new Error('Parameter missing: id');
245
+
246
+ case 14:
247
+ return _context2.abrupt("return", _Api.default.sendRequest("/as2_stations/".concat(params['id']), 'DELETE', params, _this.options));
248
+
249
+ case 15:
250
+ case "end":
251
+ return _context2.stop();
252
+ }
253
+ }
254
+ }, _callee2);
255
+ })));
256
+ (0, _defineProperty2.default)(this, "destroy", function () {
257
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
258
+ return _this.delete(params);
259
+ });
260
+ (0, _defineProperty2.default)(this, "save", function () {
261
+ if (_this.attributes['id']) {
262
+ return _this.update(_this.attributes);
263
+ } else {
264
+ var newObject = As2Station.create(_this.attributes, _this.options);
265
+ _this.attributes = _objectSpread({}, newObject.attributes);
266
+ return true;
267
+ }
268
+ });
269
+ Object.entries(attributes).forEach(function (_ref3) {
270
+ var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
271
+ key = _ref4[0],
272
+ value = _ref4[1];
273
+
274
+ var normalizedKey = key.replace('?', '');
275
+ _this.attributes[normalizedKey] = value;
276
+ Object.defineProperty(_this, normalizedKey, {
277
+ value: value,
278
+ writable: false
279
+ });
280
+ });
281
+ this.options = _objectSpread({}, options);
282
+ });
283
+ (0, _defineProperty2.default)(As2Station, "list", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
284
+ var _response$data;
285
+
286
+ var params,
287
+ options,
288
+ response,
289
+ _args3 = arguments;
290
+ return _regenerator.default.wrap(function _callee3$(_context3) {
291
+ while (1) {
292
+ switch (_context3.prev = _context3.next) {
293
+ case 0:
294
+ params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
295
+ options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
296
+
297
+ if (!(params['cursor'] && !(0, _utils.isString)(params['cursor']))) {
298
+ _context3.next = 4;
299
+ break;
300
+ }
301
+
302
+ throw new Error("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(cursor)));
303
+
304
+ case 4:
305
+ if (!(params['per_page'] && !(0, _utils.isInt)(params['per_page']))) {
306
+ _context3.next = 6;
307
+ break;
308
+ }
309
+
310
+ throw new Error("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(per_page)));
311
+
312
+ case 6:
313
+ _context3.next = 8;
314
+ return _Api.default.sendRequest("/as2_stations", 'GET', params, options);
315
+
316
+ case 8:
317
+ response = _context3.sent;
318
+ return _context3.abrupt("return", (response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.map(function (obj) {
319
+ return new As2Station(obj, options);
320
+ })) || []);
321
+
322
+ case 10:
323
+ case "end":
324
+ return _context3.stop();
325
+ }
326
+ }
327
+ }, _callee3);
328
+ })));
329
+ (0, _defineProperty2.default)(As2Station, "all", function () {
330
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
331
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
332
+ return As2Station.list(params, options);
333
+ });
334
+ (0, _defineProperty2.default)(As2Station, "find", /*#__PURE__*/function () {
335
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id) {
336
+ var params,
337
+ options,
338
+ response,
339
+ _args4 = arguments;
340
+ return _regenerator.default.wrap(function _callee4$(_context4) {
341
+ while (1) {
342
+ switch (_context4.prev = _context4.next) {
343
+ case 0:
344
+ params = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
345
+ options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
346
+
347
+ if ((0, _utils.isObject)(params)) {
348
+ _context4.next = 4;
349
+ break;
350
+ }
351
+
352
+ throw new Error("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
353
+
354
+ case 4:
355
+ params['id'] = id;
356
+
357
+ if (params['id']) {
358
+ _context4.next = 7;
359
+ break;
360
+ }
361
+
362
+ throw new Error('Parameter missing: id');
363
+
364
+ case 7:
365
+ if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
366
+ _context4.next = 9;
367
+ break;
368
+ }
369
+
370
+ throw new Error("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
371
+
372
+ case 9:
373
+ _context4.next = 11;
374
+ return _Api.default.sendRequest("/as2_stations/".concat(params['id']), 'GET', params, options);
375
+
376
+ case 11:
377
+ response = _context4.sent;
378
+ return _context4.abrupt("return", new As2Station(response === null || response === void 0 ? void 0 : response.data, options));
379
+
380
+ case 13:
381
+ case "end":
382
+ return _context4.stop();
383
+ }
384
+ }
385
+ }, _callee4);
386
+ }));
387
+
388
+ return function (_x) {
389
+ return _ref6.apply(this, arguments);
390
+ };
391
+ }());
392
+ (0, _defineProperty2.default)(As2Station, "get", function (id) {
393
+ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
394
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
395
+ return As2Station.find(id, params, options);
396
+ });
397
+ (0, _defineProperty2.default)(As2Station, "create", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
398
+ var params,
399
+ options,
400
+ response,
401
+ _args5 = arguments;
402
+ return _regenerator.default.wrap(function _callee5$(_context5) {
403
+ while (1) {
404
+ switch (_context5.prev = _context5.next) {
405
+ case 0:
406
+ params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
407
+ options = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
408
+
409
+ if (params['name']) {
410
+ _context5.next = 4;
411
+ break;
412
+ }
413
+
414
+ throw new Error('Parameter missing: name');
415
+
416
+ case 4:
417
+ if (params['domain']) {
418
+ _context5.next = 6;
419
+ break;
420
+ }
421
+
422
+ throw new Error('Parameter missing: domain');
423
+
424
+ case 6:
425
+ if (params['uri']) {
426
+ _context5.next = 8;
427
+ break;
428
+ }
429
+
430
+ throw new Error('Parameter missing: uri');
431
+
432
+ case 8:
433
+ if (params['public_certificate']) {
434
+ _context5.next = 10;
435
+ break;
436
+ }
437
+
438
+ throw new Error('Parameter missing: public_certificate');
439
+
440
+ case 10:
441
+ if (params['private_key']) {
442
+ _context5.next = 12;
443
+ break;
444
+ }
445
+
446
+ throw new Error('Parameter missing: private_key');
447
+
448
+ case 12:
449
+ if (!(params['name'] && !(0, _utils.isString)(params['name']))) {
450
+ _context5.next = 14;
451
+ break;
452
+ }
453
+
454
+ throw new Error("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(name)));
455
+
456
+ case 14:
457
+ if (!(params['domain'] && !(0, _utils.isString)(params['domain']))) {
458
+ _context5.next = 16;
459
+ break;
460
+ }
461
+
462
+ throw new Error("Bad parameter: domain must be of type String, received ".concat((0, _utils.getType)(domain)));
463
+
464
+ case 16:
465
+ if (!(params['uri'] && !(0, _utils.isString)(params['uri']))) {
466
+ _context5.next = 18;
467
+ break;
468
+ }
469
+
470
+ throw new Error("Bad parameter: uri must be of type String, received ".concat((0, _utils.getType)(uri)));
471
+
472
+ case 18:
473
+ if (!(params['public_certificate'] && !(0, _utils.isString)(params['public_certificate']))) {
474
+ _context5.next = 20;
475
+ break;
476
+ }
477
+
478
+ throw new Error("Bad parameter: public_certificate must be of type String, received ".concat((0, _utils.getType)(public_certificate)));
479
+
480
+ case 20:
481
+ if (!(params['private_key'] && !(0, _utils.isString)(params['private_key']))) {
482
+ _context5.next = 22;
483
+ break;
484
+ }
485
+
486
+ throw new Error("Bad parameter: private_key must be of type String, received ".concat((0, _utils.getType)(private_key)));
487
+
488
+ case 22:
489
+ _context5.next = 24;
490
+ return _Api.default.sendRequest("/as2_stations", 'POST', params, options);
491
+
492
+ case 24:
493
+ response = _context5.sent;
494
+ return _context5.abrupt("return", new As2Station(response === null || response === void 0 ? void 0 : response.data, options));
495
+
496
+ case 26:
497
+ case "end":
498
+ return _context5.stop();
499
+ }
500
+ }
501
+ }, _callee5);
502
+ })));
503
+ var _default = As2Station;
504
+ exports.default = _default;
@@ -143,12 +143,6 @@ var Automation = /*#__PURE__*/(0, _createClass2.default)(function Automation() {
143
143
  (0, _defineProperty2.default)(this, "setTriggerActions", function (value) {
144
144
  _this.attributes.trigger_actions = value;
145
145
  });
146
- (0, _defineProperty2.default)(this, "getTriggerActionPath", function () {
147
- return _this.attributes.trigger_action_path;
148
- });
149
- (0, _defineProperty2.default)(this, "setTriggerActionPath", function (value) {
150
- _this.attributes.trigger_action_path = value;
151
- });
152
146
  (0, _defineProperty2.default)(this, "getValue", function () {
153
147
  return _this.attributes.value;
154
148
  });
@@ -308,53 +302,45 @@ var Automation = /*#__PURE__*/(0, _createClass2.default)(function Automation() {
308
302
  throw new Error("Bad parameter: trigger_actions must be of type Array, received ".concat((0, _utils.getType)(trigger_actions)));
309
303
 
310
304
  case 36:
311
- if (!(params['trigger_action_path'] && !(0, _utils.isString)(params['trigger_action_path']))) {
312
- _context.next = 38;
313
- break;
314
- }
315
-
316
- throw new Error("Bad parameter: trigger_action_path must be of type String, received ".concat((0, _utils.getType)(trigger_action_path)));
317
-
318
- case 38:
319
305
  if (params['id']) {
320
- _context.next = 44;
306
+ _context.next = 42;
321
307
  break;
322
308
  }
323
309
 
324
310
  if (!_this.attributes.id) {
325
- _context.next = 43;
311
+ _context.next = 41;
326
312
  break;
327
313
  }
328
314
 
329
315
  params['id'] = _this.id;
330
- _context.next = 44;
316
+ _context.next = 42;
331
317
  break;
332
318
 
333
- case 43:
319
+ case 41:
334
320
  throw new Error('Parameter missing: id');
335
321
 
336
- case 44:
322
+ case 42:
337
323
  if (params['automation']) {
338
- _context.next = 50;
324
+ _context.next = 48;
339
325
  break;
340
326
  }
341
327
 
342
328
  if (!_this.attributes.automation) {
343
- _context.next = 49;
329
+ _context.next = 47;
344
330
  break;
345
331
  }
346
332
 
347
333
  params['automation'] = _this.automation;
348
- _context.next = 50;
334
+ _context.next = 48;
349
335
  break;
350
336
 
351
- case 49:
337
+ case 47:
352
338
  throw new Error('Parameter missing: automation');
353
339
 
354
- case 50:
340
+ case 48:
355
341
  return _context.abrupt("return", _Api.default.sendRequest("/automations/".concat(params['id']), 'PATCH', params, _this.options));
356
342
 
357
- case 51:
343
+ case 49:
358
344
  case "end":
359
345
  return _context.stop();
360
346
  }
@@ -704,22 +690,14 @@ var Automation = /*#__PURE__*/(0, _createClass2.default)(function Automation() {
704
690
  throw new Error("Bad parameter: trigger_actions must be of type Array, received ".concat((0, _utils.getType)(trigger_actions)));
705
691
 
706
692
  case 32:
707
- if (!(params['trigger_action_path'] && !(0, _utils.isString)(params['trigger_action_path']))) {
708
- _context5.next = 34;
709
- break;
710
- }
711
-
712
- throw new Error("Bad parameter: trigger_action_path must be of type String, received ".concat((0, _utils.getType)(trigger_action_path)));
713
-
714
- case 34:
715
- _context5.next = 36;
693
+ _context5.next = 34;
716
694
  return _Api.default.sendRequest("/automations", 'POST', params, options);
717
695
 
718
- case 36:
696
+ case 34:
719
697
  response = _context5.sent;
720
698
  return _context5.abrupt("return", new Automation(response === null || response === void 0 ? void 0 : response.data, options));
721
699
 
722
- case 38:
700
+ case 36:
723
701
  case "end":
724
702
  return _context5.stop();
725
703
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.0.149",
3
+ "version": "1.0.153",
4
4
  "description": "Files.com SDK for JavaScript",
5
5
  "keywords": [
6
6
  "files.com",