@flexprice/sdk 0.0.1

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 (167) hide show
  1. package/README.md +380 -0
  2. package/dist/ApiClient.js +703 -0
  3. package/dist/api/AuthApi.js +116 -0
  4. package/dist/api/CustomersApi.js +373 -0
  5. package/dist/api/EntitlementsApi.js +291 -0
  6. package/dist/api/EnvironmentsApi.js +204 -0
  7. package/dist/api/EventsApi.js +237 -0
  8. package/dist/api/FeaturesApi.js +252 -0
  9. package/dist/api/IntegrationsApi.js +189 -0
  10. package/dist/api/InvoicesApi.js +444 -0
  11. package/dist/api/MetersApi.js +287 -0
  12. package/dist/api/PaymentsApi.js +296 -0
  13. package/dist/api/PlansApi.js +248 -0
  14. package/dist/api/PricesApi.js +250 -0
  15. package/dist/api/SecretsApi.js +155 -0
  16. package/dist/api/SubscriptionsApi.js +383 -0
  17. package/dist/api/TasksApi.js +254 -0
  18. package/dist/api/TenantsApi.js +182 -0
  19. package/dist/api/UsersApi.js +75 -0
  20. package/dist/api/WalletsApi.js +384 -0
  21. package/dist/index.js +1154 -0
  22. package/dist/model/DtoAddress.js +149 -0
  23. package/dist/model/DtoAggregatedEntitlement.js +123 -0
  24. package/dist/model/DtoAggregatedFeature.js +138 -0
  25. package/dist/model/DtoAuthResponse.js +113 -0
  26. package/dist/model/DtoBillingPeriodInfo.js +114 -0
  27. package/dist/model/DtoBulkIngestEventRequest.js +130 -0
  28. package/dist/model/DtoCreateAPIKeyRequest.js +147 -0
  29. package/dist/model/DtoCreateAPIKeyResponse.js +103 -0
  30. package/dist/model/DtoCreateCustomerRequest.js +218 -0
  31. package/dist/model/DtoCreateEntitlementRequest.js +180 -0
  32. package/dist/model/DtoCreateEnvironmentRequest.js +126 -0
  33. package/dist/model/DtoCreateFeatureRequest.js +193 -0
  34. package/dist/model/DtoCreateIntegrationRequest.js +135 -0
  35. package/dist/model/DtoCreateInvoiceLineItemRequest.js +238 -0
  36. package/dist/model/DtoCreateInvoiceRequest.js +316 -0
  37. package/dist/model/DtoCreateMeterRequest.js +183 -0
  38. package/dist/model/DtoCreatePaymentRequest.js +202 -0
  39. package/dist/model/DtoCreatePlanEntitlementRequest.js +180 -0
  40. package/dist/model/DtoCreatePlanPriceRequest.js +318 -0
  41. package/dist/model/DtoCreatePlanRequest.js +196 -0
  42. package/dist/model/DtoCreatePriceRequest.js +318 -0
  43. package/dist/model/DtoCreatePriceTier.js +132 -0
  44. package/dist/model/DtoCreateSubscriptionRequest.js +244 -0
  45. package/dist/model/DtoCreateTaskRequest.js +167 -0
  46. package/dist/model/DtoCreateTenantRequest.js +126 -0
  47. package/dist/model/DtoCreateWalletRequest.js +216 -0
  48. package/dist/model/DtoCustomerEntitlementsResponse.js +122 -0
  49. package/dist/model/DtoCustomerInvoiceSummary.js +165 -0
  50. package/dist/model/DtoCustomerMultiCurrencyInvoiceSummary.js +134 -0
  51. package/dist/model/DtoCustomerResponse.js +300 -0
  52. package/dist/model/DtoCustomerUsageSummaryResponse.js +150 -0
  53. package/dist/model/DtoEntitlementResponse.js +276 -0
  54. package/dist/model/DtoEntitlementSource.js +161 -0
  55. package/dist/model/DtoEnvironmentResponse.js +137 -0
  56. package/dist/model/DtoEvent.js +159 -0
  57. package/dist/model/DtoFeatureResponse.js +275 -0
  58. package/dist/model/DtoFeatureUsageSummary.js +164 -0
  59. package/dist/model/DtoGetEventsResponse.js +142 -0
  60. package/dist/model/DtoGetPreviewInvoiceRequest.js +136 -0
  61. package/dist/model/DtoGetUsageByMeterRequest.js +179 -0
  62. package/dist/model/DtoGetUsageBySubscriptionRequest.js +144 -0
  63. package/dist/model/DtoGetUsageBySubscriptionResponse.js +166 -0
  64. package/dist/model/DtoGetUsageRequest.js +203 -0
  65. package/dist/model/DtoGetUsageResponse.js +139 -0
  66. package/dist/model/DtoIngestEventRequest.js +186 -0
  67. package/dist/model/DtoInvoiceLineItemResponse.js +343 -0
  68. package/dist/model/DtoInvoiceResponse.js +479 -0
  69. package/dist/model/DtoLinkedIntegrationsResponse.js +89 -0
  70. package/dist/model/DtoListCustomersResponse.js +124 -0
  71. package/dist/model/DtoListEntitlementsResponse.js +124 -0
  72. package/dist/model/DtoListEnvironmentsResponse.js +134 -0
  73. package/dist/model/DtoListFeaturesResponse.js +124 -0
  74. package/dist/model/DtoListInvoicesResponse.js +124 -0
  75. package/dist/model/DtoListPaymentsResponse.js +124 -0
  76. package/dist/model/DtoListPlansResponse.js +124 -0
  77. package/dist/model/DtoListPricesResponse.js +124 -0
  78. package/dist/model/DtoListSecretsResponse.js +124 -0
  79. package/dist/model/DtoListSubscriptionPausesResponse.js +118 -0
  80. package/dist/model/DtoListSubscriptionsResponse.js +124 -0
  81. package/dist/model/DtoListTasksResponse.js +124 -0
  82. package/dist/model/DtoListWalletTransactionsResponse.js +124 -0
  83. package/dist/model/DtoLoginRequest.js +138 -0
  84. package/dist/model/DtoMeterResponse.js +217 -0
  85. package/dist/model/DtoPauseSubscriptionRequest.js +171 -0
  86. package/dist/model/DtoPaymentAttemptResponse.js +191 -0
  87. package/dist/model/DtoPaymentResponse.js +331 -0
  88. package/dist/model/DtoPlanResponse.js +269 -0
  89. package/dist/model/DtoPriceResponse.js +412 -0
  90. package/dist/model/DtoResumeSubscriptionRequest.js +127 -0
  91. package/dist/model/DtoSecretResponse.js +200 -0
  92. package/dist/model/DtoSignUpRequest.js +148 -0
  93. package/dist/model/DtoSubscriptionPauseResponse.js +300 -0
  94. package/dist/model/DtoSubscriptionResponse.js +518 -0
  95. package/dist/model/DtoSubscriptionUsageByMetersResponse.js +165 -0
  96. package/dist/model/DtoTaskResponse.js +311 -0
  97. package/dist/model/DtoTenantBillingDetails.js +127 -0
  98. package/dist/model/DtoTenantBillingUsage.js +124 -0
  99. package/dist/model/DtoTenantResponse.js +151 -0
  100. package/dist/model/DtoTopUpWalletRequest.js +185 -0
  101. package/dist/model/DtoUpdateCustomerRequest.js +195 -0
  102. package/dist/model/DtoUpdateEntitlementRequest.js +122 -0
  103. package/dist/model/DtoUpdateEnvironmentRequest.js +101 -0
  104. package/dist/model/DtoUpdateFeatureRequest.js +135 -0
  105. package/dist/model/DtoUpdateMeterRequest.js +110 -0
  106. package/dist/model/DtoUpdatePaymentRequest.js +99 -0
  107. package/dist/model/DtoUpdatePaymentStatusRequest.js +117 -0
  108. package/dist/model/DtoUpdatePlanEntitlementRequest.js +193 -0
  109. package/dist/model/DtoUpdatePlanPriceRequest.js +331 -0
  110. package/dist/model/DtoUpdatePlanRequest.js +176 -0
  111. package/dist/model/DtoUpdatePriceRequest.js +111 -0
  112. package/dist/model/DtoUpdateTaskStatusRequest.js +109 -0
  113. package/dist/model/DtoUpdateTenantRequest.js +91 -0
  114. package/dist/model/DtoUpdateWalletRequest.js +150 -0
  115. package/dist/model/DtoUsageResult.js +97 -0
  116. package/dist/model/DtoUserResponse.js +115 -0
  117. package/dist/model/DtoWalletBalanceResponse.js +353 -0
  118. package/dist/model/DtoWalletResponse.js +252 -0
  119. package/dist/model/DtoWalletTransactionResponse.js +238 -0
  120. package/dist/model/ErrorsErrorDetail.js +111 -0
  121. package/dist/model/ErrorsErrorResponse.js +99 -0
  122. package/dist/model/MeterAggregation.js +99 -0
  123. package/dist/model/MeterFilter.js +103 -0
  124. package/dist/model/PriceJSONBTransformQuantity.js +99 -0
  125. package/dist/model/PricePrice.js +398 -0
  126. package/dist/model/PricePriceTier.js +104 -0
  127. package/dist/model/PriceTransformQuantity.js +99 -0
  128. package/dist/model/SubscriptionSubscriptionLineItem.js +355 -0
  129. package/dist/model/SubscriptionSubscriptionPause.js +300 -0
  130. package/dist/model/TypesAggregationType.js +68 -0
  131. package/dist/model/TypesAutoTopupTrigger.js +58 -0
  132. package/dist/model/TypesBillingCadence.js +58 -0
  133. package/dist/model/TypesBillingModel.js +63 -0
  134. package/dist/model/TypesBillingPeriod.js +78 -0
  135. package/dist/model/TypesBillingTier.js +58 -0
  136. package/dist/model/TypesEntityType.js +63 -0
  137. package/dist/model/TypesFeatureType.js +63 -0
  138. package/dist/model/TypesFileType.js +58 -0
  139. package/dist/model/TypesInvoiceBillingReason.js +68 -0
  140. package/dist/model/TypesInvoiceCadence.js +58 -0
  141. package/dist/model/TypesInvoiceStatus.js +63 -0
  142. package/dist/model/TypesInvoiceType.js +63 -0
  143. package/dist/model/TypesPaginationResponse.js +101 -0
  144. package/dist/model/TypesPauseMode.js +63 -0
  145. package/dist/model/TypesPauseStatus.js +73 -0
  146. package/dist/model/TypesPaymentDestinationType.js +53 -0
  147. package/dist/model/TypesPaymentMethodType.js +68 -0
  148. package/dist/model/TypesPaymentStatus.js +78 -0
  149. package/dist/model/TypesPriceType.js +58 -0
  150. package/dist/model/TypesResetUsage.js +58 -0
  151. package/dist/model/TypesResumeMode.js +63 -0
  152. package/dist/model/TypesSecretProvider.js +63 -0
  153. package/dist/model/TypesSecretType.js +63 -0
  154. package/dist/model/TypesStatus.js +63 -0
  155. package/dist/model/TypesSubscriptionStatus.js +88 -0
  156. package/dist/model/TypesTaskStatus.js +68 -0
  157. package/dist/model/TypesTaskType.js +58 -0
  158. package/dist/model/TypesTransactionReason.js +88 -0
  159. package/dist/model/TypesTransactionStatus.js +63 -0
  160. package/dist/model/TypesTransactionType.js +58 -0
  161. package/dist/model/TypesWalletConfig.js +91 -0
  162. package/dist/model/TypesWalletConfigPriceType.js +63 -0
  163. package/dist/model/TypesWalletStatus.js +63 -0
  164. package/dist/model/TypesWalletTxReferenceType.js +68 -0
  165. package/dist/model/TypesWalletType.js +58 -0
  166. package/dist/model/TypesWindowSize.js +63 -0
  167. package/package.json +54 -0
@@ -0,0 +1,703 @@
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
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
11
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
12
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
15
+ * FlexPrice API
16
+ * FlexPrice API Service
17
+ *
18
+ * The version of the OpenAPI document: 1.0
19
+ *
20
+ *
21
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
22
+ * https://openapi-generator.tech
23
+ * Do not edit the class manually.
24
+ *
25
+ */
26
+ /**
27
+ * @module ApiClient
28
+ * @version 1.0
29
+ */
30
+ /**
31
+ * Manages low level client-server communications, parameter marshalling, etc. There should not be any need for an
32
+ * application to use this class directly - the *Api and model classes provide the public API for the service. The
33
+ * contents of this file should be regarded as internal but are documented for completeness.
34
+ * @alias module:ApiClient
35
+ * @class
36
+ */
37
+ var ApiClient = /*#__PURE__*/function () {
38
+ /**
39
+ * The base URL against which to resolve every API call's (relative) path.
40
+ * Overrides the default value set in spec file if present
41
+ * @param {String} basePath
42
+ */
43
+ function ApiClient() {
44
+ var basePath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/v1';
45
+ _classCallCheck(this, ApiClient);
46
+ /**
47
+ * The base URL against which to resolve every API call's (relative) path.
48
+ * @type {String}
49
+ * @default /v1
50
+ */
51
+ this.basePath = basePath.replace(/\/+$/, '');
52
+
53
+ /**
54
+ * The authentication methods to be included for all API calls.
55
+ * @type {Array.<String>}
56
+ */
57
+ this.authentications = {
58
+ 'ApiKeyAuth': {
59
+ type: 'apiKey',
60
+ 'in': 'header',
61
+ name: 'x-api-key'
62
+ }
63
+ };
64
+
65
+ /**
66
+ * The default HTTP headers to be included for all API calls.
67
+ * @type {Array.<String>}
68
+ * @default {}
69
+ */
70
+ this.defaultHeaders = {
71
+ 'User-Agent': 'OpenAPI-Generator/1.0/Javascript'
72
+ };
73
+
74
+ /**
75
+ * The default HTTP timeout for all API calls.
76
+ * @type {Number}
77
+ * @default 60000
78
+ */
79
+ this.timeout = 60000;
80
+
81
+ /**
82
+ * If set to false an additional timestamp parameter is added to all API GET calls to
83
+ * prevent browser caching
84
+ * @type {Boolean}
85
+ * @default true
86
+ */
87
+ this.cache = true;
88
+
89
+ /**
90
+ * If set to true, the client will save the cookies from each server
91
+ * response, and return them in the next request.
92
+ * @default false
93
+ */
94
+ this.enableCookies = false;
95
+
96
+ /*
97
+ * Used to save and return cookies in a node.js (non-browser) setting,
98
+ * if this.enableCookies is set to true.
99
+ */
100
+ if (typeof window === 'undefined') {
101
+ this.agent = new _superagent["default"].agent();
102
+ }
103
+
104
+ /*
105
+ * Allow user to override superagent agent
106
+ */
107
+ this.requestAgent = null;
108
+
109
+ /*
110
+ * Allow user to add superagent plugins
111
+ */
112
+ this.plugins = null;
113
+ }
114
+
115
+ /**
116
+ * Returns a string representation for an actual parameter.
117
+ * @param param The actual parameter.
118
+ * @returns {String} The string representation of <code>param</code>.
119
+ */
120
+ return _createClass(ApiClient, [{
121
+ key: "paramToString",
122
+ value: function paramToString(param) {
123
+ if (param == undefined || param == null) {
124
+ return '';
125
+ }
126
+ if (param instanceof Date) {
127
+ return param.toJSON();
128
+ }
129
+ if (ApiClient.canBeJsonified(param)) {
130
+ return JSON.stringify(param);
131
+ }
132
+ return param.toString();
133
+ }
134
+
135
+ /**
136
+ * Returns a boolean indicating if the parameter could be JSON.stringified
137
+ * @param param The actual parameter
138
+ * @returns {Boolean} Flag indicating if <code>param</code> can be JSON.stringified
139
+ */
140
+ }, {
141
+ key: "buildUrl",
142
+ value:
143
+ /**
144
+ * Builds full URL by appending the given path to the base URL and replacing path parameter place-holders with parameter values.
145
+ * NOTE: query parameters are not handled here.
146
+ * @param {String} path The path to append to the base URL.
147
+ * @param {Object} pathParams The parameter values to append.
148
+ * @param {String} apiBasePath Base path defined in the path, operation level to override the default one
149
+ * @returns {String} The encoded path with parameter values substituted.
150
+ */
151
+ function buildUrl(path, pathParams, apiBasePath) {
152
+ var _this = this;
153
+ if (!path.match(/^\//)) {
154
+ path = '/' + path;
155
+ }
156
+ var url = this.basePath + path;
157
+
158
+ // use API (operation, path) base path if defined
159
+ if (apiBasePath !== null && apiBasePath !== undefined) {
160
+ url = apiBasePath + path;
161
+ }
162
+ url = url.replace(/\{([\w-\.#]+)\}/g, function (fullMatch, key) {
163
+ var value;
164
+ if (pathParams.hasOwnProperty(key)) {
165
+ value = _this.paramToString(pathParams[key]);
166
+ } else {
167
+ value = fullMatch;
168
+ }
169
+ return encodeURIComponent(value);
170
+ });
171
+ return url;
172
+ }
173
+
174
+ /**
175
+ * Checks whether the given content type represents JSON.<br>
176
+ * JSON content type examples:<br>
177
+ * <ul>
178
+ * <li>application/json</li>
179
+ * <li>application/json; charset=UTF8</li>
180
+ * <li>APPLICATION/JSON</li>
181
+ * </ul>
182
+ * @param {String} contentType The MIME content type to check.
183
+ * @returns {Boolean} <code>true</code> if <code>contentType</code> represents JSON, otherwise <code>false</code>.
184
+ */
185
+ }, {
186
+ key: "isJsonMime",
187
+ value: function isJsonMime(contentType) {
188
+ return Boolean(contentType != null && contentType.match(/^application\/json(;.*)?$/i));
189
+ }
190
+
191
+ /**
192
+ * Chooses a content type from the given array, with JSON preferred; i.e. return JSON if included, otherwise return the first.
193
+ * @param {Array.<String>} contentTypes
194
+ * @returns {String} The chosen content type, preferring JSON.
195
+ */
196
+ }, {
197
+ key: "jsonPreferredMime",
198
+ value: function jsonPreferredMime(contentTypes) {
199
+ for (var i = 0; i < contentTypes.length; i++) {
200
+ if (this.isJsonMime(contentTypes[i])) {
201
+ return contentTypes[i];
202
+ }
203
+ }
204
+ return contentTypes[0];
205
+ }
206
+
207
+ /**
208
+ * Checks whether the given parameter value represents file-like content.
209
+ * @param param The parameter to check.
210
+ * @returns {Boolean} <code>true</code> if <code>param</code> represents a file.
211
+ */
212
+ }, {
213
+ key: "isFileParam",
214
+ value: function isFileParam(param) {
215
+ // fs.ReadStream in Node.js and Electron (but not in runtime like browserify)
216
+ if (typeof require === 'function') {
217
+ var fs;
218
+ try {
219
+ fs = require('fs');
220
+ } catch (err) {}
221
+ if (fs && fs.ReadStream && param instanceof fs.ReadStream) {
222
+ return true;
223
+ }
224
+ }
225
+
226
+ // Buffer in Node.js
227
+ if (typeof Buffer === 'function' && param instanceof Buffer) {
228
+ return true;
229
+ }
230
+
231
+ // Blob in browser
232
+ if (typeof Blob === 'function' && param instanceof Blob) {
233
+ return true;
234
+ }
235
+
236
+ // File in browser (it seems File object is also instance of Blob, but keep this for safe)
237
+ if (typeof File === 'function' && param instanceof File) {
238
+ return true;
239
+ }
240
+ return false;
241
+ }
242
+
243
+ /**
244
+ * Normalizes parameter values:
245
+ * <ul>
246
+ * <li>remove nils</li>
247
+ * <li>keep files and arrays</li>
248
+ * <li>format to string with `paramToString` for other cases</li>
249
+ * </ul>
250
+ * @param {Object.<String, Object>} params The parameters as object properties.
251
+ * @returns {Object.<String, Object>} normalized parameters.
252
+ */
253
+ }, {
254
+ key: "normalizeParams",
255
+ value: function normalizeParams(params) {
256
+ var newParams = {};
257
+ for (var key in params) {
258
+ if (params.hasOwnProperty(key) && params[key] != undefined && params[key] != null) {
259
+ var value = params[key];
260
+ if (this.isFileParam(value) || Array.isArray(value)) {
261
+ newParams[key] = value;
262
+ } else {
263
+ newParams[key] = this.paramToString(value);
264
+ }
265
+ }
266
+ }
267
+ return newParams;
268
+ }
269
+
270
+ /**
271
+ * Builds a string representation of an array-type actual parameter, according to the given collection format.
272
+ * @param {Array} param An array parameter.
273
+ * @param {module:ApiClient.CollectionFormatEnum} collectionFormat The array element separator strategy.
274
+ * @returns {String|Array} A string representation of the supplied collection, using the specified delimiter. Returns
275
+ * <code>param</code> as is if <code>collectionFormat</code> is <code>multi</code>.
276
+ */
277
+ }, {
278
+ key: "buildCollectionParam",
279
+ value: function buildCollectionParam(param, collectionFormat) {
280
+ if (param == null) {
281
+ return null;
282
+ }
283
+ switch (collectionFormat) {
284
+ case 'csv':
285
+ return param.map(this.paramToString, this).join(',');
286
+ case 'ssv':
287
+ return param.map(this.paramToString, this).join(' ');
288
+ case 'tsv':
289
+ return param.map(this.paramToString, this).join('\t');
290
+ case 'pipes':
291
+ return param.map(this.paramToString, this).join('|');
292
+ case 'multi':
293
+ //return the array directly as SuperAgent will handle it as expected
294
+ return param.map(this.paramToString, this);
295
+ case 'passthrough':
296
+ return param;
297
+ default:
298
+ throw new Error('Unknown collection format: ' + collectionFormat);
299
+ }
300
+ }
301
+
302
+ /**
303
+ * Applies authentication headers to the request.
304
+ * @param {Object} request The request object created by a <code>superagent()</code> call.
305
+ * @param {Array.<String>} authNames An array of authentication method names.
306
+ */
307
+ }, {
308
+ key: "applyAuthToRequest",
309
+ value: function applyAuthToRequest(request, authNames) {
310
+ var _this2 = this;
311
+ authNames.forEach(function (authName) {
312
+ var auth = _this2.authentications[authName];
313
+ switch (auth.type) {
314
+ case 'basic':
315
+ if (auth.username || auth.password) {
316
+ request.auth(auth.username || '', auth.password || '');
317
+ }
318
+ break;
319
+ case 'bearer':
320
+ if (auth.accessToken) {
321
+ var localVarBearerToken = typeof auth.accessToken === 'function' ? auth.accessToken() : auth.accessToken;
322
+ request.set({
323
+ 'Authorization': 'Bearer ' + localVarBearerToken
324
+ });
325
+ }
326
+ break;
327
+ case 'apiKey':
328
+ if (auth.apiKey) {
329
+ var data = {};
330
+ if (auth.apiKeyPrefix) {
331
+ data[auth.name] = auth.apiKeyPrefix + ' ' + auth.apiKey;
332
+ } else {
333
+ data[auth.name] = auth.apiKey;
334
+ }
335
+ if (auth['in'] === 'header') {
336
+ request.set(data);
337
+ } else {
338
+ request.query(data);
339
+ }
340
+ }
341
+ break;
342
+ case 'oauth2':
343
+ if (auth.accessToken) {
344
+ request.set({
345
+ 'Authorization': 'Bearer ' + auth.accessToken
346
+ });
347
+ }
348
+ break;
349
+ default:
350
+ throw new Error('Unknown authentication type: ' + auth.type);
351
+ }
352
+ });
353
+ }
354
+
355
+ /**
356
+ * Deserializes an HTTP response body into a value of the specified type.
357
+ * @param {Object} response A SuperAgent response object.
358
+ * @param {(String|Array.<String>|Object.<String, Object>|Function)} returnType The type to return. Pass a string for simple types
359
+ * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
360
+ * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
361
+ * all properties on <code>data<code> will be converted to this type.
362
+ * @returns A value of the specified type.
363
+ */
364
+ }, {
365
+ key: "deserialize",
366
+ value: function deserialize(response, returnType) {
367
+ if (response == null || returnType == null || response.status == 204) {
368
+ return null;
369
+ }
370
+
371
+ // Rely on SuperAgent for parsing response body.
372
+ // See http://visionmedia.github.io/superagent/#parsing-response-bodies
373
+ var data = response.body;
374
+ if (data == null || _typeof(data) === 'object' && typeof data.length === 'undefined' && !Object.keys(data).length) {
375
+ // SuperAgent does not always produce a body; use the unparsed response as a fallback
376
+ data = response.text;
377
+ }
378
+ return ApiClient.convertToType(data, returnType);
379
+ }
380
+
381
+ /**
382
+ * Callback function to receive the result of the operation.
383
+ * @callback module:ApiClient~callApiCallback
384
+ * @param {String} error Error message, if any.
385
+ * @param data The data returned by the service call.
386
+ * @param {String} response The complete HTTP response.
387
+ */
388
+
389
+ /**
390
+ * Invokes the REST service using the supplied settings and parameters.
391
+ * @param {String} path The base URL to invoke.
392
+ * @param {String} httpMethod The HTTP method to use.
393
+ * @param {Object.<String, String>} pathParams A map of path parameters and their values.
394
+ * @param {Object.<String, Object>} queryParams A map of query parameters and their values.
395
+ * @param {Object.<String, Object>} headerParams A map of header parameters and their values.
396
+ * @param {Object.<String, Object>} formParams A map of form parameters and their values.
397
+ * @param {Object} bodyParam The value to pass as the request body.
398
+ * @param {Array.<String>} authNames An array of authentication type names.
399
+ * @param {Array.<String>} contentTypes An array of request MIME types.
400
+ * @param {Array.<String>} accepts An array of acceptable response MIME types.
401
+ * @param {(String|Array|ObjectFunction)} returnType The required type to return; can be a string for simple types or the
402
+ * constructor for a complex type.
403
+ * @param {String} apiBasePath base path defined in the operation/path level to override the default one
404
+ * @param {module:ApiClient~callApiCallback} callback The callback function.
405
+ * @returns {Object} The SuperAgent request object.
406
+ */
407
+ }, {
408
+ key: "callApi",
409
+ value: function callApi(path, httpMethod, pathParams, queryParams, headerParams, formParams, bodyParam, authNames, contentTypes, accepts, returnType, apiBasePath, callback) {
410
+ var _this3 = this;
411
+ var url = this.buildUrl(path, pathParams, apiBasePath);
412
+ var request = (0, _superagent["default"])(httpMethod, url);
413
+ if (this.plugins !== null) {
414
+ for (var index in this.plugins) {
415
+ if (this.plugins.hasOwnProperty(index)) {
416
+ request.use(this.plugins[index]);
417
+ }
418
+ }
419
+ }
420
+
421
+ // apply authentications
422
+ this.applyAuthToRequest(request, authNames);
423
+
424
+ // set query parameters
425
+ if (httpMethod.toUpperCase() === 'GET' && this.cache === false) {
426
+ queryParams['_'] = new Date().getTime();
427
+ }
428
+ request.query(this.normalizeParams(queryParams));
429
+
430
+ // set header parameters
431
+ request.set(this.defaultHeaders).set(this.normalizeParams(headerParams));
432
+
433
+ // set requestAgent if it is set by user
434
+ if (this.requestAgent) {
435
+ request.agent(this.requestAgent);
436
+ }
437
+
438
+ // set request timeout
439
+ request.timeout(this.timeout);
440
+ var contentType = this.jsonPreferredMime(contentTypes);
441
+ if (contentType) {
442
+ // Issue with superagent and multipart/form-data (https://github.com/visionmedia/superagent/issues/746)
443
+ if (contentType != 'multipart/form-data') {
444
+ request.type(contentType);
445
+ }
446
+ }
447
+ if (contentType === 'application/x-www-form-urlencoded') {
448
+ var normalizedParams = this.normalizeParams(formParams);
449
+ var urlSearchParams = new URLSearchParams(normalizedParams);
450
+ var queryString = urlSearchParams.toString();
451
+ request.send(queryString);
452
+ } else if (contentType == 'multipart/form-data') {
453
+ var _formParams = this.normalizeParams(formParams);
454
+ for (var key in _formParams) {
455
+ if (_formParams.hasOwnProperty(key)) {
456
+ var _formParamsValue = _formParams[key];
457
+ if (this.isFileParam(_formParamsValue)) {
458
+ // file field
459
+ request.attach(key, _formParamsValue);
460
+ } else if (Array.isArray(_formParamsValue) && _formParamsValue.length && this.isFileParam(_formParamsValue[0])) {
461
+ // multiple files
462
+ _formParamsValue.forEach(function (file) {
463
+ return request.attach(key, file);
464
+ });
465
+ } else {
466
+ request.field(key, _formParamsValue);
467
+ }
468
+ }
469
+ }
470
+ } else if (bodyParam !== null && bodyParam !== undefined) {
471
+ if (!request.header['Content-Type']) {
472
+ request.type('application/json');
473
+ }
474
+ request.send(bodyParam);
475
+ }
476
+ var accept = this.jsonPreferredMime(accepts);
477
+ if (accept) {
478
+ request.accept(accept);
479
+ }
480
+ if (returnType === 'Blob') {
481
+ request.responseType('blob');
482
+ } else if (returnType === 'String') {
483
+ request.responseType('text');
484
+ }
485
+
486
+ // Attach previously saved cookies, if enabled
487
+ if (this.enableCookies) {
488
+ if (typeof window === 'undefined') {
489
+ this.agent._attachCookies(request);
490
+ } else {
491
+ request.withCredentials();
492
+ }
493
+ }
494
+ request.end(function (error, response) {
495
+ if (callback) {
496
+ var data = null;
497
+ if (!error) {
498
+ try {
499
+ data = _this3.deserialize(response, returnType);
500
+ if (_this3.enableCookies && typeof window === 'undefined') {
501
+ _this3.agent._saveCookies(response);
502
+ }
503
+ } catch (err) {
504
+ error = err;
505
+ }
506
+ }
507
+ callback(error, data, response);
508
+ }
509
+ });
510
+ return request;
511
+ }
512
+
513
+ /**
514
+ * Parses an ISO-8601 string representation or epoch representation of a date value.
515
+ * @param {String} str The date value as a string.
516
+ * @returns {Date} The parsed date object.
517
+ */
518
+ }, {
519
+ key: "hostSettings",
520
+ value:
521
+ /**
522
+ * Gets an array of host settings
523
+ * @returns An array of host settings
524
+ */
525
+ function hostSettings() {
526
+ return [{
527
+ 'url': "/v1",
528
+ 'description': "No description provided"
529
+ }];
530
+ }
531
+ }, {
532
+ key: "getBasePathFromSettings",
533
+ value: function getBasePathFromSettings(index) {
534
+ var variables = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
535
+ var servers = this.hostSettings();
536
+
537
+ // check array index out of bound
538
+ if (index < 0 || index >= servers.length) {
539
+ throw new Error("Invalid index " + index + " when selecting the host settings. Must be less than " + servers.length);
540
+ }
541
+ var server = servers[index];
542
+ var url = server['url'];
543
+
544
+ // go through variable and assign a value
545
+ for (var variable_name in server['variables']) {
546
+ if (variable_name in variables) {
547
+ var variable = server['variables'][variable_name];
548
+ if (!('enum_values' in variable) || variable['enum_values'].includes(variables[variable_name])) {
549
+ url = url.replace("{" + variable_name + "}", variables[variable_name]);
550
+ } else {
551
+ 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'] + ".");
552
+ }
553
+ } else {
554
+ // use default value
555
+ url = url.replace("{" + variable_name + "}", server['variables'][variable_name]['default_value']);
556
+ }
557
+ }
558
+ return url;
559
+ }
560
+
561
+ /**
562
+ * Constructs a new map or array model from REST data.
563
+ * @param data {Object|Array} The REST data.
564
+ * @param obj {Object|Array} The target object or array.
565
+ */
566
+ }], [{
567
+ key: "canBeJsonified",
568
+ value: function canBeJsonified(str) {
569
+ if (typeof str !== 'string' && _typeof(str) !== 'object') return false;
570
+ try {
571
+ var type = str.toString();
572
+ return type === '[object Object]' || type === '[object Array]';
573
+ } catch (err) {
574
+ return false;
575
+ }
576
+ }
577
+ }, {
578
+ key: "parseDate",
579
+ value: function parseDate(str) {
580
+ if (isNaN(str)) {
581
+ return new Date(str.replace(/(\d)(T)(\d)/i, '$1 $3'));
582
+ }
583
+ return new Date(+str);
584
+ }
585
+
586
+ /**
587
+ * Converts a value to the specified type.
588
+ * @param {(String|Object)} data The data to convert, as a string or object.
589
+ * @param {(String|Array.<String>|Object.<String, Object>|Function)} type The type to return. Pass a string for simple types
590
+ * or the constructor function for a complex type. Pass an array containing the type name to return an array of that type. To
591
+ * return an object, pass an object with one property whose name is the key type and whose value is the corresponding value type:
592
+ * all properties on <code>data<code> will be converted to this type.
593
+ * @returns An instance of the specified type or null or undefined if data is null or undefined.
594
+ */
595
+ }, {
596
+ key: "convertToType",
597
+ value: function convertToType(data, type) {
598
+ if (data === null || data === undefined) return data;
599
+ switch (type) {
600
+ case 'Boolean':
601
+ return Boolean(data);
602
+ case 'Integer':
603
+ return parseInt(data, 10);
604
+ case 'Number':
605
+ return parseFloat(data);
606
+ case 'String':
607
+ return String(data);
608
+ case 'Date':
609
+ return ApiClient.parseDate(String(data));
610
+ case 'Blob':
611
+ return data;
612
+ default:
613
+ if (type === Object) {
614
+ // generic object, return directly
615
+ return data;
616
+ } else if (typeof type.constructFromObject === 'function') {
617
+ // for model type like User and enum class
618
+ return type.constructFromObject(data);
619
+ } else if (Array.isArray(type)) {
620
+ // for array type like: ['String']
621
+ var itemType = type[0];
622
+ return data.map(function (item) {
623
+ return ApiClient.convertToType(item, itemType);
624
+ });
625
+ } else if (_typeof(type) === 'object') {
626
+ // for plain object type like: {'String': 'Integer'}
627
+ var keyType, valueType;
628
+ for (var k in type) {
629
+ if (type.hasOwnProperty(k)) {
630
+ keyType = k;
631
+ valueType = type[k];
632
+ break;
633
+ }
634
+ }
635
+ var result = {};
636
+ for (var k in data) {
637
+ if (data.hasOwnProperty(k)) {
638
+ var key = ApiClient.convertToType(k, keyType);
639
+ var value = ApiClient.convertToType(data[k], valueType);
640
+ result[key] = value;
641
+ }
642
+ }
643
+ return result;
644
+ } else {
645
+ // for unknown type, return the data directly
646
+ return data;
647
+ }
648
+ }
649
+ }
650
+ }, {
651
+ key: "constructFromObject",
652
+ value: function constructFromObject(data, obj, itemType) {
653
+ if (Array.isArray(data)) {
654
+ for (var i = 0; i < data.length; i++) {
655
+ if (data.hasOwnProperty(i)) obj[i] = ApiClient.convertToType(data[i], itemType);
656
+ }
657
+ } else {
658
+ for (var k in data) {
659
+ if (data.hasOwnProperty(k)) obj[k] = ApiClient.convertToType(data[k], itemType);
660
+ }
661
+ }
662
+ }
663
+ }]);
664
+ }();
665
+ /**
666
+ * Enumeration of collection format separator strategies.
667
+ * @enum {String}
668
+ * @readonly
669
+ */
670
+ ApiClient.CollectionFormatEnum = {
671
+ /**
672
+ * Comma-separated values. Value: <code>csv</code>
673
+ * @const
674
+ */
675
+ CSV: ',',
676
+ /**
677
+ * Space-separated values. Value: <code>ssv</code>
678
+ * @const
679
+ */
680
+ SSV: ' ',
681
+ /**
682
+ * Tab-separated values. Value: <code>tsv</code>
683
+ * @const
684
+ */
685
+ TSV: '\t',
686
+ /**
687
+ * Pipe(|)-separated values. Value: <code>pipes</code>
688
+ * @const
689
+ */
690
+ PIPES: '|',
691
+ /**
692
+ * Native array. Value: <code>multi</code>
693
+ * @const
694
+ */
695
+ MULTI: 'multi'
696
+ };
697
+
698
+ /**
699
+ * The default API client implementation.
700
+ * @type {module:ApiClient}
701
+ */
702
+ ApiClient.instance = new ApiClient();
703
+ var _default = exports["default"] = ApiClient;