edge-impulse-api 1.82.6 → 1.82.7

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 (127) hide show
  1. package/build/library/sdk/api/adminApi.d.ts +4 -6
  2. package/build/library/sdk/api/adminApi.js +4782 -4928
  3. package/build/library/sdk/api/adminApi.js.map +1 -1
  4. package/build/library/sdk/api/authApi.d.ts +4 -6
  5. package/build/library/sdk/api/authApi.js +88 -56
  6. package/build/library/sdk/api/authApi.js.map +1 -1
  7. package/build/library/sdk/api/cDNApi.d.ts +4 -6
  8. package/build/library/sdk/api/cDNApi.js +76 -53
  9. package/build/library/sdk/api/cDNApi.js.map +1 -1
  10. package/build/library/sdk/api/canaryApi.d.ts +4 -6
  11. package/build/library/sdk/api/canaryApi.js +79 -53
  12. package/build/library/sdk/api/canaryApi.js.map +1 -1
  13. package/build/library/sdk/api/classifyApi.d.ts +4 -6
  14. package/build/library/sdk/api/classifyApi.js +527 -499
  15. package/build/library/sdk/api/classifyApi.js.map +1 -1
  16. package/build/library/sdk/api/dSPApi.d.ts +4 -6
  17. package/build/library/sdk/api/dSPApi.js +938 -942
  18. package/build/library/sdk/api/dSPApi.js.map +1 -1
  19. package/build/library/sdk/api/deploymentApi.d.ts +4 -6
  20. package/build/library/sdk/api/deploymentApi.js +680 -603
  21. package/build/library/sdk/api/deploymentApi.js.map +1 -1
  22. package/build/library/sdk/api/devicesApi.d.ts +4 -6
  23. package/build/library/sdk/api/devicesApi.js +802 -800
  24. package/build/library/sdk/api/devicesApi.js.map +1 -1
  25. package/build/library/sdk/api/emailVerificationApi.d.ts +4 -6
  26. package/build/library/sdk/api/emailVerificationApi.js +184 -190
  27. package/build/library/sdk/api/emailVerificationApi.js.map +1 -1
  28. package/build/library/sdk/api/exportApi.d.ts +4 -6
  29. package/build/library/sdk/api/exportApi.js +88 -56
  30. package/build/library/sdk/api/exportApi.js.map +1 -1
  31. package/build/library/sdk/api/featureFlagsApi.d.ts +4 -6
  32. package/build/library/sdk/api/featureFlagsApi.js +76 -52
  33. package/build/library/sdk/api/featureFlagsApi.js.map +1 -1
  34. package/build/library/sdk/api/healthApi.d.ts +4 -6
  35. package/build/library/sdk/api/healthApi.js +111 -97
  36. package/build/library/sdk/api/healthApi.js.map +1 -1
  37. package/build/library/sdk/api/impulseApi.d.ts +4 -6
  38. package/build/library/sdk/api/impulseApi.js +942 -902
  39. package/build/library/sdk/api/impulseApi.js.map +1 -1
  40. package/build/library/sdk/api/integrationsApi.d.ts +4 -6
  41. package/build/library/sdk/api/integrationsApi.js +136 -106
  42. package/build/library/sdk/api/integrationsApi.js.map +1 -1
  43. package/build/library/sdk/api/jobsApi.d.ts +4 -6
  44. package/build/library/sdk/api/jobsApi.js +2270 -2326
  45. package/build/library/sdk/api/jobsApi.js.map +1 -1
  46. package/build/library/sdk/api/learnApi.d.ts +22 -6
  47. package/build/library/sdk/api/learnApi.js +1597 -1424
  48. package/build/library/sdk/api/learnApi.js.map +1 -1
  49. package/build/library/sdk/api/loginApi.d.ts +4 -6
  50. package/build/library/sdk/api/loginApi.js +112 -98
  51. package/build/library/sdk/api/loginApi.js.map +1 -1
  52. package/build/library/sdk/api/metricsApi.d.ts +4 -6
  53. package/build/library/sdk/api/metricsApi.js +148 -144
  54. package/build/library/sdk/api/metricsApi.js.map +1 -1
  55. package/build/library/sdk/api/optimizationApi.d.ts +4 -6
  56. package/build/library/sdk/api/optimizationApi.js +844 -844
  57. package/build/library/sdk/api/optimizationApi.js.map +1 -1
  58. package/build/library/sdk/api/organizationBlocksApi.d.ts +4 -6
  59. package/build/library/sdk/api/organizationBlocksApi.js +1968 -1550
  60. package/build/library/sdk/api/organizationBlocksApi.js.map +1 -1
  61. package/build/library/sdk/api/organizationCreateProjectApi.d.ts +4 -6
  62. package/build/library/sdk/api/organizationCreateProjectApi.js +700 -652
  63. package/build/library/sdk/api/organizationCreateProjectApi.js.map +1 -1
  64. package/build/library/sdk/api/organizationDataApi.d.ts +4 -6
  65. package/build/library/sdk/api/organizationDataApi.js +2074 -1985
  66. package/build/library/sdk/api/organizationDataApi.js.map +1 -1
  67. package/build/library/sdk/api/organizationDataCampaignsApi.d.ts +4 -6
  68. package/build/library/sdk/api/organizationDataCampaignsApi.js +626 -602
  69. package/build/library/sdk/api/organizationDataCampaignsApi.js.map +1 -1
  70. package/build/library/sdk/api/organizationJobsApi.d.ts +4 -6
  71. package/build/library/sdk/api/organizationJobsApi.js +417 -399
  72. package/build/library/sdk/api/organizationJobsApi.js.map +1 -1
  73. package/build/library/sdk/api/organizationPipelinesApi.d.ts +4 -6
  74. package/build/library/sdk/api/organizationPipelinesApi.js +419 -401
  75. package/build/library/sdk/api/organizationPipelinesApi.js.map +1 -1
  76. package/build/library/sdk/api/organizationPortalsApi.d.ts +4 -6
  77. package/build/library/sdk/api/organizationPortalsApi.js +372 -352
  78. package/build/library/sdk/api/organizationPortalsApi.js.map +1 -1
  79. package/build/library/sdk/api/organizationsApi.d.ts +4 -6
  80. package/build/library/sdk/api/organizationsApi.js +4024 -4050
  81. package/build/library/sdk/api/organizationsApi.js.map +1 -1
  82. package/build/library/sdk/api/performanceCalibrationApi.d.ts +4 -6
  83. package/build/library/sdk/api/performanceCalibrationApi.js +586 -560
  84. package/build/library/sdk/api/performanceCalibrationApi.js.map +1 -1
  85. package/build/library/sdk/api/postProcessingApi.d.ts +4 -6
  86. package/build/library/sdk/api/postProcessingApi.js +279 -255
  87. package/build/library/sdk/api/postProcessingApi.js.map +1 -1
  88. package/build/library/sdk/api/projectsApi.d.ts +4 -6
  89. package/build/library/sdk/api/projectsApi.js +2758 -2818
  90. package/build/library/sdk/api/projectsApi.js.map +1 -1
  91. package/build/library/sdk/api/rawDataApi.d.ts +4 -6
  92. package/build/library/sdk/api/rawDataApi.js +3055 -3131
  93. package/build/library/sdk/api/rawDataApi.js.map +1 -1
  94. package/build/library/sdk/api/testApi.d.ts +4 -6
  95. package/build/library/sdk/api/testApi.js +152 -108
  96. package/build/library/sdk/api/testApi.js.map +1 -1
  97. package/build/library/sdk/api/themesApi.d.ts +4 -6
  98. package/build/library/sdk/api/themesApi.js +341 -305
  99. package/build/library/sdk/api/themesApi.js.map +1 -1
  100. package/build/library/sdk/api/thirdPartyAuthApi.d.ts +4 -6
  101. package/build/library/sdk/api/thirdPartyAuthApi.js +387 -353
  102. package/build/library/sdk/api/thirdPartyAuthApi.js.map +1 -1
  103. package/build/library/sdk/api/uploadPortalApi.d.ts +4 -6
  104. package/build/library/sdk/api/uploadPortalApi.js +375 -355
  105. package/build/library/sdk/api/uploadPortalApi.js.map +1 -1
  106. package/build/library/sdk/api/userApi.d.ts +4 -6
  107. package/build/library/sdk/api/userApi.js +2345 -2452
  108. package/build/library/sdk/api/userApi.js.map +1 -1
  109. package/build/library/sdk/api/vlmApi.d.ts +4 -6
  110. package/build/library/sdk/api/vlmApi.js +277 -253
  111. package/build/library/sdk/api/vlmApi.js.map +1 -1
  112. package/build/library/sdk/api/whitelabelsApi.d.ts +4 -6
  113. package/build/library/sdk/api/whitelabelsApi.js +408 -398
  114. package/build/library/sdk/api/whitelabelsApi.js.map +1 -1
  115. package/build/library/sdk/model/deployPretrainedModelRequest.d.ts +4 -0
  116. package/build/library/sdk/model/deployPretrainedModelRequest.js +5 -0
  117. package/build/library/sdk/model/deployPretrainedModelRequest.js.map +1 -1
  118. package/build/library/sdk/model/models.d.ts +47 -7
  119. package/build/library/sdk/model/models.js +33 -22
  120. package/build/library/sdk/model/models.js.map +1 -1
  121. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.d.ts +47 -0
  122. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.js +55 -0
  123. package/build/library/sdk/model/uploadPretrainedModelByUrlRequest.js.map +1 -0
  124. package/build/library/sdk/model/uploadPretrainedModelRequest.d.ts +4 -0
  125. package/build/library/sdk/model/uploadPretrainedModelRequest.js +5 -0
  126. package/build/library/sdk/model/uploadPretrainedModelRequest.js.map +1 -1
  127. package/package.json +3 -2
@@ -12,14 +12,31 @@
12
12
  */
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.OptimizationApi = exports.OptimizationApiApiKeys = void 0;
15
- // tslint:disable-next-line: variable-name, no-var-requires
16
15
  const PATH = require('path');
17
- // tslint:disable-next-line: no-unsafe-any
18
16
  module.paths.push(PATH.join(process.cwd(), 'node_modules'));
19
- const localVarRequest = require("request");
17
+ let fetch;
18
+ let FormData;
19
+ if (globalThis.fetch && globalThis.FormData) {
20
+ fetch = globalThis.fetch;
21
+ FormData = globalThis.FormData;
22
+ }
23
+ else {
24
+ const undici = require('undici');
25
+ fetch = undici.fetch;
26
+ FormData = undici.FormData;
27
+ }
20
28
  const models_1 = require("../model/models");
21
29
  const models_2 = require("../model/models");
22
30
  let defaultBasePath = 'https://studio.edgeimpulse.com/v1';
31
+ async function parseResponse(res) {
32
+ const ct = (res.headers.get('content-type') || '').toLowerCase();
33
+ if (ct.includes('application/json'))
34
+ return res.json();
35
+ if (/^(image|video|audio)\/|application\/(octet-stream|zip|x-tar|cbor)/.test(ct)) {
36
+ return Buffer.from(await res.arrayBuffer());
37
+ }
38
+ return res.text();
39
+ }
23
40
  // ===============================================
24
41
  // This file is autogenerated - Please do not edit
25
42
  // ===============================================
@@ -30,10 +47,30 @@ var OptimizationApiApiKeys;
30
47
  OptimizationApiApiKeys[OptimizationApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(OptimizationApiApiKeys = exports.OptimizationApiApiKeys || (exports.OptimizationApiApiKeys = {}));
32
49
  class OptimizationApi {
50
+ async handleResponse(response, returnType) {
51
+ let body = await parseResponse(response);
52
+ if (!response.ok) {
53
+ let errorMsg;
54
+ if (typeof body === 'object' && body !== null && 'error' in body) {
55
+ errorMsg = body.error;
56
+ }
57
+ else {
58
+ errorMsg = `Failed to call "${response.url}", returned ${response.status}: ` + (typeof body === 'string' ? body : JSON.stringify(body));
59
+ }
60
+ throw new Error(errorMsg);
61
+ }
62
+ if (returnType) {
63
+ body = models_1.ObjectSerializer.deserialize(body, returnType);
64
+ }
65
+ if (typeof body.success === 'boolean' && !body.success) {
66
+ const errString = `Failed to call "${response.url}", returned ${response.status}: ` + body.error;
67
+ throw new Error(body.error || errString);
68
+ }
69
+ return body;
70
+ }
33
71
  constructor(basePathOrUsername, opts, password, basePath) {
34
72
  this._basePath = defaultBasePath;
35
73
  this.defaultHeaders = {};
36
- this._useQuerystring = false;
37
74
  this._opts = {};
38
75
  this.authentications = {
39
76
  'default': new models_1.VoidAuth(),
@@ -54,9 +91,6 @@ class OptimizationApi {
54
91
  }
55
92
  this.opts = opts !== null && opts !== void 0 ? opts : {};
56
93
  }
57
- set useQuerystring(value) {
58
- this._useQuerystring = value;
59
- }
60
94
  set basePath(basePath) {
61
95
  this._basePath = basePath;
62
96
  }
@@ -90,9 +124,11 @@ class OptimizationApi {
90
124
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
91
125
  .replace('{' + 'jobId' + '}', encodeURIComponent(String(jobId)));
92
126
  let localVarQueryParameters = {};
93
- let localVarHeaderParams = Object.assign({
94
- 'User-Agent': 'edgeimpulse-api nodejs'
95
- }, this.defaultHeaders);
127
+ let localVarHeaderParams = {
128
+ 'User-Agent': 'edgeimpulse-api nodejs',
129
+ 'Content-Type': 'application/json',
130
+ ...this.defaultHeaders,
131
+ };
96
132
  const produces = ['application/json'];
97
133
  // give precedence to 'application/json'
98
134
  if (produces.indexOf('application/json') >= 0) {
@@ -101,7 +137,7 @@ class OptimizationApi {
101
137
  else {
102
138
  localVarHeaderParams.Accept = produces.join(',');
103
139
  }
104
- let localVarFormParams = {};
140
+ let localVarFormParams;
105
141
  // verify required parameter 'projectId' is not null or undefined
106
142
  if (projectId === null || projectId === undefined) {
107
143
  throw new Error('Required parameter projectId was null or undefined when calling completeSearch.');
@@ -114,56 +150,52 @@ class OptimizationApi {
114
150
  if (tunerCompleteSearch === null || tunerCompleteSearch === undefined) {
115
151
  throw new Error('Required parameter tunerCompleteSearch was null or undefined when calling completeSearch.');
116
152
  }
117
- Object.assign(localVarHeaderParams, options.headers);
118
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
119
- let localVarUseFormData = false;
153
+ localVarHeaderParams = {
154
+ ...localVarHeaderParams,
155
+ ...options.headers,
156
+ ...this.opts.extraHeaders,
157
+ };
158
+ const queryString = Object.entries(localVarQueryParameters)
159
+ .filter(([, value]) => value !== undefined)
160
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
161
+ .join('&');
162
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
120
163
  let localVarRequestOptions = {
121
164
  method: 'POST',
122
- qs: localVarQueryParameters,
123
- headers: localVarHeaderParams,
124
- uri: localVarPath,
125
- useQuerystring: this._useQuerystring,
126
- agentOptions: { keepAlive: false },
127
- json: true,
128
- body: models_1.ObjectSerializer.serialize(tunerCompleteSearch, "TunerCompleteSearch")
165
+ headers: { ...localVarHeaderParams },
129
166
  };
130
- let authenticationPromise = Promise.resolve();
131
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
132
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
133
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
134
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
135
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
136
- return authenticationPromise.then(() => {
137
- if (Object.keys(localVarFormParams).length) {
138
- if (localVarUseFormData) {
139
- localVarRequestOptions.formData = localVarFormParams;
140
- }
141
- else {
142
- localVarRequestOptions.form = localVarFormParams;
143
- }
167
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(tunerCompleteSearch, "TunerCompleteSearch"));
168
+ let requestOptions = localVarRequestOptions;
169
+ let url = localVarUrl;
170
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
171
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
172
+ url = auth_ApiKeyAuthentication.url;
173
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
174
+ requestOptions = auth_JWTAuthentication.requestOptions;
175
+ url = auth_JWTAuthentication.url;
176
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
177
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
178
+ url = auth_JWTHttpHeaderAuthentication.url;
179
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
180
+ requestOptions = auth_OAuth2.requestOptions;
181
+ url = auth_OAuth2.url;
182
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
183
+ requestOptions = authDefault.requestOptions;
184
+ url = authDefault.url;
185
+ if (localVarFormParams) {
186
+ delete requestOptions.headers['Content-Type'];
187
+ if (localVarFormParams instanceof FormData) {
188
+ // FormData: fetch will handle Content-Type automatically.
189
+ requestOptions.body = localVarFormParams;
144
190
  }
145
- return new Promise((resolve, reject) => {
146
- localVarRequest(localVarRequestOptions, (error, response, body) => {
147
- if (error) {
148
- reject(error);
149
- }
150
- else {
151
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
152
- if (typeof body.success === 'boolean' && !body.success) {
153
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
154
- reject(new Error(body.error || errString));
155
- }
156
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
157
- resolve(body);
158
- }
159
- else {
160
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
161
- reject(errString);
162
- }
163
- }
164
- });
165
- });
166
- });
191
+ else if (Object.keys(localVarFormParams).length > 0) {
192
+ // URL-encoded form
193
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
194
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
195
+ }
196
+ }
197
+ const response = await fetch(url, requestOptions);
198
+ return this.handleResponse(response, 'GenericApiResponse');
167
199
  }
168
200
  /**
169
201
  * Create trial
@@ -177,9 +209,11 @@ class OptimizationApi {
177
209
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
178
210
  .replace('{' + 'jobId' + '}', encodeURIComponent(String(jobId)));
179
211
  let localVarQueryParameters = {};
180
- let localVarHeaderParams = Object.assign({
181
- 'User-Agent': 'edgeimpulse-api nodejs'
182
- }, this.defaultHeaders);
212
+ let localVarHeaderParams = {
213
+ 'User-Agent': 'edgeimpulse-api nodejs',
214
+ 'Content-Type': 'application/json',
215
+ ...this.defaultHeaders,
216
+ };
183
217
  const produces = ['application/json'];
184
218
  // give precedence to 'application/json'
185
219
  if (produces.indexOf('application/json') >= 0) {
@@ -188,7 +222,7 @@ class OptimizationApi {
188
222
  else {
189
223
  localVarHeaderParams.Accept = produces.join(',');
190
224
  }
191
- let localVarFormParams = {};
225
+ let localVarFormParams;
192
226
  // verify required parameter 'projectId' is not null or undefined
193
227
  if (projectId === null || projectId === undefined) {
194
228
  throw new Error('Required parameter projectId was null or undefined when calling createTrial.');
@@ -201,56 +235,52 @@ class OptimizationApi {
201
235
  if (tunerCreateTrialImpulse === null || tunerCreateTrialImpulse === undefined) {
202
236
  throw new Error('Required parameter tunerCreateTrialImpulse was null or undefined when calling createTrial.');
203
237
  }
204
- Object.assign(localVarHeaderParams, options.headers);
205
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
206
- let localVarUseFormData = false;
238
+ localVarHeaderParams = {
239
+ ...localVarHeaderParams,
240
+ ...options.headers,
241
+ ...this.opts.extraHeaders,
242
+ };
243
+ const queryString = Object.entries(localVarQueryParameters)
244
+ .filter(([, value]) => value !== undefined)
245
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
246
+ .join('&');
247
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
207
248
  let localVarRequestOptions = {
208
249
  method: 'POST',
209
- qs: localVarQueryParameters,
210
- headers: localVarHeaderParams,
211
- uri: localVarPath,
212
- useQuerystring: this._useQuerystring,
213
- agentOptions: { keepAlive: false },
214
- json: true,
215
- body: models_1.ObjectSerializer.serialize(tunerCreateTrialImpulse, "TunerCreateTrialImpulse")
250
+ headers: { ...localVarHeaderParams },
216
251
  };
217
- let authenticationPromise = Promise.resolve();
218
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
219
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
220
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
221
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
222
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
223
- return authenticationPromise.then(() => {
224
- if (Object.keys(localVarFormParams).length) {
225
- if (localVarUseFormData) {
226
- localVarRequestOptions.formData = localVarFormParams;
227
- }
228
- else {
229
- localVarRequestOptions.form = localVarFormParams;
230
- }
252
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(tunerCreateTrialImpulse, "TunerCreateTrialImpulse"));
253
+ let requestOptions = localVarRequestOptions;
254
+ let url = localVarUrl;
255
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
256
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
257
+ url = auth_ApiKeyAuthentication.url;
258
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
259
+ requestOptions = auth_JWTAuthentication.requestOptions;
260
+ url = auth_JWTAuthentication.url;
261
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
262
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
263
+ url = auth_JWTHttpHeaderAuthentication.url;
264
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
265
+ requestOptions = auth_OAuth2.requestOptions;
266
+ url = auth_OAuth2.url;
267
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
268
+ requestOptions = authDefault.requestOptions;
269
+ url = authDefault.url;
270
+ if (localVarFormParams) {
271
+ delete requestOptions.headers['Content-Type'];
272
+ if (localVarFormParams instanceof FormData) {
273
+ // FormData: fetch will handle Content-Type automatically.
274
+ requestOptions.body = localVarFormParams;
275
+ }
276
+ else if (Object.keys(localVarFormParams).length > 0) {
277
+ // URL-encoded form
278
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
279
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
231
280
  }
232
- return new Promise((resolve, reject) => {
233
- localVarRequest(localVarRequestOptions, (error, response, body) => {
234
- if (error) {
235
- reject(error);
236
- }
237
- else {
238
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
239
- if (typeof body.success === 'boolean' && !body.success) {
240
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
241
- reject(new Error(body.error || errString));
242
- }
243
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
244
- resolve(body);
245
- }
246
- else {
247
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
248
- reject(errString);
249
- }
250
- }
251
- });
252
- });
253
- });
281
+ }
282
+ const response = await fetch(url, requestOptions);
283
+ return this.handleResponse(response, 'GenericApiResponse');
254
284
  }
255
285
  /**
256
286
  * Completely clears the EON tuner state for this project.
@@ -261,9 +291,11 @@ class OptimizationApi {
261
291
  const localVarPath = this.basePath + '/api/{projectId}/optimize/state'
262
292
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
263
293
  let localVarQueryParameters = {};
264
- let localVarHeaderParams = Object.assign({
265
- 'User-Agent': 'edgeimpulse-api nodejs'
266
- }, this.defaultHeaders);
294
+ let localVarHeaderParams = {
295
+ 'User-Agent': 'edgeimpulse-api nodejs',
296
+ 'Content-Type': 'application/json',
297
+ ...this.defaultHeaders,
298
+ };
267
299
  const produces = ['application/json'];
268
300
  // give precedence to 'application/json'
269
301
  if (produces.indexOf('application/json') >= 0) {
@@ -272,60 +304,56 @@ class OptimizationApi {
272
304
  else {
273
305
  localVarHeaderParams.Accept = produces.join(',');
274
306
  }
275
- let localVarFormParams = {};
307
+ let localVarFormParams;
276
308
  // verify required parameter 'projectId' is not null or undefined
277
309
  if (projectId === null || projectId === undefined) {
278
310
  throw new Error('Required parameter projectId was null or undefined when calling deleteState.');
279
311
  }
280
- Object.assign(localVarHeaderParams, options.headers);
281
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
282
- let localVarUseFormData = false;
312
+ localVarHeaderParams = {
313
+ ...localVarHeaderParams,
314
+ ...options.headers,
315
+ ...this.opts.extraHeaders,
316
+ };
317
+ const queryString = Object.entries(localVarQueryParameters)
318
+ .filter(([, value]) => value !== undefined)
319
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
320
+ .join('&');
321
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
283
322
  let localVarRequestOptions = {
284
323
  method: 'DELETE',
285
- qs: localVarQueryParameters,
286
- headers: localVarHeaderParams,
287
- uri: localVarPath,
288
- useQuerystring: this._useQuerystring,
289
- agentOptions: { keepAlive: false },
290
- json: true,
324
+ headers: { ...localVarHeaderParams },
291
325
  };
292
- let authenticationPromise = Promise.resolve();
293
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
294
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
295
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
296
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
297
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
298
- return authenticationPromise.then(() => {
299
- if (Object.keys(localVarFormParams).length) {
300
- if (localVarUseFormData) {
301
- localVarRequestOptions.formData = localVarFormParams;
302
- }
303
- else {
304
- localVarRequestOptions.form = localVarFormParams;
305
- }
326
+ let requestOptions = localVarRequestOptions;
327
+ let url = localVarUrl;
328
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
329
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
330
+ url = auth_ApiKeyAuthentication.url;
331
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
332
+ requestOptions = auth_JWTAuthentication.requestOptions;
333
+ url = auth_JWTAuthentication.url;
334
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
335
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
336
+ url = auth_JWTHttpHeaderAuthentication.url;
337
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
338
+ requestOptions = auth_OAuth2.requestOptions;
339
+ url = auth_OAuth2.url;
340
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
341
+ requestOptions = authDefault.requestOptions;
342
+ url = authDefault.url;
343
+ if (localVarFormParams) {
344
+ delete requestOptions.headers['Content-Type'];
345
+ if (localVarFormParams instanceof FormData) {
346
+ // FormData: fetch will handle Content-Type automatically.
347
+ requestOptions.body = localVarFormParams;
348
+ }
349
+ else if (Object.keys(localVarFormParams).length > 0) {
350
+ // URL-encoded form
351
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
352
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
306
353
  }
307
- return new Promise((resolve, reject) => {
308
- localVarRequest(localVarRequestOptions, (error, response, body) => {
309
- if (error) {
310
- reject(error);
311
- }
312
- else {
313
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
314
- if (typeof body.success === 'boolean' && !body.success) {
315
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
316
- reject(new Error(body.error || errString));
317
- }
318
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
319
- resolve(body);
320
- }
321
- else {
322
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
323
- reject(errString);
324
- }
325
- }
326
- });
327
- });
328
- });
354
+ }
355
+ const response = await fetch(url, requestOptions);
356
+ return this.handleResponse(response, 'GenericApiResponse');
329
357
  }
330
358
  /**
331
359
  * End an EON trial early. This can for example be used to implement early stopping.
@@ -340,9 +368,11 @@ class OptimizationApi {
340
368
  .replace('{' + 'jobId' + '}', encodeURIComponent(String(jobId)))
341
369
  .replace('{' + 'trialId' + '}', encodeURIComponent(String(trialId)));
342
370
  let localVarQueryParameters = {};
343
- let localVarHeaderParams = Object.assign({
344
- 'User-Agent': 'edgeimpulse-api nodejs'
345
- }, this.defaultHeaders);
371
+ let localVarHeaderParams = {
372
+ 'User-Agent': 'edgeimpulse-api nodejs',
373
+ 'Content-Type': 'application/json',
374
+ ...this.defaultHeaders,
375
+ };
346
376
  const produces = ['application/json'];
347
377
  // give precedence to 'application/json'
348
378
  if (produces.indexOf('application/json') >= 0) {
@@ -351,7 +381,7 @@ class OptimizationApi {
351
381
  else {
352
382
  localVarHeaderParams.Accept = produces.join(',');
353
383
  }
354
- let localVarFormParams = {};
384
+ let localVarFormParams;
355
385
  // verify required parameter 'projectId' is not null or undefined
356
386
  if (projectId === null || projectId === undefined) {
357
387
  throw new Error('Required parameter projectId was null or undefined when calling endTrial.');
@@ -364,55 +394,51 @@ class OptimizationApi {
364
394
  if (trialId === null || trialId === undefined) {
365
395
  throw new Error('Required parameter trialId was null or undefined when calling endTrial.');
366
396
  }
367
- Object.assign(localVarHeaderParams, options.headers);
368
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
369
- let localVarUseFormData = false;
397
+ localVarHeaderParams = {
398
+ ...localVarHeaderParams,
399
+ ...options.headers,
400
+ ...this.opts.extraHeaders,
401
+ };
402
+ const queryString = Object.entries(localVarQueryParameters)
403
+ .filter(([, value]) => value !== undefined)
404
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
405
+ .join('&');
406
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
370
407
  let localVarRequestOptions = {
371
408
  method: 'GET',
372
- qs: localVarQueryParameters,
373
- headers: localVarHeaderParams,
374
- uri: localVarPath,
375
- useQuerystring: this._useQuerystring,
376
- agentOptions: { keepAlive: false },
377
- json: true,
409
+ headers: { ...localVarHeaderParams },
378
410
  };
379
- let authenticationPromise = Promise.resolve();
380
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
381
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
382
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
383
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
384
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
385
- return authenticationPromise.then(() => {
386
- if (Object.keys(localVarFormParams).length) {
387
- if (localVarUseFormData) {
388
- localVarRequestOptions.formData = localVarFormParams;
389
- }
390
- else {
391
- localVarRequestOptions.form = localVarFormParams;
392
- }
411
+ let requestOptions = localVarRequestOptions;
412
+ let url = localVarUrl;
413
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
414
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
415
+ url = auth_ApiKeyAuthentication.url;
416
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
417
+ requestOptions = auth_JWTAuthentication.requestOptions;
418
+ url = auth_JWTAuthentication.url;
419
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
420
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
421
+ url = auth_JWTHttpHeaderAuthentication.url;
422
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
423
+ requestOptions = auth_OAuth2.requestOptions;
424
+ url = auth_OAuth2.url;
425
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
426
+ requestOptions = authDefault.requestOptions;
427
+ url = authDefault.url;
428
+ if (localVarFormParams) {
429
+ delete requestOptions.headers['Content-Type'];
430
+ if (localVarFormParams instanceof FormData) {
431
+ // FormData: fetch will handle Content-Type automatically.
432
+ requestOptions.body = localVarFormParams;
393
433
  }
394
- return new Promise((resolve, reject) => {
395
- localVarRequest(localVarRequestOptions, (error, response, body) => {
396
- if (error) {
397
- reject(error);
398
- }
399
- else {
400
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
401
- if (typeof body.success === 'boolean' && !body.success) {
402
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
403
- reject(new Error(body.error || errString));
404
- }
405
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
406
- resolve(body);
407
- }
408
- else {
409
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
410
- reject(errString);
411
- }
412
- }
413
- });
414
- });
415
- });
434
+ else if (Object.keys(localVarFormParams).length > 0) {
435
+ // URL-encoded form
436
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
437
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
438
+ }
439
+ }
440
+ const response = await fetch(url, requestOptions);
441
+ return this.handleResponse(response, 'GenericApiResponse');
416
442
  }
417
443
  /**
418
444
  * Lists all possible blocks that can be used in the impulse, including any additional information required by the EON tuner that the getImpulseBlocks endpoint does not return
@@ -423,9 +449,11 @@ class OptimizationApi {
423
449
  const localVarPath = this.basePath + '/api/{projectId}/optimize/all-blocks'
424
450
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
425
451
  let localVarQueryParameters = {};
426
- let localVarHeaderParams = Object.assign({
427
- 'User-Agent': 'edgeimpulse-api nodejs'
428
- }, this.defaultHeaders);
452
+ let localVarHeaderParams = {
453
+ 'User-Agent': 'edgeimpulse-api nodejs',
454
+ 'Content-Type': 'application/json',
455
+ ...this.defaultHeaders,
456
+ };
429
457
  const produces = ['application/json'];
430
458
  // give precedence to 'application/json'
431
459
  if (produces.indexOf('application/json') >= 0) {
@@ -434,60 +462,56 @@ class OptimizationApi {
434
462
  else {
435
463
  localVarHeaderParams.Accept = produces.join(',');
436
464
  }
437
- let localVarFormParams = {};
465
+ let localVarFormParams;
438
466
  // verify required parameter 'projectId' is not null or undefined
439
467
  if (projectId === null || projectId === undefined) {
440
468
  throw new Error('Required parameter projectId was null or undefined when calling getAllBlocks.');
441
469
  }
442
- Object.assign(localVarHeaderParams, options.headers);
443
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
444
- let localVarUseFormData = false;
470
+ localVarHeaderParams = {
471
+ ...localVarHeaderParams,
472
+ ...options.headers,
473
+ ...this.opts.extraHeaders,
474
+ };
475
+ const queryString = Object.entries(localVarQueryParameters)
476
+ .filter(([, value]) => value !== undefined)
477
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
478
+ .join('&');
479
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
445
480
  let localVarRequestOptions = {
446
481
  method: 'GET',
447
- qs: localVarQueryParameters,
448
- headers: localVarHeaderParams,
449
- uri: localVarPath,
450
- useQuerystring: this._useQuerystring,
451
- agentOptions: { keepAlive: false },
452
- json: true,
482
+ headers: { ...localVarHeaderParams },
453
483
  };
454
- let authenticationPromise = Promise.resolve();
455
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
456
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
457
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
458
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
459
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
460
- return authenticationPromise.then(() => {
461
- if (Object.keys(localVarFormParams).length) {
462
- if (localVarUseFormData) {
463
- localVarRequestOptions.formData = localVarFormParams;
464
- }
465
- else {
466
- localVarRequestOptions.form = localVarFormParams;
467
- }
484
+ let requestOptions = localVarRequestOptions;
485
+ let url = localVarUrl;
486
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
487
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
488
+ url = auth_ApiKeyAuthentication.url;
489
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
490
+ requestOptions = auth_JWTAuthentication.requestOptions;
491
+ url = auth_JWTAuthentication.url;
492
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
493
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
494
+ url = auth_JWTHttpHeaderAuthentication.url;
495
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
496
+ requestOptions = auth_OAuth2.requestOptions;
497
+ url = auth_OAuth2.url;
498
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
499
+ requestOptions = authDefault.requestOptions;
500
+ url = authDefault.url;
501
+ if (localVarFormParams) {
502
+ delete requestOptions.headers['Content-Type'];
503
+ if (localVarFormParams instanceof FormData) {
504
+ // FormData: fetch will handle Content-Type automatically.
505
+ requestOptions.body = localVarFormParams;
506
+ }
507
+ else if (Object.keys(localVarFormParams).length > 0) {
508
+ // URL-encoded form
509
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
510
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
468
511
  }
469
- return new Promise((resolve, reject) => {
470
- localVarRequest(localVarRequestOptions, (error, response, body) => {
471
- if (error) {
472
- reject(error);
473
- }
474
- else {
475
- body = models_1.ObjectSerializer.deserialize(body, "AllBlocksResponse");
476
- if (typeof body.success === 'boolean' && !body.success) {
477
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
478
- reject(new Error(body.error || errString));
479
- }
480
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
481
- resolve(body);
482
- }
483
- else {
484
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
485
- reject(errString);
486
- }
487
- }
488
- });
489
- });
490
- });
512
+ }
513
+ const response = await fetch(url, requestOptions);
514
+ return this.handleResponse(response, 'AllBlocksResponse');
491
515
  }
492
516
  /**
493
517
  * Get all available learn blocks
@@ -498,9 +522,11 @@ class OptimizationApi {
498
522
  const localVarPath = this.basePath + '/api/{projectId}/optimize/all-learn-blocks'
499
523
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
500
524
  let localVarQueryParameters = {};
501
- let localVarHeaderParams = Object.assign({
502
- 'User-Agent': 'edgeimpulse-api nodejs'
503
- }, this.defaultHeaders);
525
+ let localVarHeaderParams = {
526
+ 'User-Agent': 'edgeimpulse-api nodejs',
527
+ 'Content-Type': 'application/json',
528
+ ...this.defaultHeaders,
529
+ };
504
530
  const produces = ['application/json'];
505
531
  // give precedence to 'application/json'
506
532
  if (produces.indexOf('application/json') >= 0) {
@@ -509,60 +535,56 @@ class OptimizationApi {
509
535
  else {
510
536
  localVarHeaderParams.Accept = produces.join(',');
511
537
  }
512
- let localVarFormParams = {};
538
+ let localVarFormParams;
513
539
  // verify required parameter 'projectId' is not null or undefined
514
540
  if (projectId === null || projectId === undefined) {
515
541
  throw new Error('Required parameter projectId was null or undefined when calling getAllLearnBlocks.');
516
542
  }
517
- Object.assign(localVarHeaderParams, options.headers);
518
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
519
- let localVarUseFormData = false;
543
+ localVarHeaderParams = {
544
+ ...localVarHeaderParams,
545
+ ...options.headers,
546
+ ...this.opts.extraHeaders,
547
+ };
548
+ const queryString = Object.entries(localVarQueryParameters)
549
+ .filter(([, value]) => value !== undefined)
550
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
551
+ .join('&');
552
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
520
553
  let localVarRequestOptions = {
521
554
  method: 'GET',
522
- qs: localVarQueryParameters,
523
- headers: localVarHeaderParams,
524
- uri: localVarPath,
525
- useQuerystring: this._useQuerystring,
526
- agentOptions: { keepAlive: false },
527
- json: true,
555
+ headers: { ...localVarHeaderParams },
528
556
  };
529
- let authenticationPromise = Promise.resolve();
530
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
531
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
532
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
533
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
534
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
535
- return authenticationPromise.then(() => {
536
- if (Object.keys(localVarFormParams).length) {
537
- if (localVarUseFormData) {
538
- localVarRequestOptions.formData = localVarFormParams;
539
- }
540
- else {
541
- localVarRequestOptions.form = localVarFormParams;
542
- }
557
+ let requestOptions = localVarRequestOptions;
558
+ let url = localVarUrl;
559
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
560
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
561
+ url = auth_ApiKeyAuthentication.url;
562
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
563
+ requestOptions = auth_JWTAuthentication.requestOptions;
564
+ url = auth_JWTAuthentication.url;
565
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
566
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
567
+ url = auth_JWTHttpHeaderAuthentication.url;
568
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
569
+ requestOptions = auth_OAuth2.requestOptions;
570
+ url = auth_OAuth2.url;
571
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
572
+ requestOptions = authDefault.requestOptions;
573
+ url = authDefault.url;
574
+ if (localVarFormParams) {
575
+ delete requestOptions.headers['Content-Type'];
576
+ if (localVarFormParams instanceof FormData) {
577
+ // FormData: fetch will handle Content-Type automatically.
578
+ requestOptions.body = localVarFormParams;
543
579
  }
544
- return new Promise((resolve, reject) => {
545
- localVarRequest(localVarRequestOptions, (error, response, body) => {
546
- if (error) {
547
- reject(error);
548
- }
549
- else {
550
- body = models_1.ObjectSerializer.deserialize(body, "AllLearnBlocksResponse");
551
- if (typeof body.success === 'boolean' && !body.success) {
552
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
553
- reject(new Error(body.error || errString));
554
- }
555
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
556
- resolve(body);
557
- }
558
- else {
559
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
560
- reject(errString);
561
- }
562
- }
563
- });
564
- });
565
- });
580
+ else if (Object.keys(localVarFormParams).length > 0) {
581
+ // URL-encoded form
582
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
583
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
584
+ }
585
+ }
586
+ const response = await fetch(url, requestOptions);
587
+ return this.handleResponse(response, 'AllLearnBlocksResponse');
566
588
  }
567
589
  /**
568
590
  * Get config
@@ -573,9 +595,11 @@ class OptimizationApi {
573
595
  const localVarPath = this.basePath + '/api/{projectId}/optimize/config'
574
596
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
575
597
  let localVarQueryParameters = {};
576
- let localVarHeaderParams = Object.assign({
577
- 'User-Agent': 'edgeimpulse-api nodejs'
578
- }, this.defaultHeaders);
598
+ let localVarHeaderParams = {
599
+ 'User-Agent': 'edgeimpulse-api nodejs',
600
+ 'Content-Type': 'application/json',
601
+ ...this.defaultHeaders,
602
+ };
579
603
  const produces = ['application/json'];
580
604
  // give precedence to 'application/json'
581
605
  if (produces.indexOf('application/json') >= 0) {
@@ -584,60 +608,56 @@ class OptimizationApi {
584
608
  else {
585
609
  localVarHeaderParams.Accept = produces.join(',');
586
610
  }
587
- let localVarFormParams = {};
611
+ let localVarFormParams;
588
612
  // verify required parameter 'projectId' is not null or undefined
589
613
  if (projectId === null || projectId === undefined) {
590
614
  throw new Error('Required parameter projectId was null or undefined when calling getConfig.');
591
615
  }
592
- Object.assign(localVarHeaderParams, options.headers);
593
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
594
- let localVarUseFormData = false;
616
+ localVarHeaderParams = {
617
+ ...localVarHeaderParams,
618
+ ...options.headers,
619
+ ...this.opts.extraHeaders,
620
+ };
621
+ const queryString = Object.entries(localVarQueryParameters)
622
+ .filter(([, value]) => value !== undefined)
623
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
624
+ .join('&');
625
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
595
626
  let localVarRequestOptions = {
596
627
  method: 'GET',
597
- qs: localVarQueryParameters,
598
- headers: localVarHeaderParams,
599
- uri: localVarPath,
600
- useQuerystring: this._useQuerystring,
601
- agentOptions: { keepAlive: false },
602
- json: true,
628
+ headers: { ...localVarHeaderParams },
603
629
  };
604
- let authenticationPromise = Promise.resolve();
605
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
606
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
607
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
608
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
609
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
610
- return authenticationPromise.then(() => {
611
- if (Object.keys(localVarFormParams).length) {
612
- if (localVarUseFormData) {
613
- localVarRequestOptions.formData = localVarFormParams;
614
- }
615
- else {
616
- localVarRequestOptions.form = localVarFormParams;
617
- }
630
+ let requestOptions = localVarRequestOptions;
631
+ let url = localVarUrl;
632
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
633
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
634
+ url = auth_ApiKeyAuthentication.url;
635
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
636
+ requestOptions = auth_JWTAuthentication.requestOptions;
637
+ url = auth_JWTAuthentication.url;
638
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
639
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
640
+ url = auth_JWTHttpHeaderAuthentication.url;
641
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
642
+ requestOptions = auth_OAuth2.requestOptions;
643
+ url = auth_OAuth2.url;
644
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
645
+ requestOptions = authDefault.requestOptions;
646
+ url = authDefault.url;
647
+ if (localVarFormParams) {
648
+ delete requestOptions.headers['Content-Type'];
649
+ if (localVarFormParams instanceof FormData) {
650
+ // FormData: fetch will handle Content-Type automatically.
651
+ requestOptions.body = localVarFormParams;
652
+ }
653
+ else if (Object.keys(localVarFormParams).length > 0) {
654
+ // URL-encoded form
655
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
656
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
618
657
  }
619
- return new Promise((resolve, reject) => {
620
- localVarRequest(localVarRequestOptions, (error, response, body) => {
621
- if (error) {
622
- reject(error);
623
- }
624
- else {
625
- body = models_1.ObjectSerializer.deserialize(body, "OptimizeConfigResponse");
626
- if (typeof body.success === 'boolean' && !body.success) {
627
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
628
- reject(new Error(body.error || errString));
629
- }
630
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
631
- resolve(body);
632
- }
633
- else {
634
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
635
- reject(errString);
636
- }
637
- }
638
- });
639
- });
640
- });
658
+ }
659
+ const response = await fetch(url, requestOptions);
660
+ return this.handleResponse(response, 'OptimizeConfigResponse');
641
661
  }
642
662
  /**
643
663
  * Retrieves DSP block parameters
@@ -650,9 +670,11 @@ class OptimizationApi {
650
670
  const localVarPath = this.basePath + '/api/{projectId}/optimize/dsp-parameters'
651
671
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
652
672
  let localVarQueryParameters = {};
653
- let localVarHeaderParams = Object.assign({
654
- 'User-Agent': 'edgeimpulse-api nodejs'
655
- }, this.defaultHeaders);
673
+ let localVarHeaderParams = {
674
+ 'User-Agent': 'edgeimpulse-api nodejs',
675
+ 'Content-Type': 'application/json',
676
+ ...this.defaultHeaders,
677
+ };
656
678
  const produces = ['application/json'];
657
679
  // give precedence to 'application/json'
658
680
  if (produces.indexOf('application/json') >= 0) {
@@ -661,7 +683,7 @@ class OptimizationApi {
661
683
  else {
662
684
  localVarHeaderParams.Accept = produces.join(',');
663
685
  }
664
- let localVarFormParams = {};
686
+ let localVarFormParams;
665
687
  // verify required parameter 'projectId' is not null or undefined
666
688
  if (projectId === null || projectId === undefined) {
667
689
  throw new Error('Required parameter projectId was null or undefined when calling getDspParameters.');
@@ -680,55 +702,51 @@ class OptimizationApi {
680
702
  if ((queryParams === null || queryParams === void 0 ? void 0 : queryParams.organizationDspId) !== undefined) {
681
703
  localVarQueryParameters['organizationDspId'] = models_1.ObjectSerializer.serialize(queryParams.organizationDspId, "number");
682
704
  }
683
- Object.assign(localVarHeaderParams, options.headers);
684
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
685
- let localVarUseFormData = false;
705
+ localVarHeaderParams = {
706
+ ...localVarHeaderParams,
707
+ ...options.headers,
708
+ ...this.opts.extraHeaders,
709
+ };
710
+ const queryString = Object.entries(localVarQueryParameters)
711
+ .filter(([, value]) => value !== undefined)
712
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
713
+ .join('&');
714
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
686
715
  let localVarRequestOptions = {
687
716
  method: 'GET',
688
- qs: localVarQueryParameters,
689
- headers: localVarHeaderParams,
690
- uri: localVarPath,
691
- useQuerystring: this._useQuerystring,
692
- agentOptions: { keepAlive: false },
693
- json: true,
717
+ headers: { ...localVarHeaderParams },
694
718
  };
695
- let authenticationPromise = Promise.resolve();
696
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
697
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
698
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
699
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
700
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
701
- return authenticationPromise.then(() => {
702
- if (Object.keys(localVarFormParams).length) {
703
- if (localVarUseFormData) {
704
- localVarRequestOptions.formData = localVarFormParams;
705
- }
706
- else {
707
- localVarRequestOptions.form = localVarFormParams;
708
- }
719
+ let requestOptions = localVarRequestOptions;
720
+ let url = localVarUrl;
721
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
722
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
723
+ url = auth_ApiKeyAuthentication.url;
724
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
725
+ requestOptions = auth_JWTAuthentication.requestOptions;
726
+ url = auth_JWTAuthentication.url;
727
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
728
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
729
+ url = auth_JWTHttpHeaderAuthentication.url;
730
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
731
+ requestOptions = auth_OAuth2.requestOptions;
732
+ url = auth_OAuth2.url;
733
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
734
+ requestOptions = authDefault.requestOptions;
735
+ url = authDefault.url;
736
+ if (localVarFormParams) {
737
+ delete requestOptions.headers['Content-Type'];
738
+ if (localVarFormParams instanceof FormData) {
739
+ // FormData: fetch will handle Content-Type automatically.
740
+ requestOptions.body = localVarFormParams;
741
+ }
742
+ else if (Object.keys(localVarFormParams).length > 0) {
743
+ // URL-encoded form
744
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
745
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
709
746
  }
710
- return new Promise((resolve, reject) => {
711
- localVarRequest(localVarRequestOptions, (error, response, body) => {
712
- if (error) {
713
- reject(error);
714
- }
715
- else {
716
- body = models_1.ObjectSerializer.deserialize(body, "OptimizeDSPParametersResponse");
717
- if (typeof body.success === 'boolean' && !body.success) {
718
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
719
- reject(new Error(body.error || errString));
720
- }
721
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
722
- resolve(body);
723
- }
724
- else {
725
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
726
- reject(errString);
727
- }
728
- }
729
- });
730
- });
731
- });
747
+ }
748
+ const response = await fetch(url, requestOptions);
749
+ return this.handleResponse(response, 'OptimizeDSPParametersResponse');
732
750
  }
733
751
  /**
734
752
  * Search space
@@ -739,9 +757,11 @@ class OptimizationApi {
739
757
  const localVarPath = this.basePath + '/api/{projectId}/optimize/space'
740
758
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
741
759
  let localVarQueryParameters = {};
742
- let localVarHeaderParams = Object.assign({
743
- 'User-Agent': 'edgeimpulse-api nodejs'
744
- }, this.defaultHeaders);
760
+ let localVarHeaderParams = {
761
+ 'User-Agent': 'edgeimpulse-api nodejs',
762
+ 'Content-Type': 'application/json',
763
+ ...this.defaultHeaders,
764
+ };
745
765
  const produces = ['application/json'];
746
766
  // give precedence to 'application/json'
747
767
  if (produces.indexOf('application/json') >= 0) {
@@ -750,60 +770,56 @@ class OptimizationApi {
750
770
  else {
751
771
  localVarHeaderParams.Accept = produces.join(',');
752
772
  }
753
- let localVarFormParams = {};
773
+ let localVarFormParams;
754
774
  // verify required parameter 'projectId' is not null or undefined
755
775
  if (projectId === null || projectId === undefined) {
756
776
  throw new Error('Required parameter projectId was null or undefined when calling getSpace.');
757
777
  }
758
- Object.assign(localVarHeaderParams, options.headers);
759
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
760
- let localVarUseFormData = false;
778
+ localVarHeaderParams = {
779
+ ...localVarHeaderParams,
780
+ ...options.headers,
781
+ ...this.opts.extraHeaders,
782
+ };
783
+ const queryString = Object.entries(localVarQueryParameters)
784
+ .filter(([, value]) => value !== undefined)
785
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
786
+ .join('&');
787
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
761
788
  let localVarRequestOptions = {
762
789
  method: 'GET',
763
- qs: localVarQueryParameters,
764
- headers: localVarHeaderParams,
765
- uri: localVarPath,
766
- useQuerystring: this._useQuerystring,
767
- agentOptions: { keepAlive: false },
768
- json: true,
790
+ headers: { ...localVarHeaderParams },
769
791
  };
770
- let authenticationPromise = Promise.resolve();
771
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
772
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
773
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
774
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
775
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
776
- return authenticationPromise.then(() => {
777
- if (Object.keys(localVarFormParams).length) {
778
- if (localVarUseFormData) {
779
- localVarRequestOptions.formData = localVarFormParams;
780
- }
781
- else {
782
- localVarRequestOptions.form = localVarFormParams;
783
- }
792
+ let requestOptions = localVarRequestOptions;
793
+ let url = localVarUrl;
794
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
795
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
796
+ url = auth_ApiKeyAuthentication.url;
797
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
798
+ requestOptions = auth_JWTAuthentication.requestOptions;
799
+ url = auth_JWTAuthentication.url;
800
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
801
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
802
+ url = auth_JWTHttpHeaderAuthentication.url;
803
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
804
+ requestOptions = auth_OAuth2.requestOptions;
805
+ url = auth_OAuth2.url;
806
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
807
+ requestOptions = authDefault.requestOptions;
808
+ url = authDefault.url;
809
+ if (localVarFormParams) {
810
+ delete requestOptions.headers['Content-Type'];
811
+ if (localVarFormParams instanceof FormData) {
812
+ // FormData: fetch will handle Content-Type automatically.
813
+ requestOptions.body = localVarFormParams;
784
814
  }
785
- return new Promise((resolve, reject) => {
786
- localVarRequest(localVarRequestOptions, (error, response, body) => {
787
- if (error) {
788
- reject(error);
789
- }
790
- else {
791
- body = models_1.ObjectSerializer.deserialize(body, "OptimizeSpaceResponse");
792
- if (typeof body.success === 'boolean' && !body.success) {
793
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
794
- reject(new Error(body.error || errString));
795
- }
796
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
797
- resolve(body);
798
- }
799
- else {
800
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
801
- reject(errString);
802
- }
803
- }
804
- });
805
- });
806
- });
815
+ else if (Object.keys(localVarFormParams).length > 0) {
816
+ // URL-encoded form
817
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
818
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
819
+ }
820
+ }
821
+ const response = await fetch(url, requestOptions);
822
+ return this.handleResponse(response, 'OptimizeSpaceResponse');
807
823
  }
808
824
  /**
809
825
  * Retrieves the EON tuner state
@@ -814,9 +830,11 @@ class OptimizationApi {
814
830
  const localVarPath = this.basePath + '/api/{projectId}/optimize/state'
815
831
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
816
832
  let localVarQueryParameters = {};
817
- let localVarHeaderParams = Object.assign({
818
- 'User-Agent': 'edgeimpulse-api nodejs'
819
- }, this.defaultHeaders);
833
+ let localVarHeaderParams = {
834
+ 'User-Agent': 'edgeimpulse-api nodejs',
835
+ 'Content-Type': 'application/json',
836
+ ...this.defaultHeaders,
837
+ };
820
838
  const produces = ['application/json'];
821
839
  // give precedence to 'application/json'
822
840
  if (produces.indexOf('application/json') >= 0) {
@@ -825,60 +843,56 @@ class OptimizationApi {
825
843
  else {
826
844
  localVarHeaderParams.Accept = produces.join(',');
827
845
  }
828
- let localVarFormParams = {};
846
+ let localVarFormParams;
829
847
  // verify required parameter 'projectId' is not null or undefined
830
848
  if (projectId === null || projectId === undefined) {
831
849
  throw new Error('Required parameter projectId was null or undefined when calling getState.');
832
850
  }
833
- Object.assign(localVarHeaderParams, options.headers);
834
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
835
- let localVarUseFormData = false;
851
+ localVarHeaderParams = {
852
+ ...localVarHeaderParams,
853
+ ...options.headers,
854
+ ...this.opts.extraHeaders,
855
+ };
856
+ const queryString = Object.entries(localVarQueryParameters)
857
+ .filter(([, value]) => value !== undefined)
858
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
859
+ .join('&');
860
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
836
861
  let localVarRequestOptions = {
837
862
  method: 'GET',
838
- qs: localVarQueryParameters,
839
- headers: localVarHeaderParams,
840
- uri: localVarPath,
841
- useQuerystring: this._useQuerystring,
842
- agentOptions: { keepAlive: false },
843
- json: true,
863
+ headers: { ...localVarHeaderParams },
844
864
  };
845
- let authenticationPromise = Promise.resolve();
846
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
847
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
848
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
849
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
850
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
851
- return authenticationPromise.then(() => {
852
- if (Object.keys(localVarFormParams).length) {
853
- if (localVarUseFormData) {
854
- localVarRequestOptions.formData = localVarFormParams;
855
- }
856
- else {
857
- localVarRequestOptions.form = localVarFormParams;
858
- }
865
+ let requestOptions = localVarRequestOptions;
866
+ let url = localVarUrl;
867
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
868
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
869
+ url = auth_ApiKeyAuthentication.url;
870
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
871
+ requestOptions = auth_JWTAuthentication.requestOptions;
872
+ url = auth_JWTAuthentication.url;
873
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
874
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
875
+ url = auth_JWTHttpHeaderAuthentication.url;
876
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
877
+ requestOptions = auth_OAuth2.requestOptions;
878
+ url = auth_OAuth2.url;
879
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
880
+ requestOptions = authDefault.requestOptions;
881
+ url = authDefault.url;
882
+ if (localVarFormParams) {
883
+ delete requestOptions.headers['Content-Type'];
884
+ if (localVarFormParams instanceof FormData) {
885
+ // FormData: fetch will handle Content-Type automatically.
886
+ requestOptions.body = localVarFormParams;
887
+ }
888
+ else if (Object.keys(localVarFormParams).length > 0) {
889
+ // URL-encoded form
890
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
891
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
859
892
  }
860
- return new Promise((resolve, reject) => {
861
- localVarRequest(localVarRequestOptions, (error, response, body) => {
862
- if (error) {
863
- reject(error);
864
- }
865
- else {
866
- body = models_1.ObjectSerializer.deserialize(body, "OptimizeStateResponse");
867
- if (typeof body.success === 'boolean' && !body.success) {
868
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
869
- reject(new Error(body.error || errString));
870
- }
871
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
872
- resolve(body);
873
- }
874
- else {
875
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
876
- reject(errString);
877
- }
878
- }
879
- });
880
- });
881
- });
893
+ }
894
+ const response = await fetch(url, requestOptions);
895
+ return this.handleResponse(response, 'OptimizeStateResponse');
882
896
  }
883
897
  /**
884
898
  * Retrieves available transfer learning models
@@ -889,9 +903,11 @@ class OptimizationApi {
889
903
  const localVarPath = this.basePath + '/api/{projectId}/optimize/transfer-learning-models'
890
904
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
891
905
  let localVarQueryParameters = {};
892
- let localVarHeaderParams = Object.assign({
893
- 'User-Agent': 'edgeimpulse-api nodejs'
894
- }, this.defaultHeaders);
906
+ let localVarHeaderParams = {
907
+ 'User-Agent': 'edgeimpulse-api nodejs',
908
+ 'Content-Type': 'application/json',
909
+ ...this.defaultHeaders,
910
+ };
895
911
  const produces = ['application/json'];
896
912
  // give precedence to 'application/json'
897
913
  if (produces.indexOf('application/json') >= 0) {
@@ -900,60 +916,56 @@ class OptimizationApi {
900
916
  else {
901
917
  localVarHeaderParams.Accept = produces.join(',');
902
918
  }
903
- let localVarFormParams = {};
919
+ let localVarFormParams;
904
920
  // verify required parameter 'projectId' is not null or undefined
905
921
  if (projectId === null || projectId === undefined) {
906
922
  throw new Error('Required parameter projectId was null or undefined when calling getTransferLearningModels.');
907
923
  }
908
- Object.assign(localVarHeaderParams, options.headers);
909
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
910
- let localVarUseFormData = false;
924
+ localVarHeaderParams = {
925
+ ...localVarHeaderParams,
926
+ ...options.headers,
927
+ ...this.opts.extraHeaders,
928
+ };
929
+ const queryString = Object.entries(localVarQueryParameters)
930
+ .filter(([, value]) => value !== undefined)
931
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
932
+ .join('&');
933
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
911
934
  let localVarRequestOptions = {
912
935
  method: 'GET',
913
- qs: localVarQueryParameters,
914
- headers: localVarHeaderParams,
915
- uri: localVarPath,
916
- useQuerystring: this._useQuerystring,
917
- agentOptions: { keepAlive: false },
918
- json: true,
936
+ headers: { ...localVarHeaderParams },
919
937
  };
920
- let authenticationPromise = Promise.resolve();
921
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
922
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
923
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
924
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
925
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
926
- return authenticationPromise.then(() => {
927
- if (Object.keys(localVarFormParams).length) {
928
- if (localVarUseFormData) {
929
- localVarRequestOptions.formData = localVarFormParams;
930
- }
931
- else {
932
- localVarRequestOptions.form = localVarFormParams;
933
- }
938
+ let requestOptions = localVarRequestOptions;
939
+ let url = localVarUrl;
940
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
941
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
942
+ url = auth_ApiKeyAuthentication.url;
943
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
944
+ requestOptions = auth_JWTAuthentication.requestOptions;
945
+ url = auth_JWTAuthentication.url;
946
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
947
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
948
+ url = auth_JWTHttpHeaderAuthentication.url;
949
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
950
+ requestOptions = auth_OAuth2.requestOptions;
951
+ url = auth_OAuth2.url;
952
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
953
+ requestOptions = authDefault.requestOptions;
954
+ url = authDefault.url;
955
+ if (localVarFormParams) {
956
+ delete requestOptions.headers['Content-Type'];
957
+ if (localVarFormParams instanceof FormData) {
958
+ // FormData: fetch will handle Content-Type automatically.
959
+ requestOptions.body = localVarFormParams;
934
960
  }
935
- return new Promise((resolve, reject) => {
936
- localVarRequest(localVarRequestOptions, (error, response, body) => {
937
- if (error) {
938
- reject(error);
939
- }
940
- else {
941
- body = models_1.ObjectSerializer.deserialize(body, "OptimizeTransferLearningModelsResponse");
942
- if (typeof body.success === 'boolean' && !body.success) {
943
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
944
- reject(new Error(body.error || errString));
945
- }
946
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
947
- resolve(body);
948
- }
949
- else {
950
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
951
- reject(errString);
952
- }
953
- }
954
- });
955
- });
956
- });
961
+ else if (Object.keys(localVarFormParams).length > 0) {
962
+ // URL-encoded form
963
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
964
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
965
+ }
966
+ }
967
+ const response = await fetch(url, requestOptions);
968
+ return this.handleResponse(response, 'OptimizeTransferLearningModelsResponse');
957
969
  }
958
970
  /**
959
971
  * Get the logs for a trial.
@@ -966,9 +978,11 @@ class OptimizationApi {
966
978
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
967
979
  .replace('{' + 'trialId' + '}', encodeURIComponent(String(trialId)));
968
980
  let localVarQueryParameters = {};
969
- let localVarHeaderParams = Object.assign({
970
- 'User-Agent': 'edgeimpulse-api nodejs'
971
- }, this.defaultHeaders);
981
+ let localVarHeaderParams = {
982
+ 'User-Agent': 'edgeimpulse-api nodejs',
983
+ 'Content-Type': 'application/json',
984
+ ...this.defaultHeaders,
985
+ };
972
986
  const produces = ['application/json'];
973
987
  // give precedence to 'application/json'
974
988
  if (produces.indexOf('application/json') >= 0) {
@@ -977,7 +991,7 @@ class OptimizationApi {
977
991
  else {
978
992
  localVarHeaderParams.Accept = produces.join(',');
979
993
  }
980
- let localVarFormParams = {};
994
+ let localVarFormParams;
981
995
  // verify required parameter 'projectId' is not null or undefined
982
996
  if (projectId === null || projectId === undefined) {
983
997
  throw new Error('Required parameter projectId was null or undefined when calling getTrialLogs.');
@@ -986,55 +1000,51 @@ class OptimizationApi {
986
1000
  if (trialId === null || trialId === undefined) {
987
1001
  throw new Error('Required parameter trialId was null or undefined when calling getTrialLogs.');
988
1002
  }
989
- Object.assign(localVarHeaderParams, options.headers);
990
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
991
- let localVarUseFormData = false;
1003
+ localVarHeaderParams = {
1004
+ ...localVarHeaderParams,
1005
+ ...options.headers,
1006
+ ...this.opts.extraHeaders,
1007
+ };
1008
+ const queryString = Object.entries(localVarQueryParameters)
1009
+ .filter(([, value]) => value !== undefined)
1010
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1011
+ .join('&');
1012
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
992
1013
  let localVarRequestOptions = {
993
1014
  method: 'GET',
994
- qs: localVarQueryParameters,
995
- headers: localVarHeaderParams,
996
- uri: localVarPath,
997
- useQuerystring: this._useQuerystring,
998
- agentOptions: { keepAlive: false },
999
- json: true,
1015
+ headers: { ...localVarHeaderParams },
1000
1016
  };
1001
- let authenticationPromise = Promise.resolve();
1002
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1003
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1004
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1005
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1006
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1007
- return authenticationPromise.then(() => {
1008
- if (Object.keys(localVarFormParams).length) {
1009
- if (localVarUseFormData) {
1010
- localVarRequestOptions.formData = localVarFormParams;
1011
- }
1012
- else {
1013
- localVarRequestOptions.form = localVarFormParams;
1014
- }
1017
+ let requestOptions = localVarRequestOptions;
1018
+ let url = localVarUrl;
1019
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1020
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1021
+ url = auth_ApiKeyAuthentication.url;
1022
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1023
+ requestOptions = auth_JWTAuthentication.requestOptions;
1024
+ url = auth_JWTAuthentication.url;
1025
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1026
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1027
+ url = auth_JWTHttpHeaderAuthentication.url;
1028
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1029
+ requestOptions = auth_OAuth2.requestOptions;
1030
+ url = auth_OAuth2.url;
1031
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1032
+ requestOptions = authDefault.requestOptions;
1033
+ url = authDefault.url;
1034
+ if (localVarFormParams) {
1035
+ delete requestOptions.headers['Content-Type'];
1036
+ if (localVarFormParams instanceof FormData) {
1037
+ // FormData: fetch will handle Content-Type automatically.
1038
+ requestOptions.body = localVarFormParams;
1039
+ }
1040
+ else if (Object.keys(localVarFormParams).length > 0) {
1041
+ // URL-encoded form
1042
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1043
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1015
1044
  }
1016
- return new Promise((resolve, reject) => {
1017
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1018
- if (error) {
1019
- reject(error);
1020
- }
1021
- else {
1022
- body = models_1.ObjectSerializer.deserialize(body, "LogStdoutResponse");
1023
- if (typeof body.success === 'boolean' && !body.success) {
1024
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1025
- reject(new Error(body.error || errString));
1026
- }
1027
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1028
- resolve(body);
1029
- }
1030
- else {
1031
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1032
- reject(errString);
1033
- }
1034
- }
1035
- });
1036
- });
1037
- });
1045
+ }
1046
+ const response = await fetch(url, requestOptions);
1047
+ return this.handleResponse(response, 'LogStdoutResponse');
1038
1048
  }
1039
1049
  /**
1040
1050
  * Retrieves the EON tuner state for a specific run.
@@ -1047,9 +1057,11 @@ class OptimizationApi {
1047
1057
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1048
1058
  .replace('{' + 'tunerCoordinatorJobId' + '}', encodeURIComponent(String(tunerCoordinatorJobId)));
1049
1059
  let localVarQueryParameters = {};
1050
- let localVarHeaderParams = Object.assign({
1051
- 'User-Agent': 'edgeimpulse-api nodejs'
1052
- }, this.defaultHeaders);
1060
+ let localVarHeaderParams = {
1061
+ 'User-Agent': 'edgeimpulse-api nodejs',
1062
+ 'Content-Type': 'application/json',
1063
+ ...this.defaultHeaders,
1064
+ };
1053
1065
  const produces = ['application/json'];
1054
1066
  // give precedence to 'application/json'
1055
1067
  if (produces.indexOf('application/json') >= 0) {
@@ -1058,7 +1070,7 @@ class OptimizationApi {
1058
1070
  else {
1059
1071
  localVarHeaderParams.Accept = produces.join(',');
1060
1072
  }
1061
- let localVarFormParams = {};
1073
+ let localVarFormParams;
1062
1074
  // verify required parameter 'projectId' is not null or undefined
1063
1075
  if (projectId === null || projectId === undefined) {
1064
1076
  throw new Error('Required parameter projectId was null or undefined when calling getTunerRunState.');
@@ -1067,55 +1079,51 @@ class OptimizationApi {
1067
1079
  if (tunerCoordinatorJobId === null || tunerCoordinatorJobId === undefined) {
1068
1080
  throw new Error('Required parameter tunerCoordinatorJobId was null or undefined when calling getTunerRunState.');
1069
1081
  }
1070
- Object.assign(localVarHeaderParams, options.headers);
1071
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1072
- let localVarUseFormData = false;
1082
+ localVarHeaderParams = {
1083
+ ...localVarHeaderParams,
1084
+ ...options.headers,
1085
+ ...this.opts.extraHeaders,
1086
+ };
1087
+ const queryString = Object.entries(localVarQueryParameters)
1088
+ .filter(([, value]) => value !== undefined)
1089
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1090
+ .join('&');
1091
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1073
1092
  let localVarRequestOptions = {
1074
1093
  method: 'GET',
1075
- qs: localVarQueryParameters,
1076
- headers: localVarHeaderParams,
1077
- uri: localVarPath,
1078
- useQuerystring: this._useQuerystring,
1079
- agentOptions: { keepAlive: false },
1080
- json: true,
1094
+ headers: { ...localVarHeaderParams },
1081
1095
  };
1082
- let authenticationPromise = Promise.resolve();
1083
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1084
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1085
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1086
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1087
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1088
- return authenticationPromise.then(() => {
1089
- if (Object.keys(localVarFormParams).length) {
1090
- if (localVarUseFormData) {
1091
- localVarRequestOptions.formData = localVarFormParams;
1092
- }
1093
- else {
1094
- localVarRequestOptions.form = localVarFormParams;
1095
- }
1096
+ let requestOptions = localVarRequestOptions;
1097
+ let url = localVarUrl;
1098
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1099
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1100
+ url = auth_ApiKeyAuthentication.url;
1101
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1102
+ requestOptions = auth_JWTAuthentication.requestOptions;
1103
+ url = auth_JWTAuthentication.url;
1104
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1105
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1106
+ url = auth_JWTHttpHeaderAuthentication.url;
1107
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1108
+ requestOptions = auth_OAuth2.requestOptions;
1109
+ url = auth_OAuth2.url;
1110
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1111
+ requestOptions = authDefault.requestOptions;
1112
+ url = authDefault.url;
1113
+ if (localVarFormParams) {
1114
+ delete requestOptions.headers['Content-Type'];
1115
+ if (localVarFormParams instanceof FormData) {
1116
+ // FormData: fetch will handle Content-Type automatically.
1117
+ requestOptions.body = localVarFormParams;
1118
+ }
1119
+ else if (Object.keys(localVarFormParams).length > 0) {
1120
+ // URL-encoded form
1121
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1122
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1096
1123
  }
1097
- return new Promise((resolve, reject) => {
1098
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1099
- if (error) {
1100
- reject(error);
1101
- }
1102
- else {
1103
- body = models_1.ObjectSerializer.deserialize(body, "OptimizeStateResponse");
1104
- if (typeof body.success === 'boolean' && !body.success) {
1105
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1106
- reject(new Error(body.error || errString));
1107
- }
1108
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1109
- resolve(body);
1110
- }
1111
- else {
1112
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1113
- reject(errString);
1114
- }
1115
- }
1116
- });
1117
- });
1118
- });
1124
+ }
1125
+ const response = await fetch(url, requestOptions);
1126
+ return this.handleResponse(response, 'OptimizeStateResponse');
1119
1127
  }
1120
1128
  /**
1121
1129
  * Get window settings
@@ -1126,9 +1134,11 @@ class OptimizationApi {
1126
1134
  const localVarPath = this.basePath + '/api/{projectId}/optimize/window-settings'
1127
1135
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
1128
1136
  let localVarQueryParameters = {};
1129
- let localVarHeaderParams = Object.assign({
1130
- 'User-Agent': 'edgeimpulse-api nodejs'
1131
- }, this.defaultHeaders);
1137
+ let localVarHeaderParams = {
1138
+ 'User-Agent': 'edgeimpulse-api nodejs',
1139
+ 'Content-Type': 'application/json',
1140
+ ...this.defaultHeaders,
1141
+ };
1132
1142
  const produces = ['application/json'];
1133
1143
  // give precedence to 'application/json'
1134
1144
  if (produces.indexOf('application/json') >= 0) {
@@ -1137,60 +1147,56 @@ class OptimizationApi {
1137
1147
  else {
1138
1148
  localVarHeaderParams.Accept = produces.join(',');
1139
1149
  }
1140
- let localVarFormParams = {};
1150
+ let localVarFormParams;
1141
1151
  // verify required parameter 'projectId' is not null or undefined
1142
1152
  if (projectId === null || projectId === undefined) {
1143
1153
  throw new Error('Required parameter projectId was null or undefined when calling getWindowSettings.');
1144
1154
  }
1145
- Object.assign(localVarHeaderParams, options.headers);
1146
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1147
- let localVarUseFormData = false;
1155
+ localVarHeaderParams = {
1156
+ ...localVarHeaderParams,
1157
+ ...options.headers,
1158
+ ...this.opts.extraHeaders,
1159
+ };
1160
+ const queryString = Object.entries(localVarQueryParameters)
1161
+ .filter(([, value]) => value !== undefined)
1162
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1163
+ .join('&');
1164
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1148
1165
  let localVarRequestOptions = {
1149
1166
  method: 'GET',
1150
- qs: localVarQueryParameters,
1151
- headers: localVarHeaderParams,
1152
- uri: localVarPath,
1153
- useQuerystring: this._useQuerystring,
1154
- agentOptions: { keepAlive: false },
1155
- json: true,
1167
+ headers: { ...localVarHeaderParams },
1156
1168
  };
1157
- let authenticationPromise = Promise.resolve();
1158
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1159
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1160
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1161
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1162
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1163
- return authenticationPromise.then(() => {
1164
- if (Object.keys(localVarFormParams).length) {
1165
- if (localVarUseFormData) {
1166
- localVarRequestOptions.formData = localVarFormParams;
1167
- }
1168
- else {
1169
- localVarRequestOptions.form = localVarFormParams;
1170
- }
1169
+ let requestOptions = localVarRequestOptions;
1170
+ let url = localVarUrl;
1171
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1172
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1173
+ url = auth_ApiKeyAuthentication.url;
1174
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1175
+ requestOptions = auth_JWTAuthentication.requestOptions;
1176
+ url = auth_JWTAuthentication.url;
1177
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1178
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1179
+ url = auth_JWTHttpHeaderAuthentication.url;
1180
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1181
+ requestOptions = auth_OAuth2.requestOptions;
1182
+ url = auth_OAuth2.url;
1183
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1184
+ requestOptions = authDefault.requestOptions;
1185
+ url = authDefault.url;
1186
+ if (localVarFormParams) {
1187
+ delete requestOptions.headers['Content-Type'];
1188
+ if (localVarFormParams instanceof FormData) {
1189
+ // FormData: fetch will handle Content-Type automatically.
1190
+ requestOptions.body = localVarFormParams;
1171
1191
  }
1172
- return new Promise((resolve, reject) => {
1173
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1174
- if (error) {
1175
- reject(error);
1176
- }
1177
- else {
1178
- body = models_1.ObjectSerializer.deserialize(body, "WindowSettingsResponse");
1179
- if (typeof body.success === 'boolean' && !body.success) {
1180
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1181
- reject(new Error(body.error || errString));
1182
- }
1183
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1184
- resolve(body);
1185
- }
1186
- else {
1187
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1188
- reject(errString);
1189
- }
1190
- }
1191
- });
1192
- });
1193
- });
1192
+ else if (Object.keys(localVarFormParams).length > 0) {
1193
+ // URL-encoded form
1194
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1195
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1196
+ }
1197
+ }
1198
+ const response = await fetch(url, requestOptions);
1199
+ return this.handleResponse(response, 'WindowSettingsResponse');
1194
1200
  }
1195
1201
  /**
1196
1202
  * List all the tuner runs for a project.
@@ -1201,9 +1207,11 @@ class OptimizationApi {
1201
1207
  const localVarPath = this.basePath + '/api/{projectId}/optimize/runs'
1202
1208
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
1203
1209
  let localVarQueryParameters = {};
1204
- let localVarHeaderParams = Object.assign({
1205
- 'User-Agent': 'edgeimpulse-api nodejs'
1206
- }, this.defaultHeaders);
1210
+ let localVarHeaderParams = {
1211
+ 'User-Agent': 'edgeimpulse-api nodejs',
1212
+ 'Content-Type': 'application/json',
1213
+ ...this.defaultHeaders,
1214
+ };
1207
1215
  const produces = ['application/json'];
1208
1216
  // give precedence to 'application/json'
1209
1217
  if (produces.indexOf('application/json') >= 0) {
@@ -1212,60 +1220,56 @@ class OptimizationApi {
1212
1220
  else {
1213
1221
  localVarHeaderParams.Accept = produces.join(',');
1214
1222
  }
1215
- let localVarFormParams = {};
1223
+ let localVarFormParams;
1216
1224
  // verify required parameter 'projectId' is not null or undefined
1217
1225
  if (projectId === null || projectId === undefined) {
1218
1226
  throw new Error('Required parameter projectId was null or undefined when calling listTunerRuns.');
1219
1227
  }
1220
- Object.assign(localVarHeaderParams, options.headers);
1221
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1222
- let localVarUseFormData = false;
1228
+ localVarHeaderParams = {
1229
+ ...localVarHeaderParams,
1230
+ ...options.headers,
1231
+ ...this.opts.extraHeaders,
1232
+ };
1233
+ const queryString = Object.entries(localVarQueryParameters)
1234
+ .filter(([, value]) => value !== undefined)
1235
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1236
+ .join('&');
1237
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1223
1238
  let localVarRequestOptions = {
1224
1239
  method: 'GET',
1225
- qs: localVarQueryParameters,
1226
- headers: localVarHeaderParams,
1227
- uri: localVarPath,
1228
- useQuerystring: this._useQuerystring,
1229
- agentOptions: { keepAlive: false },
1230
- json: true,
1240
+ headers: { ...localVarHeaderParams },
1231
1241
  };
1232
- let authenticationPromise = Promise.resolve();
1233
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1234
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1235
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1236
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1237
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1238
- return authenticationPromise.then(() => {
1239
- if (Object.keys(localVarFormParams).length) {
1240
- if (localVarUseFormData) {
1241
- localVarRequestOptions.formData = localVarFormParams;
1242
- }
1243
- else {
1244
- localVarRequestOptions.form = localVarFormParams;
1245
- }
1242
+ let requestOptions = localVarRequestOptions;
1243
+ let url = localVarUrl;
1244
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1245
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1246
+ url = auth_ApiKeyAuthentication.url;
1247
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1248
+ requestOptions = auth_JWTAuthentication.requestOptions;
1249
+ url = auth_JWTAuthentication.url;
1250
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1251
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1252
+ url = auth_JWTHttpHeaderAuthentication.url;
1253
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1254
+ requestOptions = auth_OAuth2.requestOptions;
1255
+ url = auth_OAuth2.url;
1256
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1257
+ requestOptions = authDefault.requestOptions;
1258
+ url = authDefault.url;
1259
+ if (localVarFormParams) {
1260
+ delete requestOptions.headers['Content-Type'];
1261
+ if (localVarFormParams instanceof FormData) {
1262
+ // FormData: fetch will handle Content-Type automatically.
1263
+ requestOptions.body = localVarFormParams;
1264
+ }
1265
+ else if (Object.keys(localVarFormParams).length > 0) {
1266
+ // URL-encoded form
1267
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1268
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1246
1269
  }
1247
- return new Promise((resolve, reject) => {
1248
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1249
- if (error) {
1250
- reject(error);
1251
- }
1252
- else {
1253
- body = models_1.ObjectSerializer.deserialize(body, "ListTunerRunsResponse");
1254
- if (typeof body.success === 'boolean' && !body.success) {
1255
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1256
- reject(new Error(body.error || errString));
1257
- }
1258
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1259
- resolve(body);
1260
- }
1261
- else {
1262
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1263
- reject(errString);
1264
- }
1265
- }
1266
- });
1267
- });
1268
- });
1270
+ }
1271
+ const response = await fetch(url, requestOptions);
1272
+ return this.handleResponse(response, 'ListTunerRunsResponse');
1269
1273
  }
1270
1274
  /**
1271
1275
  * Update config
@@ -1277,9 +1281,11 @@ class OptimizationApi {
1277
1281
  const localVarPath = this.basePath + '/api/{projectId}/optimize/config'
1278
1282
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)));
1279
1283
  let localVarQueryParameters = {};
1280
- let localVarHeaderParams = Object.assign({
1281
- 'User-Agent': 'edgeimpulse-api nodejs'
1282
- }, this.defaultHeaders);
1284
+ let localVarHeaderParams = {
1285
+ 'User-Agent': 'edgeimpulse-api nodejs',
1286
+ 'Content-Type': 'application/json',
1287
+ ...this.defaultHeaders,
1288
+ };
1283
1289
  const produces = ['application/json'];
1284
1290
  // give precedence to 'application/json'
1285
1291
  if (produces.indexOf('application/json') >= 0) {
@@ -1288,7 +1294,7 @@ class OptimizationApi {
1288
1294
  else {
1289
1295
  localVarHeaderParams.Accept = produces.join(',');
1290
1296
  }
1291
- let localVarFormParams = {};
1297
+ let localVarFormParams;
1292
1298
  // verify required parameter 'projectId' is not null or undefined
1293
1299
  if (projectId === null || projectId === undefined) {
1294
1300
  throw new Error('Required parameter projectId was null or undefined when calling updateConfig.');
@@ -1297,56 +1303,52 @@ class OptimizationApi {
1297
1303
  if (optimizeConfig === null || optimizeConfig === undefined) {
1298
1304
  throw new Error('Required parameter optimizeConfig was null or undefined when calling updateConfig.');
1299
1305
  }
1300
- Object.assign(localVarHeaderParams, options.headers);
1301
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1302
- let localVarUseFormData = false;
1306
+ localVarHeaderParams = {
1307
+ ...localVarHeaderParams,
1308
+ ...options.headers,
1309
+ ...this.opts.extraHeaders,
1310
+ };
1311
+ const queryString = Object.entries(localVarQueryParameters)
1312
+ .filter(([, value]) => value !== undefined)
1313
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1314
+ .join('&');
1315
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1303
1316
  let localVarRequestOptions = {
1304
1317
  method: 'POST',
1305
- qs: localVarQueryParameters,
1306
- headers: localVarHeaderParams,
1307
- uri: localVarPath,
1308
- useQuerystring: this._useQuerystring,
1309
- agentOptions: { keepAlive: false },
1310
- json: true,
1311
- body: models_1.ObjectSerializer.serialize(optimizeConfig, "OptimizeConfig")
1318
+ headers: { ...localVarHeaderParams },
1312
1319
  };
1313
- let authenticationPromise = Promise.resolve();
1314
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1315
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1316
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1317
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1318
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1319
- return authenticationPromise.then(() => {
1320
- if (Object.keys(localVarFormParams).length) {
1321
- if (localVarUseFormData) {
1322
- localVarRequestOptions.formData = localVarFormParams;
1323
- }
1324
- else {
1325
- localVarRequestOptions.form = localVarFormParams;
1326
- }
1320
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(optimizeConfig, "OptimizeConfig"));
1321
+ let requestOptions = localVarRequestOptions;
1322
+ let url = localVarUrl;
1323
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1324
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1325
+ url = auth_ApiKeyAuthentication.url;
1326
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1327
+ requestOptions = auth_JWTAuthentication.requestOptions;
1328
+ url = auth_JWTAuthentication.url;
1329
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1330
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1331
+ url = auth_JWTHttpHeaderAuthentication.url;
1332
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1333
+ requestOptions = auth_OAuth2.requestOptions;
1334
+ url = auth_OAuth2.url;
1335
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1336
+ requestOptions = authDefault.requestOptions;
1337
+ url = authDefault.url;
1338
+ if (localVarFormParams) {
1339
+ delete requestOptions.headers['Content-Type'];
1340
+ if (localVarFormParams instanceof FormData) {
1341
+ // FormData: fetch will handle Content-Type automatically.
1342
+ requestOptions.body = localVarFormParams;
1327
1343
  }
1328
- return new Promise((resolve, reject) => {
1329
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1330
- if (error) {
1331
- reject(error);
1332
- }
1333
- else {
1334
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
1335
- if (typeof body.success === 'boolean' && !body.success) {
1336
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1337
- reject(new Error(body.error || errString));
1338
- }
1339
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1340
- resolve(body);
1341
- }
1342
- else {
1343
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1344
- reject(errString);
1345
- }
1346
- }
1347
- });
1348
- });
1349
- });
1344
+ else if (Object.keys(localVarFormParams).length > 0) {
1345
+ // URL-encoded form
1346
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1347
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1348
+ }
1349
+ }
1350
+ const response = await fetch(url, requestOptions);
1351
+ return this.handleResponse(response, 'GenericApiResponse');
1350
1352
  }
1351
1353
  /**
1352
1354
  * Updates the EON tuner state for a specific run.
@@ -1360,9 +1362,11 @@ class OptimizationApi {
1360
1362
  .replace('{' + 'projectId' + '}', encodeURIComponent(String(projectId)))
1361
1363
  .replace('{' + 'tunerCoordinatorJobId' + '}', encodeURIComponent(String(tunerCoordinatorJobId)));
1362
1364
  let localVarQueryParameters = {};
1363
- let localVarHeaderParams = Object.assign({
1364
- 'User-Agent': 'edgeimpulse-api nodejs'
1365
- }, this.defaultHeaders);
1365
+ let localVarHeaderParams = {
1366
+ 'User-Agent': 'edgeimpulse-api nodejs',
1367
+ 'Content-Type': 'application/json',
1368
+ ...this.defaultHeaders,
1369
+ };
1366
1370
  const produces = ['application/json'];
1367
1371
  // give precedence to 'application/json'
1368
1372
  if (produces.indexOf('application/json') >= 0) {
@@ -1371,7 +1375,7 @@ class OptimizationApi {
1371
1375
  else {
1372
1376
  localVarHeaderParams.Accept = produces.join(',');
1373
1377
  }
1374
- let localVarFormParams = {};
1378
+ let localVarFormParams;
1375
1379
  // verify required parameter 'projectId' is not null or undefined
1376
1380
  if (projectId === null || projectId === undefined) {
1377
1381
  throw new Error('Required parameter projectId was null or undefined when calling updateTunerRun.');
@@ -1384,56 +1388,52 @@ class OptimizationApi {
1384
1388
  if (updateTunerRunRequest === null || updateTunerRunRequest === undefined) {
1385
1389
  throw new Error('Required parameter updateTunerRunRequest was null or undefined when calling updateTunerRun.');
1386
1390
  }
1387
- Object.assign(localVarHeaderParams, options.headers);
1388
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1389
- let localVarUseFormData = false;
1391
+ localVarHeaderParams = {
1392
+ ...localVarHeaderParams,
1393
+ ...options.headers,
1394
+ ...this.opts.extraHeaders,
1395
+ };
1396
+ const queryString = Object.entries(localVarQueryParameters)
1397
+ .filter(([, value]) => value !== undefined)
1398
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1399
+ .join('&');
1400
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1390
1401
  let localVarRequestOptions = {
1391
1402
  method: 'POST',
1392
- qs: localVarQueryParameters,
1393
- headers: localVarHeaderParams,
1394
- uri: localVarPath,
1395
- useQuerystring: this._useQuerystring,
1396
- agentOptions: { keepAlive: false },
1397
- json: true,
1398
- body: models_1.ObjectSerializer.serialize(updateTunerRunRequest, "UpdateTunerRunRequest")
1403
+ headers: { ...localVarHeaderParams },
1399
1404
  };
1400
- let authenticationPromise = Promise.resolve();
1401
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1402
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1403
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1404
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1405
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1406
- return authenticationPromise.then(() => {
1407
- if (Object.keys(localVarFormParams).length) {
1408
- if (localVarUseFormData) {
1409
- localVarRequestOptions.formData = localVarFormParams;
1410
- }
1411
- else {
1412
- localVarRequestOptions.form = localVarFormParams;
1413
- }
1405
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(updateTunerRunRequest, "UpdateTunerRunRequest"));
1406
+ let requestOptions = localVarRequestOptions;
1407
+ let url = localVarUrl;
1408
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1409
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1410
+ url = auth_ApiKeyAuthentication.url;
1411
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1412
+ requestOptions = auth_JWTAuthentication.requestOptions;
1413
+ url = auth_JWTAuthentication.url;
1414
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1415
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1416
+ url = auth_JWTHttpHeaderAuthentication.url;
1417
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1418
+ requestOptions = auth_OAuth2.requestOptions;
1419
+ url = auth_OAuth2.url;
1420
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1421
+ requestOptions = authDefault.requestOptions;
1422
+ url = authDefault.url;
1423
+ if (localVarFormParams) {
1424
+ delete requestOptions.headers['Content-Type'];
1425
+ if (localVarFormParams instanceof FormData) {
1426
+ // FormData: fetch will handle Content-Type automatically.
1427
+ requestOptions.body = localVarFormParams;
1414
1428
  }
1415
- return new Promise((resolve, reject) => {
1416
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1417
- if (error) {
1418
- reject(error);
1419
- }
1420
- else {
1421
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
1422
- if (typeof body.success === 'boolean' && !body.success) {
1423
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1424
- reject(new Error(body.error || errString));
1425
- }
1426
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1427
- resolve(body);
1428
- }
1429
- else {
1430
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1431
- reject(errString);
1432
- }
1433
- }
1434
- });
1435
- });
1436
- });
1429
+ else if (Object.keys(localVarFormParams).length > 0) {
1430
+ // URL-encoded form
1431
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1432
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1433
+ }
1434
+ }
1435
+ const response = await fetch(url, requestOptions);
1436
+ return this.handleResponse(response, 'GenericApiResponse');
1437
1437
  }
1438
1438
  }
1439
1439
  exports.OptimizationApi = OptimizationApi;