edge-impulse-api 1.82.6 → 1.82.8

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.WhitelabelsApi = exports.WhitelabelsApiApiKeys = 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 WhitelabelsApiApiKeys;
30
47
  WhitelabelsApiApiKeys[WhitelabelsApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(WhitelabelsApiApiKeys = exports.WhitelabelsApiApiKeys || (exports.WhitelabelsApiApiKeys = {}));
32
49
  class WhitelabelsApi {
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 WhitelabelsApi {
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
  }
@@ -86,9 +120,11 @@ class WhitelabelsApi {
86
120
  async createWhitelabel(createWhitelabelRequest, options = { headers: {} }) {
87
121
  const localVarPath = this.basePath + '/api/whitelabels';
88
122
  let localVarQueryParameters = {};
89
- let localVarHeaderParams = Object.assign({
90
- 'User-Agent': 'edgeimpulse-api nodejs'
91
- }, this.defaultHeaders);
123
+ let localVarHeaderParams = {
124
+ 'User-Agent': 'edgeimpulse-api nodejs',
125
+ 'Content-Type': 'application/json',
126
+ ...this.defaultHeaders,
127
+ };
92
128
  const produces = ['application/json'];
93
129
  // give precedence to 'application/json'
94
130
  if (produces.indexOf('application/json') >= 0) {
@@ -97,61 +133,57 @@ class WhitelabelsApi {
97
133
  else {
98
134
  localVarHeaderParams.Accept = produces.join(',');
99
135
  }
100
- let localVarFormParams = {};
136
+ let localVarFormParams;
101
137
  // verify required parameter 'createWhitelabelRequest' is not null or undefined
102
138
  if (createWhitelabelRequest === null || createWhitelabelRequest === undefined) {
103
139
  throw new Error('Required parameter createWhitelabelRequest was null or undefined when calling createWhitelabel.');
104
140
  }
105
- Object.assign(localVarHeaderParams, options.headers);
106
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
107
- let localVarUseFormData = false;
141
+ localVarHeaderParams = {
142
+ ...localVarHeaderParams,
143
+ ...options.headers,
144
+ ...this.opts.extraHeaders,
145
+ };
146
+ const queryString = Object.entries(localVarQueryParameters)
147
+ .filter(([, value]) => value !== undefined)
148
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
149
+ .join('&');
150
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
108
151
  let localVarRequestOptions = {
109
152
  method: 'POST',
110
- qs: localVarQueryParameters,
111
- headers: localVarHeaderParams,
112
- uri: localVarPath,
113
- useQuerystring: this._useQuerystring,
114
- agentOptions: { keepAlive: false },
115
- json: true,
116
- body: models_1.ObjectSerializer.serialize(createWhitelabelRequest, "CreateWhitelabelRequest")
153
+ headers: { ...localVarHeaderParams },
117
154
  };
118
- let authenticationPromise = Promise.resolve();
119
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
120
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
121
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
122
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
123
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
124
- return authenticationPromise.then(() => {
125
- if (Object.keys(localVarFormParams).length) {
126
- if (localVarUseFormData) {
127
- localVarRequestOptions.formData = localVarFormParams;
128
- }
129
- else {
130
- localVarRequestOptions.form = localVarFormParams;
131
- }
155
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(createWhitelabelRequest, "CreateWhitelabelRequest"));
156
+ let requestOptions = localVarRequestOptions;
157
+ let url = localVarUrl;
158
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
159
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
160
+ url = auth_ApiKeyAuthentication.url;
161
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
162
+ requestOptions = auth_JWTAuthentication.requestOptions;
163
+ url = auth_JWTAuthentication.url;
164
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
165
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
166
+ url = auth_JWTHttpHeaderAuthentication.url;
167
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
168
+ requestOptions = auth_OAuth2.requestOptions;
169
+ url = auth_OAuth2.url;
170
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
171
+ requestOptions = authDefault.requestOptions;
172
+ url = authDefault.url;
173
+ if (localVarFormParams) {
174
+ delete requestOptions.headers['Content-Type'];
175
+ if (localVarFormParams instanceof FormData) {
176
+ // FormData: fetch will handle Content-Type automatically.
177
+ requestOptions.body = localVarFormParams;
178
+ }
179
+ else if (Object.keys(localVarFormParams).length > 0) {
180
+ // URL-encoded form
181
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
182
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
132
183
  }
133
- return new Promise((resolve, reject) => {
134
- localVarRequest(localVarRequestOptions, (error, response, body) => {
135
- if (error) {
136
- reject(error);
137
- }
138
- else {
139
- body = models_1.ObjectSerializer.deserialize(body, "CreateWhitelabelResponse");
140
- if (typeof body.success === 'boolean' && !body.success) {
141
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
142
- reject(new Error(body.error || errString));
143
- }
144
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
145
- resolve(body);
146
- }
147
- else {
148
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
149
- reject(errString);
150
- }
151
- }
152
- });
153
- });
154
- });
184
+ }
185
+ const response = await fetch(url, requestOptions);
186
+ return this.handleResponse(response, 'CreateWhitelabelResponse');
155
187
  }
156
188
  /**
157
189
  * Deletes the white label with the given id.
@@ -162,9 +194,11 @@ class WhitelabelsApi {
162
194
  const localVarPath = this.basePath + '/api/whitelabel/{whitelabelIdentifier}'
163
195
  .replace('{' + 'whitelabelIdentifier' + '}', encodeURIComponent(String(whitelabelIdentifier)));
164
196
  let localVarQueryParameters = {};
165
- let localVarHeaderParams = Object.assign({
166
- 'User-Agent': 'edgeimpulse-api nodejs'
167
- }, this.defaultHeaders);
197
+ let localVarHeaderParams = {
198
+ 'User-Agent': 'edgeimpulse-api nodejs',
199
+ 'Content-Type': 'application/json',
200
+ ...this.defaultHeaders,
201
+ };
168
202
  const produces = ['application/json'];
169
203
  // give precedence to 'application/json'
170
204
  if (produces.indexOf('application/json') >= 0) {
@@ -173,60 +207,56 @@ class WhitelabelsApi {
173
207
  else {
174
208
  localVarHeaderParams.Accept = produces.join(',');
175
209
  }
176
- let localVarFormParams = {};
210
+ let localVarFormParams;
177
211
  // verify required parameter 'whitelabelIdentifier' is not null or undefined
178
212
  if (whitelabelIdentifier === null || whitelabelIdentifier === undefined) {
179
213
  throw new Error('Required parameter whitelabelIdentifier was null or undefined when calling deleteWhitelabel.');
180
214
  }
181
- Object.assign(localVarHeaderParams, options.headers);
182
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
183
- let localVarUseFormData = false;
215
+ localVarHeaderParams = {
216
+ ...localVarHeaderParams,
217
+ ...options.headers,
218
+ ...this.opts.extraHeaders,
219
+ };
220
+ const queryString = Object.entries(localVarQueryParameters)
221
+ .filter(([, value]) => value !== undefined)
222
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
223
+ .join('&');
224
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
184
225
  let localVarRequestOptions = {
185
226
  method: 'DELETE',
186
- qs: localVarQueryParameters,
187
- headers: localVarHeaderParams,
188
- uri: localVarPath,
189
- useQuerystring: this._useQuerystring,
190
- agentOptions: { keepAlive: false },
191
- json: true,
227
+ headers: { ...localVarHeaderParams },
192
228
  };
193
- let authenticationPromise = Promise.resolve();
194
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
195
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
196
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
197
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
198
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
199
- return authenticationPromise.then(() => {
200
- if (Object.keys(localVarFormParams).length) {
201
- if (localVarUseFormData) {
202
- localVarRequestOptions.formData = localVarFormParams;
203
- }
204
- else {
205
- localVarRequestOptions.form = localVarFormParams;
206
- }
229
+ let requestOptions = localVarRequestOptions;
230
+ let url = localVarUrl;
231
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
232
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
233
+ url = auth_ApiKeyAuthentication.url;
234
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
235
+ requestOptions = auth_JWTAuthentication.requestOptions;
236
+ url = auth_JWTAuthentication.url;
237
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
238
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
239
+ url = auth_JWTHttpHeaderAuthentication.url;
240
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
241
+ requestOptions = auth_OAuth2.requestOptions;
242
+ url = auth_OAuth2.url;
243
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
244
+ requestOptions = authDefault.requestOptions;
245
+ url = authDefault.url;
246
+ if (localVarFormParams) {
247
+ delete requestOptions.headers['Content-Type'];
248
+ if (localVarFormParams instanceof FormData) {
249
+ // FormData: fetch will handle Content-Type automatically.
250
+ requestOptions.body = localVarFormParams;
207
251
  }
208
- return new Promise((resolve, reject) => {
209
- localVarRequest(localVarRequestOptions, (error, response, body) => {
210
- if (error) {
211
- reject(error);
212
- }
213
- else {
214
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
215
- if (typeof body.success === 'boolean' && !body.success) {
216
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
217
- reject(new Error(body.error || errString));
218
- }
219
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
220
- resolve(body);
221
- }
222
- else {
223
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
224
- reject(errString);
225
- }
226
- }
227
- });
228
- });
229
- });
252
+ else if (Object.keys(localVarFormParams).length > 0) {
253
+ // URL-encoded form
254
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
255
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
256
+ }
257
+ }
258
+ const response = await fetch(url, requestOptions);
259
+ return this.handleResponse(response, 'GenericApiResponse');
230
260
  }
231
261
  /**
232
262
  * Lists all possible DSP and ML blocks available for this white label.
@@ -237,9 +267,11 @@ class WhitelabelsApi {
237
267
  const localVarPath = this.basePath + '/api/whitelabel/{whitelabelIdentifier}/impulse/blocks'
238
268
  .replace('{' + 'whitelabelIdentifier' + '}', encodeURIComponent(String(whitelabelIdentifier)));
239
269
  let localVarQueryParameters = {};
240
- let localVarHeaderParams = Object.assign({
241
- 'User-Agent': 'edgeimpulse-api nodejs'
242
- }, this.defaultHeaders);
270
+ let localVarHeaderParams = {
271
+ 'User-Agent': 'edgeimpulse-api nodejs',
272
+ 'Content-Type': 'application/json',
273
+ ...this.defaultHeaders,
274
+ };
243
275
  const produces = ['application/json'];
244
276
  // give precedence to 'application/json'
245
277
  if (produces.indexOf('application/json') >= 0) {
@@ -248,60 +280,56 @@ class WhitelabelsApi {
248
280
  else {
249
281
  localVarHeaderParams.Accept = produces.join(',');
250
282
  }
251
- let localVarFormParams = {};
283
+ let localVarFormParams;
252
284
  // verify required parameter 'whitelabelIdentifier' is not null or undefined
253
285
  if (whitelabelIdentifier === null || whitelabelIdentifier === undefined) {
254
286
  throw new Error('Required parameter whitelabelIdentifier was null or undefined when calling getAllImpulseBlocks.');
255
287
  }
256
- Object.assign(localVarHeaderParams, options.headers);
257
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
258
- let localVarUseFormData = false;
288
+ localVarHeaderParams = {
289
+ ...localVarHeaderParams,
290
+ ...options.headers,
291
+ ...this.opts.extraHeaders,
292
+ };
293
+ const queryString = Object.entries(localVarQueryParameters)
294
+ .filter(([, value]) => value !== undefined)
295
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
296
+ .join('&');
297
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
259
298
  let localVarRequestOptions = {
260
299
  method: 'GET',
261
- qs: localVarQueryParameters,
262
- headers: localVarHeaderParams,
263
- uri: localVarPath,
264
- useQuerystring: this._useQuerystring,
265
- agentOptions: { keepAlive: false },
266
- json: true,
300
+ headers: { ...localVarHeaderParams },
267
301
  };
268
- let authenticationPromise = Promise.resolve();
269
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
270
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
271
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
272
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
273
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
274
- return authenticationPromise.then(() => {
275
- if (Object.keys(localVarFormParams).length) {
276
- if (localVarUseFormData) {
277
- localVarRequestOptions.formData = localVarFormParams;
278
- }
279
- else {
280
- localVarRequestOptions.form = localVarFormParams;
281
- }
302
+ let requestOptions = localVarRequestOptions;
303
+ let url = localVarUrl;
304
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
305
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
306
+ url = auth_ApiKeyAuthentication.url;
307
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
308
+ requestOptions = auth_JWTAuthentication.requestOptions;
309
+ url = auth_JWTAuthentication.url;
310
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
311
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
312
+ url = auth_JWTHttpHeaderAuthentication.url;
313
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
314
+ requestOptions = auth_OAuth2.requestOptions;
315
+ url = auth_OAuth2.url;
316
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
317
+ requestOptions = authDefault.requestOptions;
318
+ url = authDefault.url;
319
+ if (localVarFormParams) {
320
+ delete requestOptions.headers['Content-Type'];
321
+ if (localVarFormParams instanceof FormData) {
322
+ // FormData: fetch will handle Content-Type automatically.
323
+ requestOptions.body = localVarFormParams;
324
+ }
325
+ else if (Object.keys(localVarFormParams).length > 0) {
326
+ // URL-encoded form
327
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
328
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
282
329
  }
283
- return new Promise((resolve, reject) => {
284
- localVarRequest(localVarRequestOptions, (error, response, body) => {
285
- if (error) {
286
- reject(error);
287
- }
288
- else {
289
- body = models_1.ObjectSerializer.deserialize(body, "GetImpulseBlocksResponse");
290
- if (typeof body.success === 'boolean' && !body.success) {
291
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
292
- reject(new Error(body.error || errString));
293
- }
294
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
295
- resolve(body);
296
- }
297
- else {
298
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
299
- reject(errString);
300
- }
301
- }
302
- });
303
- });
304
- });
330
+ }
331
+ const response = await fetch(url, requestOptions);
332
+ return this.handleResponse(response, 'GetImpulseBlocksResponse');
305
333
  }
306
334
  /**
307
335
  * Retrieve the list of registered white labels.
@@ -310,9 +338,11 @@ class WhitelabelsApi {
310
338
  async getAllWhitelabels(options = { headers: {} }) {
311
339
  const localVarPath = this.basePath + '/api/whitelabels';
312
340
  let localVarQueryParameters = {};
313
- let localVarHeaderParams = Object.assign({
314
- 'User-Agent': 'edgeimpulse-api nodejs'
315
- }, this.defaultHeaders);
341
+ let localVarHeaderParams = {
342
+ 'User-Agent': 'edgeimpulse-api nodejs',
343
+ 'Content-Type': 'application/json',
344
+ ...this.defaultHeaders,
345
+ };
316
346
  const produces = ['application/json'];
317
347
  // give precedence to 'application/json'
318
348
  if (produces.indexOf('application/json') >= 0) {
@@ -321,56 +351,52 @@ class WhitelabelsApi {
321
351
  else {
322
352
  localVarHeaderParams.Accept = produces.join(',');
323
353
  }
324
- let localVarFormParams = {};
325
- Object.assign(localVarHeaderParams, options.headers);
326
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
327
- let localVarUseFormData = false;
354
+ let localVarFormParams;
355
+ localVarHeaderParams = {
356
+ ...localVarHeaderParams,
357
+ ...options.headers,
358
+ ...this.opts.extraHeaders,
359
+ };
360
+ const queryString = Object.entries(localVarQueryParameters)
361
+ .filter(([, value]) => value !== undefined)
362
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
363
+ .join('&');
364
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
328
365
  let localVarRequestOptions = {
329
366
  method: 'GET',
330
- qs: localVarQueryParameters,
331
- headers: localVarHeaderParams,
332
- uri: localVarPath,
333
- useQuerystring: this._useQuerystring,
334
- agentOptions: { keepAlive: false },
335
- json: true,
367
+ headers: { ...localVarHeaderParams },
336
368
  };
337
- let authenticationPromise = Promise.resolve();
338
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
339
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
340
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
341
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
342
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
343
- return authenticationPromise.then(() => {
344
- if (Object.keys(localVarFormParams).length) {
345
- if (localVarUseFormData) {
346
- localVarRequestOptions.formData = localVarFormParams;
347
- }
348
- else {
349
- localVarRequestOptions.form = localVarFormParams;
350
- }
369
+ let requestOptions = localVarRequestOptions;
370
+ let url = localVarUrl;
371
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
372
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
373
+ url = auth_ApiKeyAuthentication.url;
374
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
375
+ requestOptions = auth_JWTAuthentication.requestOptions;
376
+ url = auth_JWTAuthentication.url;
377
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
378
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
379
+ url = auth_JWTHttpHeaderAuthentication.url;
380
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
381
+ requestOptions = auth_OAuth2.requestOptions;
382
+ url = auth_OAuth2.url;
383
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
384
+ requestOptions = authDefault.requestOptions;
385
+ url = authDefault.url;
386
+ if (localVarFormParams) {
387
+ delete requestOptions.headers['Content-Type'];
388
+ if (localVarFormParams instanceof FormData) {
389
+ // FormData: fetch will handle Content-Type automatically.
390
+ requestOptions.body = localVarFormParams;
351
391
  }
352
- return new Promise((resolve, reject) => {
353
- localVarRequest(localVarRequestOptions, (error, response, body) => {
354
- if (error) {
355
- reject(error);
356
- }
357
- else {
358
- body = models_1.ObjectSerializer.deserialize(body, "GetAllWhitelabelsResponse");
359
- if (typeof body.success === 'boolean' && !body.success) {
360
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
361
- reject(new Error(body.error || errString));
362
- }
363
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
364
- resolve(body);
365
- }
366
- else {
367
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
368
- reject(errString);
369
- }
370
- }
371
- });
372
- });
373
- });
392
+ else if (Object.keys(localVarFormParams).length > 0) {
393
+ // URL-encoded form
394
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
395
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
396
+ }
397
+ }
398
+ const response = await fetch(url, requestOptions);
399
+ return this.handleResponse(response, 'GetAllWhitelabelsResponse');
374
400
  }
375
401
  /**
376
402
  * Retrieve all the information about this white label.
@@ -381,9 +407,11 @@ class WhitelabelsApi {
381
407
  const localVarPath = this.basePath + '/api/whitelabel/{whitelabelIdentifier}'
382
408
  .replace('{' + 'whitelabelIdentifier' + '}', encodeURIComponent(String(whitelabelIdentifier)));
383
409
  let localVarQueryParameters = {};
384
- let localVarHeaderParams = Object.assign({
385
- 'User-Agent': 'edgeimpulse-api nodejs'
386
- }, this.defaultHeaders);
410
+ let localVarHeaderParams = {
411
+ 'User-Agent': 'edgeimpulse-api nodejs',
412
+ 'Content-Type': 'application/json',
413
+ ...this.defaultHeaders,
414
+ };
387
415
  const produces = ['application/json'];
388
416
  // give precedence to 'application/json'
389
417
  if (produces.indexOf('application/json') >= 0) {
@@ -392,60 +420,56 @@ class WhitelabelsApi {
392
420
  else {
393
421
  localVarHeaderParams.Accept = produces.join(',');
394
422
  }
395
- let localVarFormParams = {};
423
+ let localVarFormParams;
396
424
  // verify required parameter 'whitelabelIdentifier' is not null or undefined
397
425
  if (whitelabelIdentifier === null || whitelabelIdentifier === undefined) {
398
426
  throw new Error('Required parameter whitelabelIdentifier was null or undefined when calling getWhitelabel.');
399
427
  }
400
- Object.assign(localVarHeaderParams, options.headers);
401
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
402
- let localVarUseFormData = false;
428
+ localVarHeaderParams = {
429
+ ...localVarHeaderParams,
430
+ ...options.headers,
431
+ ...this.opts.extraHeaders,
432
+ };
433
+ const queryString = Object.entries(localVarQueryParameters)
434
+ .filter(([, value]) => value !== undefined)
435
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
436
+ .join('&');
437
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
403
438
  let localVarRequestOptions = {
404
439
  method: 'GET',
405
- qs: localVarQueryParameters,
406
- headers: localVarHeaderParams,
407
- uri: localVarPath,
408
- useQuerystring: this._useQuerystring,
409
- agentOptions: { keepAlive: false },
410
- json: true,
440
+ headers: { ...localVarHeaderParams },
411
441
  };
412
- let authenticationPromise = Promise.resolve();
413
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
414
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
415
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
416
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
417
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
418
- return authenticationPromise.then(() => {
419
- if (Object.keys(localVarFormParams).length) {
420
- if (localVarUseFormData) {
421
- localVarRequestOptions.formData = localVarFormParams;
422
- }
423
- else {
424
- localVarRequestOptions.form = localVarFormParams;
425
- }
442
+ let requestOptions = localVarRequestOptions;
443
+ let url = localVarUrl;
444
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
445
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
446
+ url = auth_ApiKeyAuthentication.url;
447
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
448
+ requestOptions = auth_JWTAuthentication.requestOptions;
449
+ url = auth_JWTAuthentication.url;
450
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
451
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
452
+ url = auth_JWTHttpHeaderAuthentication.url;
453
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
454
+ requestOptions = auth_OAuth2.requestOptions;
455
+ url = auth_OAuth2.url;
456
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
457
+ requestOptions = authDefault.requestOptions;
458
+ url = authDefault.url;
459
+ if (localVarFormParams) {
460
+ delete requestOptions.headers['Content-Type'];
461
+ if (localVarFormParams instanceof FormData) {
462
+ // FormData: fetch will handle Content-Type automatically.
463
+ requestOptions.body = localVarFormParams;
464
+ }
465
+ else if (Object.keys(localVarFormParams).length > 0) {
466
+ // URL-encoded form
467
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
468
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
426
469
  }
427
- return new Promise((resolve, reject) => {
428
- localVarRequest(localVarRequestOptions, (error, response, body) => {
429
- if (error) {
430
- reject(error);
431
- }
432
- else {
433
- body = models_1.ObjectSerializer.deserialize(body, "GetWhitelabelResponse");
434
- if (typeof body.success === 'boolean' && !body.success) {
435
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
436
- reject(new Error(body.error || errString));
437
- }
438
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
439
- resolve(body);
440
- }
441
- else {
442
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
443
- reject(errString);
444
- }
445
- }
446
- });
447
- });
448
- });
470
+ }
471
+ const response = await fetch(url, requestOptions);
472
+ return this.handleResponse(response, 'GetWhitelabelResponse');
449
473
  }
450
474
  /**
451
475
  * Get a white label domain given its unique identifier.
@@ -456,9 +480,11 @@ class WhitelabelsApi {
456
480
  const localVarPath = this.basePath + '/api/whitelabel/{whitelabelIdentifier}/domain'
457
481
  .replace('{' + 'whitelabelIdentifier' + '}', encodeURIComponent(String(whitelabelIdentifier)));
458
482
  let localVarQueryParameters = {};
459
- let localVarHeaderParams = Object.assign({
460
- 'User-Agent': 'edgeimpulse-api nodejs'
461
- }, this.defaultHeaders);
483
+ let localVarHeaderParams = {
484
+ 'User-Agent': 'edgeimpulse-api nodejs',
485
+ 'Content-Type': 'application/json',
486
+ ...this.defaultHeaders,
487
+ };
462
488
  const produces = ['application/json'];
463
489
  // give precedence to 'application/json'
464
490
  if (produces.indexOf('application/json') >= 0) {
@@ -467,56 +493,44 @@ class WhitelabelsApi {
467
493
  else {
468
494
  localVarHeaderParams.Accept = produces.join(',');
469
495
  }
470
- let localVarFormParams = {};
496
+ let localVarFormParams;
471
497
  // verify required parameter 'whitelabelIdentifier' is not null or undefined
472
498
  if (whitelabelIdentifier === null || whitelabelIdentifier === undefined) {
473
499
  throw new Error('Required parameter whitelabelIdentifier was null or undefined when calling getWhitelabelDomain.');
474
500
  }
475
- Object.assign(localVarHeaderParams, options.headers);
476
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
477
- let localVarUseFormData = false;
501
+ localVarHeaderParams = {
502
+ ...localVarHeaderParams,
503
+ ...options.headers,
504
+ ...this.opts.extraHeaders,
505
+ };
506
+ const queryString = Object.entries(localVarQueryParameters)
507
+ .filter(([, value]) => value !== undefined)
508
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
509
+ .join('&');
510
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
478
511
  let localVarRequestOptions = {
479
512
  method: 'GET',
480
- qs: localVarQueryParameters,
481
- headers: localVarHeaderParams,
482
- uri: localVarPath,
483
- useQuerystring: this._useQuerystring,
484
- agentOptions: { keepAlive: false },
485
- json: true,
513
+ headers: { ...localVarHeaderParams },
486
514
  };
487
- let authenticationPromise = Promise.resolve();
488
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
489
- return authenticationPromise.then(() => {
490
- if (Object.keys(localVarFormParams).length) {
491
- if (localVarUseFormData) {
492
- localVarRequestOptions.formData = localVarFormParams;
493
- }
494
- else {
495
- localVarRequestOptions.form = localVarFormParams;
496
- }
515
+ let requestOptions = localVarRequestOptions;
516
+ let url = localVarUrl;
517
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
518
+ requestOptions = authDefault.requestOptions;
519
+ url = authDefault.url;
520
+ if (localVarFormParams) {
521
+ delete requestOptions.headers['Content-Type'];
522
+ if (localVarFormParams instanceof FormData) {
523
+ // FormData: fetch will handle Content-Type automatically.
524
+ requestOptions.body = localVarFormParams;
497
525
  }
498
- return new Promise((resolve, reject) => {
499
- localVarRequest(localVarRequestOptions, (error, response, body) => {
500
- if (error) {
501
- reject(error);
502
- }
503
- else {
504
- body = models_1.ObjectSerializer.deserialize(body, "GetWhitelabelDomainResponse");
505
- if (typeof body.success === 'boolean' && !body.success) {
506
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
507
- reject(new Error(body.error || errString));
508
- }
509
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
510
- resolve(body);
511
- }
512
- else {
513
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
514
- reject(errString);
515
- }
516
- }
517
- });
518
- });
519
- });
526
+ else if (Object.keys(localVarFormParams).length > 0) {
527
+ // URL-encoded form
528
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
529
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
530
+ }
531
+ }
532
+ const response = await fetch(url, requestOptions);
533
+ return this.handleResponse(response, 'GetWhitelabelDomainResponse');
520
534
  }
521
535
  /**
522
536
  * Update some or all of the deployment targets enabled for this white label.
@@ -528,9 +542,11 @@ class WhitelabelsApi {
528
542
  const localVarPath = this.basePath + '/api/whitelabel/{whitelabelIdentifier}/deploymentTargets'
529
543
  .replace('{' + 'whitelabelIdentifier' + '}', encodeURIComponent(String(whitelabelIdentifier)));
530
544
  let localVarQueryParameters = {};
531
- let localVarHeaderParams = Object.assign({
532
- 'User-Agent': 'edgeimpulse-api nodejs'
533
- }, this.defaultHeaders);
545
+ let localVarHeaderParams = {
546
+ 'User-Agent': 'edgeimpulse-api nodejs',
547
+ 'Content-Type': 'application/json',
548
+ ...this.defaultHeaders,
549
+ };
534
550
  const produces = ['application/json'];
535
551
  // give precedence to 'application/json'
536
552
  if (produces.indexOf('application/json') >= 0) {
@@ -539,7 +555,7 @@ class WhitelabelsApi {
539
555
  else {
540
556
  localVarHeaderParams.Accept = produces.join(',');
541
557
  }
542
- let localVarFormParams = {};
558
+ let localVarFormParams;
543
559
  // verify required parameter 'whitelabelIdentifier' is not null or undefined
544
560
  if (whitelabelIdentifier === null || whitelabelIdentifier === undefined) {
545
561
  throw new Error('Required parameter whitelabelIdentifier was null or undefined when calling updateDeploymentTargets.');
@@ -548,56 +564,52 @@ class WhitelabelsApi {
548
564
  if (updateWhitelabelDeploymentTargetsRequest === null || updateWhitelabelDeploymentTargetsRequest === undefined) {
549
565
  throw new Error('Required parameter updateWhitelabelDeploymentTargetsRequest was null or undefined when calling updateDeploymentTargets.');
550
566
  }
551
- Object.assign(localVarHeaderParams, options.headers);
552
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
553
- let localVarUseFormData = false;
567
+ localVarHeaderParams = {
568
+ ...localVarHeaderParams,
569
+ ...options.headers,
570
+ ...this.opts.extraHeaders,
571
+ };
572
+ const queryString = Object.entries(localVarQueryParameters)
573
+ .filter(([, value]) => value !== undefined)
574
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
575
+ .join('&');
576
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
554
577
  let localVarRequestOptions = {
555
578
  method: 'POST',
556
- qs: localVarQueryParameters,
557
- headers: localVarHeaderParams,
558
- uri: localVarPath,
559
- useQuerystring: this._useQuerystring,
560
- agentOptions: { keepAlive: false },
561
- json: true,
562
- body: models_1.ObjectSerializer.serialize(updateWhitelabelDeploymentTargetsRequest, "UpdateWhitelabelDeploymentTargetsRequest")
579
+ headers: { ...localVarHeaderParams },
563
580
  };
564
- let authenticationPromise = Promise.resolve();
565
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
566
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
567
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
568
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
569
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
570
- return authenticationPromise.then(() => {
571
- if (Object.keys(localVarFormParams).length) {
572
- if (localVarUseFormData) {
573
- localVarRequestOptions.formData = localVarFormParams;
574
- }
575
- else {
576
- localVarRequestOptions.form = localVarFormParams;
577
- }
581
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(updateWhitelabelDeploymentTargetsRequest, "UpdateWhitelabelDeploymentTargetsRequest"));
582
+ let requestOptions = localVarRequestOptions;
583
+ let url = localVarUrl;
584
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
585
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
586
+ url = auth_ApiKeyAuthentication.url;
587
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
588
+ requestOptions = auth_JWTAuthentication.requestOptions;
589
+ url = auth_JWTAuthentication.url;
590
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
591
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
592
+ url = auth_JWTHttpHeaderAuthentication.url;
593
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
594
+ requestOptions = auth_OAuth2.requestOptions;
595
+ url = auth_OAuth2.url;
596
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
597
+ requestOptions = authDefault.requestOptions;
598
+ url = authDefault.url;
599
+ if (localVarFormParams) {
600
+ delete requestOptions.headers['Content-Type'];
601
+ if (localVarFormParams instanceof FormData) {
602
+ // FormData: fetch will handle Content-Type automatically.
603
+ requestOptions.body = localVarFormParams;
604
+ }
605
+ else if (Object.keys(localVarFormParams).length > 0) {
606
+ // URL-encoded form
607
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
608
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
578
609
  }
579
- return new Promise((resolve, reject) => {
580
- localVarRequest(localVarRequestOptions, (error, response, body) => {
581
- if (error) {
582
- reject(error);
583
- }
584
- else {
585
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
586
- if (typeof body.success === 'boolean' && !body.success) {
587
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
588
- reject(new Error(body.error || errString));
589
- }
590
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
591
- resolve(body);
592
- }
593
- else {
594
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
595
- reject(errString);
596
- }
597
- }
598
- });
599
- });
600
- });
610
+ }
611
+ const response = await fetch(url, requestOptions);
612
+ return this.handleResponse(response, 'GenericApiResponse');
601
613
  }
602
614
  /**
603
615
  * Update the white label with the given id.
@@ -609,9 +621,11 @@ class WhitelabelsApi {
609
621
  const localVarPath = this.basePath + '/api/whitelabel/{whitelabelIdentifier}'
610
622
  .replace('{' + 'whitelabelIdentifier' + '}', encodeURIComponent(String(whitelabelIdentifier)));
611
623
  let localVarQueryParameters = {};
612
- let localVarHeaderParams = Object.assign({
613
- 'User-Agent': 'edgeimpulse-api nodejs'
614
- }, this.defaultHeaders);
624
+ let localVarHeaderParams = {
625
+ 'User-Agent': 'edgeimpulse-api nodejs',
626
+ 'Content-Type': 'application/json',
627
+ ...this.defaultHeaders,
628
+ };
615
629
  const produces = ['application/json'];
616
630
  // give precedence to 'application/json'
617
631
  if (produces.indexOf('application/json') >= 0) {
@@ -620,7 +634,7 @@ class WhitelabelsApi {
620
634
  else {
621
635
  localVarHeaderParams.Accept = produces.join(',');
622
636
  }
623
- let localVarFormParams = {};
637
+ let localVarFormParams;
624
638
  // verify required parameter 'whitelabelIdentifier' is not null or undefined
625
639
  if (whitelabelIdentifier === null || whitelabelIdentifier === undefined) {
626
640
  throw new Error('Required parameter whitelabelIdentifier was null or undefined when calling updateWhitelabel.');
@@ -629,56 +643,52 @@ class WhitelabelsApi {
629
643
  if (updateWhitelabelInternalRequest === null || updateWhitelabelInternalRequest === undefined) {
630
644
  throw new Error('Required parameter updateWhitelabelInternalRequest was null or undefined when calling updateWhitelabel.');
631
645
  }
632
- Object.assign(localVarHeaderParams, options.headers);
633
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
634
- let localVarUseFormData = false;
646
+ localVarHeaderParams = {
647
+ ...localVarHeaderParams,
648
+ ...options.headers,
649
+ ...this.opts.extraHeaders,
650
+ };
651
+ const queryString = Object.entries(localVarQueryParameters)
652
+ .filter(([, value]) => value !== undefined)
653
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
654
+ .join('&');
655
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
635
656
  let localVarRequestOptions = {
636
657
  method: 'PUT',
637
- qs: localVarQueryParameters,
638
- headers: localVarHeaderParams,
639
- uri: localVarPath,
640
- useQuerystring: this._useQuerystring,
641
- agentOptions: { keepAlive: false },
642
- json: true,
643
- body: models_1.ObjectSerializer.serialize(updateWhitelabelInternalRequest, "UpdateWhitelabelInternalRequest")
658
+ headers: { ...localVarHeaderParams },
644
659
  };
645
- let authenticationPromise = Promise.resolve();
646
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
647
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
648
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
649
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
650
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
651
- return authenticationPromise.then(() => {
652
- if (Object.keys(localVarFormParams).length) {
653
- if (localVarUseFormData) {
654
- localVarRequestOptions.formData = localVarFormParams;
655
- }
656
- else {
657
- localVarRequestOptions.form = localVarFormParams;
658
- }
660
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(updateWhitelabelInternalRequest, "UpdateWhitelabelInternalRequest"));
661
+ let requestOptions = localVarRequestOptions;
662
+ let url = localVarUrl;
663
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
664
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
665
+ url = auth_ApiKeyAuthentication.url;
666
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
667
+ requestOptions = auth_JWTAuthentication.requestOptions;
668
+ url = auth_JWTAuthentication.url;
669
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
670
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
671
+ url = auth_JWTHttpHeaderAuthentication.url;
672
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
673
+ requestOptions = auth_OAuth2.requestOptions;
674
+ url = auth_OAuth2.url;
675
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
676
+ requestOptions = authDefault.requestOptions;
677
+ url = authDefault.url;
678
+ if (localVarFormParams) {
679
+ delete requestOptions.headers['Content-Type'];
680
+ if (localVarFormParams instanceof FormData) {
681
+ // FormData: fetch will handle Content-Type automatically.
682
+ requestOptions.body = localVarFormParams;
659
683
  }
660
- return new Promise((resolve, reject) => {
661
- localVarRequest(localVarRequestOptions, (error, response, body) => {
662
- if (error) {
663
- reject(error);
664
- }
665
- else {
666
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
667
- if (typeof body.success === 'boolean' && !body.success) {
668
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
669
- reject(new Error(body.error || errString));
670
- }
671
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
672
- resolve(body);
673
- }
674
- else {
675
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
676
- reject(errString);
677
- }
678
- }
679
- });
680
- });
681
- });
684
+ else if (Object.keys(localVarFormParams).length > 0) {
685
+ // URL-encoded form
686
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
687
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
688
+ }
689
+ }
690
+ const response = await fetch(url, requestOptions);
691
+ return this.handleResponse(response, 'GenericApiResponse');
682
692
  }
683
693
  }
684
694
  exports.WhitelabelsApi = WhitelabelsApi;