@blues-inc/notehub-js 1.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.
Files changed (83) hide show
  1. package/README.md +297 -0
  2. package/dist/ApiClient.js +699 -0
  3. package/dist/api/AuthorizationApi.js +74 -0
  4. package/dist/api/BillingAccountApi.js +68 -0
  5. package/dist/api/DeviceApi.js +784 -0
  6. package/dist/api/DevicesApi.js +293 -0
  7. package/dist/api/EnvironmentVariablesApi.js +567 -0
  8. package/dist/api/EventApi.js +284 -0
  9. package/dist/api/FilesApi.js +193 -0
  10. package/dist/api/FleetApi.js +715 -0
  11. package/dist/api/NotesApi.js +435 -0
  12. package/dist/api/ProductApi.js +163 -0
  13. package/dist/api/ProjectApi.js +716 -0
  14. package/dist/api/RouteApi.js +266 -0
  15. package/dist/index.js +566 -0
  16. package/dist/model/Aws.js +233 -0
  17. package/dist/model/Azure.js +166 -0
  18. package/dist/model/BillingAccount.js +130 -0
  19. package/dist/model/BillingAccountRole.js +42 -0
  20. package/dist/model/Body.js +78 -0
  21. package/dist/model/Contact.js +118 -0
  22. package/dist/model/CreateFleetRequest.js +83 -0
  23. package/dist/model/CreateProductRequest.js +142 -0
  24. package/dist/model/CreateProjectRequest.js +119 -0
  25. package/dist/model/DFUEnv.js +97 -0
  26. package/dist/model/DFUState.js +276 -0
  27. package/dist/model/DeleteDeviceFleetsRequest.js +106 -0
  28. package/dist/model/Device.js +267 -0
  29. package/dist/model/DeviceSession.js +537 -0
  30. package/dist/model/DeviceTowerInfo.js +102 -0
  31. package/dist/model/DeviceUsage.js +150 -0
  32. package/dist/model/EnvironmentVariables.js +103 -0
  33. package/dist/model/Error.js +164 -0
  34. package/dist/model/Event.js +676 -0
  35. package/dist/model/Fleet.js +129 -0
  36. package/dist/model/GetBillingAccounts200Response.js +103 -0
  37. package/dist/model/GetDeviceEnvironmentVariables200Response.js +117 -0
  38. package/dist/model/GetDeviceHealthLog200Response.js +123 -0
  39. package/dist/model/GetDeviceHealthLog200ResponseHealthLogInner.js +125 -0
  40. package/dist/model/GetDeviceLatest200Response.js +104 -0
  41. package/dist/model/GetDevicePublicKey200Response.js +119 -0
  42. package/dist/model/GetDeviceSessions200Response.js +133 -0
  43. package/dist/model/GetProjectDevicePublicKeys200Response.js +133 -0
  44. package/dist/model/GetProjectDevicePublicKeys200ResponseDevicePublicKeysInner.js +94 -0
  45. package/dist/model/GetProjectDevices200Response.js +133 -0
  46. package/dist/model/GetProjectEvents200Response.js +149 -0
  47. package/dist/model/GetProjectEventsByCursor200Response.js +149 -0
  48. package/dist/model/GetProjectFleets200Response.js +123 -0
  49. package/dist/model/GetProjectMembers200Response.js +123 -0
  50. package/dist/model/GetProjectProducts200Response.js +103 -0
  51. package/dist/model/GetProjects200Response.js +103 -0
  52. package/dist/model/Google.js +142 -0
  53. package/dist/model/HandleNoteChanges200Response.js +97 -0
  54. package/dist/model/HandleNoteGet200Response.js +101 -0
  55. package/dist/model/HandleNoteSignal200Response.js +79 -0
  56. package/dist/model/HandleNotefileChanges200Response.js +97 -0
  57. package/dist/model/HandleNotefileChangesPending200Response.js +106 -0
  58. package/dist/model/HandleNotefileDeleteRequest.js +83 -0
  59. package/dist/model/Http.js +163 -0
  60. package/dist/model/HttpFilter.js +128 -0
  61. package/dist/model/HttpTransform.js +139 -0
  62. package/dist/model/Location.js +167 -0
  63. package/dist/model/Login200Response.js +82 -0
  64. package/dist/model/LoginRequest.js +94 -0
  65. package/dist/model/Mqtt.js +240 -0
  66. package/dist/model/Note.js +90 -0
  67. package/dist/model/Product.js +141 -0
  68. package/dist/model/Project.js +165 -0
  69. package/dist/model/ProjectMember.js +131 -0
  70. package/dist/model/Proxy.js +128 -0
  71. package/dist/model/PutDeviceFleetsRequest.js +106 -0
  72. package/dist/model/Radresponder.js +130 -0
  73. package/dist/model/Role.js +43 -0
  74. package/dist/model/Route.js +245 -0
  75. package/dist/model/RouteSchema.js +427 -0
  76. package/dist/model/Snowflake.js +185 -0
  77. package/dist/model/SnowflakeTransform.js +97 -0
  78. package/dist/model/Thingworx.js +154 -0
  79. package/dist/model/TowerLocation.js +204 -0
  80. package/dist/model/Twilio.js +181 -0
  81. package/dist/model/UpdateFleetRequest.js +109 -0
  82. package/dist/model/UserDbRoute.js +131 -0
  83. package/package.json +49 -0
@@ -0,0 +1,699 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _superagent = _interopRequireDefault(require("superagent"));
8
+ var _querystring = _interopRequireDefault(require("querystring"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
10
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
11
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
12
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
13
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
+ /**
17
+ * @module ApiClient
18
+ * @version 1.0.4
19
+ */
20
+ /**
21
+ * Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
22
+ * application to use this class directly - the *Api and model classes provide the public API for the service. The
23
+ * contents of this file should be regarded as internal but are documented for completeness.
24
+ * @alias module:ApiClient
25
+ * @class
26
+ */
27
+ var ApiClient = /*#__PURE__*/function () {
28
+ /**
29
+ * The base URL against which to resolve every API call's (relative) path.
30
+ * Overrides the default value set in spec file if present
31
+ * @param {String} basePath
32
+ */
33
+ function ApiClient() {
34
+ var basePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'https://api.notefile.net';
35
+ _classCallCheck(this, ApiClient);
36
+ /**
37
+ * The base URL against which to resolve every API call's (relative) path.
38
+ * @type {String}
39
+ * @default https://api.notefile.net
40
+ */
41
+ this.basePath = basePath.replace(/\/+$/, '');
42
+
43
+ /**
44
+ * The authentication methods to be included for all API calls.
45
+ * @type {Array.<String>}
46
+ */
47
+ this.authentications = {
48
+ 'api_key': {
49
+ type: 'apiKey',
50
+ 'in': 'header',
51
+ name: 'X-Session-Token'
52
+ },
53
+ 'pin': {
54
+ type: 'apiKey',
55
+ 'in': 'header',
56
+ name: 'X-Auth-Token'
57
+ }
58
+ };
59
+
60
+ /**
61
+ * The default HTTP headers to be included for all API calls.
62
+ * @type {Array.<String>}
63
+ * @default {}
64
+ */
65
+ this.defaultHeaders = {
66
+ 'User-Agent': 'OpenAPI-Generator/1.0.4/Javascript'
67
+ };
68
+
69
+ /**
70
+ * The default HTTP timeout for all API calls.
71
+ * @type {Number}
72
+ * @default 60000
73
+ */
74
+ this.timeout = 60000;
75
+
76
+ /**
77
+ * If set to false an additional timestamp parameter is added to all API GET calls to
78
+ * prevent browser caching
79
+ * @type {Boolean}
80
+ * @default true
81
+ */
82
+ this.cache = true;
83
+
84
+ /**
85
+ * If set to true, the client will save the cookies from each server
86
+ * response, and return them in the next request.
87
+ * @default false
88
+ */
89
+ this.enableCookies = false;
90
+
91
+ /*
92
+ * Used to save and return cookies in a node.js (non-browser) setting,
93
+ * if this.enableCookies is set to true.
94
+ */
95
+ if (typeof window === 'undefined') {
96
+ this.agent = new _superagent["default"].agent();
97
+ }
98
+
99
+ /*
100
+ * Allow user to override superagent agent
101
+ */
102
+ this.requestAgent = null;
103
+
104
+ /*
105
+ * Allow user to add superagent plugins
106
+ */
107
+ this.plugins = null;
108
+ }
109
+
110
+ /**
111
+ * Returns a string representation for an actual parameter.
112
+ * @param param The actual parameter.
113
+ * @returns {String} The string representation of <code>param</code>.
114
+ */
115
+ _createClass(ApiClient, [{
116
+ key: "paramToString",
117
+ value: function paramToString(param) {
118
+ if (param == undefined || param == null) {
119
+ return '';
120
+ }
121
+ if (param instanceof Date) {
122
+ return param.toJSON();
123
+ }
124
+ if (ApiClient.canBeJsonified(param)) {
125
+ return JSON.stringify(param);
126
+ }
127
+ return param.toString();
128
+ }
129
+
130
+ /**
131
+ * Returns a boolean indicating if the parameter could be JSON.stringified
132
+ * @param param The actual parameter
133
+ * @returns {Boolean} Flag indicating if <code>param</code> can be JSON.stringified
134
+ */
135
+ }, {
136
+ key: "buildUrl",
137
+ value:
138
+ /**
139
+ * Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values.
140
+ * NOTE: query parameters are not handled here.
141
+ * @param {String} path The path to append to the base URL.
142
+ * @param {Object} pathParams The parameter values to append.
143
+ * @param {String} apiBasePath Base path defined in the path, operation level to override the default one
144
+ * @returns {String} The encoded path with parameter values substituted.
145
+ */
146
+ function buildUrl(path, pathParams, apiBasePath) {
147
+ var _this = this;
148
+ if (!path.match(/^\//)) {
149
+ path = '/' + path;
150
+ }
151
+ var url = this.basePath + path;
152
+
153
+ // use API (operation, path) base path if defined
154
+ if (apiBasePath !== null && apiBasePath !== undefined) {
155
+ url = apiBasePath + path;
156
+ }
157
+ url = url.replace(/\{([\w-\.]+)\}/g, function (fullMatch, key) {
158
+ var value;
159
+ if (pathParams.hasOwnProperty(key)) {
160
+ value = _this.paramToString(pathParams[key]);
161
+ } else {
162
+ value = fullMatch;
163
+ }
164
+ return value;
165
+ });
166
+ return url;
167
+ }
168
+
169
+ /**
170
+ * Checks whether the given content type represents JSON.<br>
171
+ * JSON content type examples:<br>
172
+ * <ul>
173
+ * <li>application/json</li>
174
+ * <li>application/json; charset=UTF8</li>
175
+ * <li>APPLICATION/JSON</li>
176
+ * </ul>
177
+ * @param {String} contentType The MIME content type to check.
178
+ * @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>.
179
+ */
180
+ }, {
181
+ key: "isJsonMime",
182
+ value: function isJsonMime(contentType) {
183
+ return Boolean(contentType != null && contentType.match(/^application\/json(;.*)?$/i));
184
+ }
185
+
186
+ /**
187
+ * Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
188
+ * @param {Array.<String>} contentTypes
189
+ * @returns {String} The chosen content type, preferring JSON.
190
+ */
191
+ }, {
192
+ key: "jsonPreferredMime",
193
+ value: function jsonPreferredMime(contentTypes) {
194
+ for (var i = 0; i < contentTypes.length; i++) {
195
+ if (this.isJsonMime(contentTypes[i])) {
196
+ return contentTypes[i];
197
+ }
198
+ }
199
+ return contentTypes[0];
200
+ }
201
+
202
+ /**
203
+ * Checks whether the given parameter value represents file-like content.
204
+ * @param param The parameter to check.
205
+ * @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
206
+ */
207
+ }, {
208
+ key: "isFileParam",
209
+ value: function isFileParam(param) {
210
+ // fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
211
+ if (typeof require === 'function') {
212
+ var fs;
213
+ try {
214
+ fs = require('fs');
215
+ } catch (err) {}
216
+ if (fs && fs.ReadStream && param instanceof fs.ReadStream) {
217
+ return true;
218
+ }
219
+ }
220
+
221
+ // Buffer in Node.js
222
+ if (typeof Buffer === 'function' && param instanceof Buffer) {
223
+ return true;
224
+ }
225
+
226
+ // Blob in browser
227
+ if (typeof Blob === 'function' && param instanceof Blob) {
228
+ return true;
229
+ }
230
+
231
+ // File in browser (it seems File object is also instance of Blob, but keep this for safe)
232
+ if (typeof File === 'function' && param instanceof File) {
233
+ return true;
234
+ }
235
+ return false;
236
+ }
237
+
238
+ /**
239
+ * Normalizes parameter values:
240
+ * <ul>
241
+ * <li>remove nils</li>
242
+ * <li>keep files and arrays</li>
243
+ * <li>format to string with `paramToString` for other cases</li>
244
+ * </ul>
245
+ * @param {Object.<String, Object>} params The parameters as object properties.
246
+ * @returns {Object.<String, Object>} normalized parameters.
247
+ */
248
+ }, {
249
+ key: "normalizeParams",
250
+ value: function normalizeParams(params) {
251
+ var newParams = {};
252
+ for (var key in params) {
253
+ if (params.hasOwnProperty(key) && params[key] != undefined && params[key] != null) {
254
+ var value = params[key];
255
+ if (this.isFileParam(value) || Array.isArray(value)) {
256
+ newParams[key] = value;
257
+ } else {
258
+ newParams[key] = this.paramToString(value);
259
+ }
260
+ }
261
+ }
262
+ return newParams;
263
+ }
264
+
265
+ /**
266
+ * Builds a string representation of an array-type actual parameter, according to the given collection format.
267
+ * @param {Array} param An array parameter.
268
+ * @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
269
+ * @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
270
+ * <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
271
+ */
272
+ }, {
273
+ key: "buildCollectionParam",
274
+ value: function buildCollectionParam(param, collectionFormat) {
275
+ if (param == null) {
276
+ return null;
277
+ }
278
+ switch (collectionFormat) {
279
+ case 'csv':
280
+ return param.map(this.paramToString, this).join(',');
281
+ case 'ssv':
282
+ return param.map(this.paramToString, this).join(' ');
283
+ case 'tsv':
284
+ return param.map(this.paramToString, this).join('\t');
285
+ case 'pipes':
286
+ return param.map(this.paramToString, this).join('|');
287
+ case 'multi':
288
+ //return the array directly as SuperAgent will handle it as expected
289
+ return param.map(this.paramToString, this);
290
+ case 'passthrough':
291
+ return param;
292
+ default:
293
+ throw new Error('Unknown collection format: ' + collectionFormat);
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Applies authentication headers to the request.
299
+ * @param {Object} request The request object created by a <code>superagent()</code> call.
300
+ * @param {Array.<String>} authNames An array of authentication method names.
301
+ */
302
+ }, {
303
+ key: "applyAuthToRequest",
304
+ value: function applyAuthToRequest(request, authNames) {
305
+ var _this2 = this;
306
+ authNames.forEach(function (authName) {
307
+ var auth = _this2.authentications[authName];
308
+ switch (auth.type) {
309
+ case 'basic':
310
+ if (auth.username || auth.password) {
311
+ request.auth(auth.username || '', auth.password || '');
312
+ }
313
+ break;
314
+ case 'bearer':
315
+ if (auth.accessToken) {
316
+ var localVarBearerToken = typeof auth.accessToken === 'function' ? auth.accessToken() : auth.accessToken;
317
+ request.set({
318
+ 'Authorization': 'Bearer ' + localVarBearerToken
319
+ });
320
+ }
321
+ break;
322
+ case 'apiKey':
323
+ if (auth.apiKey) {
324
+ var data = {};
325
+ if (auth.apiKeyPrefix) {
326
+ data[auth.name] = auth.apiKeyPrefix + ' ' + auth.apiKey;
327
+ } else {
328
+ data[auth.name] = auth.apiKey;
329
+ }
330
+ if (auth['in'] === 'header') {
331
+ request.set(data);
332
+ } else {
333
+ request.query(data);
334
+ }
335
+ }
336
+ break;
337
+ case 'oauth2':
338
+ if (auth.accessToken) {
339
+ request.set({
340
+ 'Authorization': 'Bearer ' + auth.accessToken
341
+ });
342
+ }
343
+ break;
344
+ default:
345
+ throw new Error('Unknown authentication type: ' + auth.type);
346
+ }
347
+ });
348
+ }
349
+
350
+ /**
351
+ * Deserializes an HTTP response body into a value of the specified type.
352
+ * @param {Object} response A SuperAgent response object.
353
+ * @param {(String|Array.<String>|Object.<String, Object>|Function)} returnType The type to return. Pass a string for simple types
354
+ * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
355
+ * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
356
+ * all properties on <code>data<code> will be converted to this type.
357
+ * @returns A value of the specified type.
358
+ */
359
+ }, {
360
+ key: "deserialize",
361
+ value: function deserialize(response, returnType) {
362
+ if (response == null || returnType == null || response.status == 204) {
363
+ return null;
364
+ }
365
+
366
+ // Rely on SuperAgent for parsing response body.
367
+ // See http://visionmedia.github.io/superagent/#parsing-response-bodies
368
+ var data = response.body;
369
+ if (data == null || _typeof(data) === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length) {
370
+ // SuperAgent does not always produce a body; use the unparsed response as a fallback
371
+ data = response.text;
372
+ }
373
+ return ApiClient.convertToType(data, returnType);
374
+ }
375
+
376
+ /**
377
+ * Invokes the REST service using the supplied settings and parameters.
378
+ * @param {String} path The base URL to invoke.
379
+ * @param {String} httpMethod The HTTP method to use.
380
+ * @param {Object.<String, String>} pathParams A map of path parameters and their values.
381
+ * @param {Object.<String, Object>} queryParams A map of query parameters and their values.
382
+ * @param {Object.<String, Object>} headerParams A map of header parameters and their values.
383
+ * @param {Object.<String, Object>} formParams A map of form parameters and their values.
384
+ * @param {Object} bodyParam The value to pass as the request body.
385
+ * @param {Array.<String>} authNames An array of authentication type names.
386
+ * @param {Array.<String>} contentTypes An array of request MIME types.
387
+ * @param {Array.<String>} accepts An array of acceptable response MIME types.
388
+ * @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
389
+ * constructor for a complex type.
390
+ * @param {String} apiBasePath base path defined in the operation/path level to override the default one
391
+ * @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
392
+ */
393
+ }, {
394
+ key: "callApi",
395
+ value: function callApi(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType, apiBasePath) {
396
+ var _this3 = this;
397
+ var url = this.buildUrl(path, pathParams, apiBasePath);
398
+ var request = (0, _superagent["default"])(httpMethod, url);
399
+ if (this.plugins !== null) {
400
+ for (var index in this.plugins) {
401
+ if (this.plugins.hasOwnProperty(index)) {
402
+ request.use(this.plugins[index]);
403
+ }
404
+ }
405
+ }
406
+
407
+ // apply authentications
408
+ this.applyAuthToRequest(request, authNames);
409
+
410
+ // set query parameters
411
+ if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
412
+ queryParams['_'] = new Date().getTime();
413
+ }
414
+ request.query(this.normalizeParams(queryParams));
415
+
416
+ // set header parameters
417
+ request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
418
+
419
+ // set requestAgent if it is set by user
420
+ if (this.requestAgent) {
421
+ request.agent(this.requestAgent);
422
+ }
423
+
424
+ // set request timeout
425
+ request.timeout(this.timeout);
426
+ var contentType = this.jsonPreferredMime(contentTypes);
427
+ if (contentType) {
428
+ // Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
429
+ if (contentType != 'multipart/form-data') {
430
+ request.type(contentType);
431
+ }
432
+ }
433
+ if (contentType === 'application/x-www-form-urlencoded') {
434
+ request.send(_querystring["default"].stringify(this.normalizeParams(formParams)));
435
+ } else if (contentType == 'multipart/form-data') {
436
+ var _formParams = this.normalizeParams(formParams);
437
+ for (var key in _formParams) {
438
+ if (_formParams.hasOwnProperty(key)) {
439
+ var _formParamsValue = _formParams[key];
440
+ if (this.isFileParam(_formParamsValue)) {
441
+ // file field
442
+ request.attach(key, _formParamsValue);
443
+ } else if (Array.isArray(_formParamsValue) && _formParamsValue.length && this.isFileParam(_formParamsValue[0])) {
444
+ // multiple files
445
+ _formParamsValue.forEach(function (file) {
446
+ return request.attach(key, file);
447
+ });
448
+ } else {
449
+ request.field(key, _formParamsValue);
450
+ }
451
+ }
452
+ }
453
+ } else if (bodyParam !== null && bodyParam !== undefined) {
454
+ if (!request.header['Content-Type']) {
455
+ request.type('application/json');
456
+ }
457
+ request.send(bodyParam);
458
+ }
459
+ var accept = this.jsonPreferredMime(accepts);
460
+ if (accept) {
461
+ request.accept(accept);
462
+ }
463
+ if (returnType === 'Blob') {
464
+ request.responseType('blob');
465
+ } else if (returnType === 'String') {
466
+ request.responseType('text');
467
+ }
468
+
469
+ // Attach previously saved cookies, if enabled
470
+ if (this.enableCookies) {
471
+ if (typeof window === 'undefined') {
472
+ this.agent._attachCookies(request);
473
+ } else {
474
+ request.withCredentials();
475
+ }
476
+ }
477
+ return new Promise(function (resolve, reject) {
478
+ request.end(function (error, response) {
479
+ if (error) {
480
+ var err = {};
481
+ if (response) {
482
+ err.status = response.status;
483
+ err.statusText = response.statusText;
484
+ err.body = response.body;
485
+ err.response = response;
486
+ }
487
+ err.error = error;
488
+ reject(err);
489
+ } else {
490
+ try {
491
+ var data = _this3.deserialize(response, returnType);
492
+ if (_this3.enableCookies && typeof window === 'undefined') {
493
+ _this3.agent._saveCookies(response);
494
+ }
495
+ resolve({
496
+ data: data,
497
+ response: response
498
+ });
499
+ } catch (err) {
500
+ reject(err);
501
+ }
502
+ }
503
+ });
504
+ });
505
+ }
506
+
507
+ /**
508
+ * Parses an ISO-8601 string representation or epoch representation of a date value.
509
+ * @param {String} str The date value as a string.
510
+ * @returns {Date} The parsed date object.
511
+ */
512
+ }, {
513
+ key: "hostSettings",
514
+ value:
515
+ /**
516
+ * Gets an array of host settings
517
+ * @returns An array of host settings
518
+ */
519
+ function hostSettings() {
520
+ return [{
521
+ 'url': "https://api.notefile.net",
522
+ 'description': "Production server"
523
+ }];
524
+ }
525
+ }, {
526
+ key: "getBasePathFromSettings",
527
+ value: function getBasePathFromSettings(index) {
528
+ var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
529
+ var servers = this.hostSettings();
530
+
531
+ // check array index out of bound
532
+ if (index < 0 || index >= servers.length) {
533
+ throw new Error("Invalid index " + index + " when selecting the host settings. Must be less than " + servers.length);
534
+ }
535
+ var server = servers[index];
536
+ var url = server['url'];
537
+
538
+ // go through variable and assign a value
539
+ for (var variable_name in server['variables']) {
540
+ if (variable_name in variables) {
541
+ var variable = server['variables'][variable_name];
542
+ if (!('enum_values' in variable) || variable['enum_values'].includes(variables[variable_name])) {
543
+ url = url.replace("{" + variable_name + "}", variables[variable_name]);
544
+ } else {
545
+ throw new Error("The variable `" + variable_name + "` in the host URL has invalid value " + variables[variable_name] + ". Must be " + server['variables'][variable_name]['enum_values'] + ".");
546
+ }
547
+ } else {
548
+ // use default value
549
+ url = url.replace("{" + variable_name + "}", server['variables'][variable_name]['default_value']);
550
+ }
551
+ }
552
+ return url;
553
+ }
554
+
555
+ /**
556
+ * Constructs a new map or array model from REST data.
557
+ * @param data {Object|Array} The REST data.
558
+ * @param obj {Object|Array} The target object or array.
559
+ */
560
+ }], [{
561
+ key: "canBeJsonified",
562
+ value: function canBeJsonified(str) {
563
+ if (typeof str !== 'string' && _typeof(str) !== 'object') return false;
564
+ try {
565
+ var type = str.toString();
566
+ return type === '[object Object]' || type === '[object Array]';
567
+ } catch (err) {
568
+ return false;
569
+ }
570
+ }
571
+ }, {
572
+ key: "parseDate",
573
+ value: function parseDate(str) {
574
+ if (isNaN(str)) {
575
+ return new Date(str.replace(/(\d)(T)(\d)/i, '$1 $3'));
576
+ }
577
+ return new Date(+str);
578
+ }
579
+
580
+ /**
581
+ * Converts a value to the specified type.
582
+ * @param {(String|Object)} data The data to convert, as a string or object.
583
+ * @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types
584
+ * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
585
+ * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
586
+ * all properties on <code>data<code> will be converted to this type.
587
+ * @returns An instance of the specified type or null or undefined if data is null or undefined.
588
+ */
589
+ }, {
590
+ key: "convertToType",
591
+ value: function convertToType(data, type) {
592
+ if (data === null || data === undefined) return data;
593
+ switch (type) {
594
+ case 'Boolean':
595
+ return Boolean(data);
596
+ case 'Integer':
597
+ return parseInt(data, 10);
598
+ case 'Number':
599
+ return parseFloat(data);
600
+ case 'String':
601
+ return String(data);
602
+ case 'Date':
603
+ return String(data);
604
+ case 'Blob':
605
+ return data;
606
+ default:
607
+ if (type === Object) {
608
+ // generic object, return directly
609
+ return data;
610
+ } else if (typeof type.constructFromObject === 'function') {
611
+ // for model type like User and enum class
612
+ return type.constructFromObject(data);
613
+ } else if (Array.isArray(type)) {
614
+ // for array type like: ['String']
615
+ var itemType = type[0];
616
+ return data.map(function (item) {
617
+ return ApiClient.convertToType(item, itemType);
618
+ });
619
+ } else if (_typeof(type) === 'object') {
620
+ // for plain object type like: {'String': 'Integer'}
621
+ var keyType, valueType;
622
+ for (var k in type) {
623
+ if (type.hasOwnProperty(k)) {
624
+ keyType = k;
625
+ valueType = type[k];
626
+ break;
627
+ }
628
+ }
629
+ var result = {};
630
+ for (var k in data) {
631
+ if (data.hasOwnProperty(k)) {
632
+ var key = ApiClient.convertToType(k, keyType);
633
+ var value = ApiClient.convertToType(data[k], valueType);
634
+ result[key] = value;
635
+ }
636
+ }
637
+ return result;
638
+ } else {
639
+ // for unknown type, return the data directly
640
+ return data;
641
+ }
642
+ }
643
+ }
644
+ }, {
645
+ key: "constructFromObject",
646
+ value: function constructFromObject(data, obj, itemType) {
647
+ if (Array.isArray(data)) {
648
+ for (var i = 0; i < data.length; i++) {
649
+ if (data.hasOwnProperty(i)) obj[i] = ApiClient.convertToType(data[i], itemType);
650
+ }
651
+ } else {
652
+ for (var k in data) {
653
+ if (data.hasOwnProperty(k)) obj[k] = ApiClient.convertToType(data[k], itemType);
654
+ }
655
+ }
656
+ }
657
+ }]);
658
+ return ApiClient;
659
+ }();
660
+ /**
661
+ * Enumeration of collection format separator strategies.
662
+ * @enum {String}
663
+ * @readonly
664
+ */
665
+ ApiClient.CollectionFormatEnum = {
666
+ /**
667
+ * Comma-separated values. Value: <code>csv</code>
668
+ * @const
669
+ */
670
+ CSV: ',',
671
+ /**
672
+ * Space-separated values. Value: <code>ssv</code>
673
+ * @const
674
+ */
675
+ SSV: ' ',
676
+ /**
677
+ * Tab-separated values. Value: <code>tsv</code>
678
+ * @const
679
+ */
680
+ TSV: '\t',
681
+ /**
682
+ * Pipe(|)-separated values. Value: <code>pipes</code>
683
+ * @const
684
+ */
685
+ PIPES: '|',
686
+ /**
687
+ * Native array. Value: <code>multi</code>
688
+ * @const
689
+ */
690
+ MULTI: 'multi'
691
+ };
692
+
693
+ /**
694
+ * The default API client implementation.
695
+ * @type {module:ApiClient}
696
+ */
697
+ ApiClient.instance = new ApiClient();
698
+ var _default = ApiClient;
699
+ exports["default"] = _default;