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.OrganizationDataCampaignsApi = exports.OrganizationDataCampaignsApiApiKeys = 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 OrganizationDataCampaignsApiApiKeys;
30
47
  OrganizationDataCampaignsApiApiKeys[OrganizationDataCampaignsApiApiKeys["JWTHttpHeaderAuthentication"] = 2] = "JWTHttpHeaderAuthentication";
31
48
  })(OrganizationDataCampaignsApiApiKeys = exports.OrganizationDataCampaignsApiApiKeys || (exports.OrganizationDataCampaignsApiApiKeys = {}));
32
49
  class OrganizationDataCampaignsApi {
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 OrganizationDataCampaignsApi {
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
  }
@@ -88,9 +122,11 @@ class OrganizationDataCampaignsApi {
88
122
  const localVarPath = this.basePath + '/api/organizations/{organizationId}/campaigns'
89
123
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)));
90
124
  let localVarQueryParameters = {};
91
- let localVarHeaderParams = Object.assign({
92
- 'User-Agent': 'edgeimpulse-api nodejs'
93
- }, this.defaultHeaders);
125
+ let localVarHeaderParams = {
126
+ 'User-Agent': 'edgeimpulse-api nodejs',
127
+ 'Content-Type': 'application/json',
128
+ ...this.defaultHeaders,
129
+ };
94
130
  const produces = ['application/json'];
95
131
  // give precedence to 'application/json'
96
132
  if (produces.indexOf('application/json') >= 0) {
@@ -99,7 +135,7 @@ class OrganizationDataCampaignsApi {
99
135
  else {
100
136
  localVarHeaderParams.Accept = produces.join(',');
101
137
  }
102
- let localVarFormParams = {};
138
+ let localVarFormParams;
103
139
  // verify required parameter 'organizationId' is not null or undefined
104
140
  if (organizationId === null || organizationId === undefined) {
105
141
  throw new Error('Required parameter organizationId was null or undefined when calling addOrganizationDataCampaign.');
@@ -108,56 +144,52 @@ class OrganizationDataCampaignsApi {
108
144
  if (addOrganizationDataCampaignRequest === null || addOrganizationDataCampaignRequest === undefined) {
109
145
  throw new Error('Required parameter addOrganizationDataCampaignRequest was null or undefined when calling addOrganizationDataCampaign.');
110
146
  }
111
- Object.assign(localVarHeaderParams, options.headers);
112
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
113
- let localVarUseFormData = false;
147
+ localVarHeaderParams = {
148
+ ...localVarHeaderParams,
149
+ ...options.headers,
150
+ ...this.opts.extraHeaders,
151
+ };
152
+ const queryString = Object.entries(localVarQueryParameters)
153
+ .filter(([, value]) => value !== undefined)
154
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
155
+ .join('&');
156
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
114
157
  let localVarRequestOptions = {
115
158
  method: 'POST',
116
- qs: localVarQueryParameters,
117
- headers: localVarHeaderParams,
118
- uri: localVarPath,
119
- useQuerystring: this._useQuerystring,
120
- agentOptions: { keepAlive: false },
121
- json: true,
122
- body: models_1.ObjectSerializer.serialize(addOrganizationDataCampaignRequest, "AddOrganizationDataCampaignRequest")
159
+ headers: { ...localVarHeaderParams },
123
160
  };
124
- let authenticationPromise = Promise.resolve();
125
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
126
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
127
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
128
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
129
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
130
- return authenticationPromise.then(() => {
131
- if (Object.keys(localVarFormParams).length) {
132
- if (localVarUseFormData) {
133
- localVarRequestOptions.formData = localVarFormParams;
134
- }
135
- else {
136
- localVarRequestOptions.form = localVarFormParams;
137
- }
161
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(addOrganizationDataCampaignRequest, "AddOrganizationDataCampaignRequest"));
162
+ let requestOptions = localVarRequestOptions;
163
+ let url = localVarUrl;
164
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
165
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
166
+ url = auth_ApiKeyAuthentication.url;
167
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
168
+ requestOptions = auth_JWTAuthentication.requestOptions;
169
+ url = auth_JWTAuthentication.url;
170
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
171
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
172
+ url = auth_JWTHttpHeaderAuthentication.url;
173
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
174
+ requestOptions = auth_OAuth2.requestOptions;
175
+ url = auth_OAuth2.url;
176
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
177
+ requestOptions = authDefault.requestOptions;
178
+ url = authDefault.url;
179
+ if (localVarFormParams) {
180
+ delete requestOptions.headers['Content-Type'];
181
+ if (localVarFormParams instanceof FormData) {
182
+ // FormData: fetch will handle Content-Type automatically.
183
+ requestOptions.body = localVarFormParams;
138
184
  }
139
- return new Promise((resolve, reject) => {
140
- localVarRequest(localVarRequestOptions, (error, response, body) => {
141
- if (error) {
142
- reject(error);
143
- }
144
- else {
145
- body = models_1.ObjectSerializer.deserialize(body, "AddOrganizationDataCampaignResponse");
146
- if (typeof body.success === 'boolean' && !body.success) {
147
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
148
- reject(new Error(body.error || errString));
149
- }
150
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
151
- resolve(body);
152
- }
153
- else {
154
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
155
- reject(errString);
156
- }
157
- }
158
- });
159
- });
160
- });
185
+ else if (Object.keys(localVarFormParams).length > 0) {
186
+ // URL-encoded form
187
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
188
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
189
+ }
190
+ }
191
+ const response = await fetch(url, requestOptions);
192
+ return this.handleResponse(response, 'AddOrganizationDataCampaignResponse');
161
193
  }
162
194
  /**
163
195
  * Add a new data campaign dashboard
@@ -169,9 +201,11 @@ class OrganizationDataCampaignsApi {
169
201
  const localVarPath = this.basePath + '/api/organizations/{organizationId}/campaign-dashboards'
170
202
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)));
171
203
  let localVarQueryParameters = {};
172
- let localVarHeaderParams = Object.assign({
173
- 'User-Agent': 'edgeimpulse-api nodejs'
174
- }, this.defaultHeaders);
204
+ let localVarHeaderParams = {
205
+ 'User-Agent': 'edgeimpulse-api nodejs',
206
+ 'Content-Type': 'application/json',
207
+ ...this.defaultHeaders,
208
+ };
175
209
  const produces = ['application/json'];
176
210
  // give precedence to 'application/json'
177
211
  if (produces.indexOf('application/json') >= 0) {
@@ -180,7 +214,7 @@ class OrganizationDataCampaignsApi {
180
214
  else {
181
215
  localVarHeaderParams.Accept = produces.join(',');
182
216
  }
183
- let localVarFormParams = {};
217
+ let localVarFormParams;
184
218
  // verify required parameter 'organizationId' is not null or undefined
185
219
  if (organizationId === null || organizationId === undefined) {
186
220
  throw new Error('Required parameter organizationId was null or undefined when calling addOrganizationDataCampaignDashboard.');
@@ -189,56 +223,52 @@ class OrganizationDataCampaignsApi {
189
223
  if (addOrganizationDataCampaignDashboardRequest === null || addOrganizationDataCampaignDashboardRequest === undefined) {
190
224
  throw new Error('Required parameter addOrganizationDataCampaignDashboardRequest was null or undefined when calling addOrganizationDataCampaignDashboard.');
191
225
  }
192
- Object.assign(localVarHeaderParams, options.headers);
193
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
194
- let localVarUseFormData = false;
226
+ localVarHeaderParams = {
227
+ ...localVarHeaderParams,
228
+ ...options.headers,
229
+ ...this.opts.extraHeaders,
230
+ };
231
+ const queryString = Object.entries(localVarQueryParameters)
232
+ .filter(([, value]) => value !== undefined)
233
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
234
+ .join('&');
235
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
195
236
  let localVarRequestOptions = {
196
237
  method: 'POST',
197
- qs: localVarQueryParameters,
198
- headers: localVarHeaderParams,
199
- uri: localVarPath,
200
- useQuerystring: this._useQuerystring,
201
- agentOptions: { keepAlive: false },
202
- json: true,
203
- body: models_1.ObjectSerializer.serialize(addOrganizationDataCampaignDashboardRequest, "AddOrganizationDataCampaignDashboardRequest")
238
+ headers: { ...localVarHeaderParams },
204
239
  };
205
- let authenticationPromise = Promise.resolve();
206
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
207
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
208
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
209
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
210
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
211
- return authenticationPromise.then(() => {
212
- if (Object.keys(localVarFormParams).length) {
213
- if (localVarUseFormData) {
214
- localVarRequestOptions.formData = localVarFormParams;
215
- }
216
- else {
217
- localVarRequestOptions.form = localVarFormParams;
218
- }
240
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(addOrganizationDataCampaignDashboardRequest, "AddOrganizationDataCampaignDashboardRequest"));
241
+ let requestOptions = localVarRequestOptions;
242
+ let url = localVarUrl;
243
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
244
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
245
+ url = auth_ApiKeyAuthentication.url;
246
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
247
+ requestOptions = auth_JWTAuthentication.requestOptions;
248
+ url = auth_JWTAuthentication.url;
249
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
250
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
251
+ url = auth_JWTHttpHeaderAuthentication.url;
252
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
253
+ requestOptions = auth_OAuth2.requestOptions;
254
+ url = auth_OAuth2.url;
255
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
256
+ requestOptions = authDefault.requestOptions;
257
+ url = authDefault.url;
258
+ if (localVarFormParams) {
259
+ delete requestOptions.headers['Content-Type'];
260
+ if (localVarFormParams instanceof FormData) {
261
+ // FormData: fetch will handle Content-Type automatically.
262
+ requestOptions.body = localVarFormParams;
219
263
  }
220
- return new Promise((resolve, reject) => {
221
- localVarRequest(localVarRequestOptions, (error, response, body) => {
222
- if (error) {
223
- reject(error);
224
- }
225
- else {
226
- body = models_1.ObjectSerializer.deserialize(body, "AddOrganizationDataCampaignDashboardResponse");
227
- if (typeof body.success === 'boolean' && !body.success) {
228
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
229
- reject(new Error(body.error || errString));
230
- }
231
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
232
- resolve(body);
233
- }
234
- else {
235
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
236
- reject(errString);
237
- }
238
- }
239
- });
240
- });
241
- });
264
+ else if (Object.keys(localVarFormParams).length > 0) {
265
+ // URL-encoded form
266
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
267
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
268
+ }
269
+ }
270
+ const response = await fetch(url, requestOptions);
271
+ return this.handleResponse(response, 'AddOrganizationDataCampaignDashboardResponse');
242
272
  }
243
273
  /**
244
274
  * Delete a data campaign
@@ -251,9 +281,11 @@ class OrganizationDataCampaignsApi {
251
281
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
252
282
  .replace('{' + 'campaignId' + '}', encodeURIComponent(String(campaignId)));
253
283
  let localVarQueryParameters = {};
254
- let localVarHeaderParams = Object.assign({
255
- 'User-Agent': 'edgeimpulse-api nodejs'
256
- }, this.defaultHeaders);
284
+ let localVarHeaderParams = {
285
+ 'User-Agent': 'edgeimpulse-api nodejs',
286
+ 'Content-Type': 'application/json',
287
+ ...this.defaultHeaders,
288
+ };
257
289
  const produces = ['application/json'];
258
290
  // give precedence to 'application/json'
259
291
  if (produces.indexOf('application/json') >= 0) {
@@ -262,7 +294,7 @@ class OrganizationDataCampaignsApi {
262
294
  else {
263
295
  localVarHeaderParams.Accept = produces.join(',');
264
296
  }
265
- let localVarFormParams = {};
297
+ let localVarFormParams;
266
298
  // verify required parameter 'organizationId' is not null or undefined
267
299
  if (organizationId === null || organizationId === undefined) {
268
300
  throw new Error('Required parameter organizationId was null or undefined when calling deleteOrganizationDataCampaign.');
@@ -271,55 +303,51 @@ class OrganizationDataCampaignsApi {
271
303
  if (campaignId === null || campaignId === undefined) {
272
304
  throw new Error('Required parameter campaignId was null or undefined when calling deleteOrganizationDataCampaign.');
273
305
  }
274
- Object.assign(localVarHeaderParams, options.headers);
275
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
276
- let localVarUseFormData = false;
306
+ localVarHeaderParams = {
307
+ ...localVarHeaderParams,
308
+ ...options.headers,
309
+ ...this.opts.extraHeaders,
310
+ };
311
+ const queryString = Object.entries(localVarQueryParameters)
312
+ .filter(([, value]) => value !== undefined)
313
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
314
+ .join('&');
315
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
277
316
  let localVarRequestOptions = {
278
317
  method: 'DELETE',
279
- qs: localVarQueryParameters,
280
- headers: localVarHeaderParams,
281
- uri: localVarPath,
282
- useQuerystring: this._useQuerystring,
283
- agentOptions: { keepAlive: false },
284
- json: true,
318
+ headers: { ...localVarHeaderParams },
285
319
  };
286
- let authenticationPromise = Promise.resolve();
287
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
288
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
289
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
290
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
291
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
292
- return authenticationPromise.then(() => {
293
- if (Object.keys(localVarFormParams).length) {
294
- if (localVarUseFormData) {
295
- localVarRequestOptions.formData = localVarFormParams;
296
- }
297
- else {
298
- localVarRequestOptions.form = localVarFormParams;
299
- }
320
+ let requestOptions = localVarRequestOptions;
321
+ let url = localVarUrl;
322
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
323
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
324
+ url = auth_ApiKeyAuthentication.url;
325
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
326
+ requestOptions = auth_JWTAuthentication.requestOptions;
327
+ url = auth_JWTAuthentication.url;
328
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
329
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
330
+ url = auth_JWTHttpHeaderAuthentication.url;
331
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
332
+ requestOptions = auth_OAuth2.requestOptions;
333
+ url = auth_OAuth2.url;
334
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
335
+ requestOptions = authDefault.requestOptions;
336
+ url = authDefault.url;
337
+ if (localVarFormParams) {
338
+ delete requestOptions.headers['Content-Type'];
339
+ if (localVarFormParams instanceof FormData) {
340
+ // FormData: fetch will handle Content-Type automatically.
341
+ requestOptions.body = localVarFormParams;
300
342
  }
301
- return new Promise((resolve, reject) => {
302
- localVarRequest(localVarRequestOptions, (error, response, body) => {
303
- if (error) {
304
- reject(error);
305
- }
306
- else {
307
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
308
- if (typeof body.success === 'boolean' && !body.success) {
309
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
310
- reject(new Error(body.error || errString));
311
- }
312
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
313
- resolve(body);
314
- }
315
- else {
316
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
317
- reject(errString);
318
- }
319
- }
320
- });
321
- });
322
- });
343
+ else if (Object.keys(localVarFormParams).length > 0) {
344
+ // URL-encoded form
345
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
346
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
347
+ }
348
+ }
349
+ const response = await fetch(url, requestOptions);
350
+ return this.handleResponse(response, 'GenericApiResponse');
323
351
  }
324
352
  /**
325
353
  * Delete a data campaign dashboard
@@ -332,9 +360,11 @@ class OrganizationDataCampaignsApi {
332
360
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
333
361
  .replace('{' + 'campaignDashboardId' + '}', encodeURIComponent(String(campaignDashboardId)));
334
362
  let localVarQueryParameters = {};
335
- let localVarHeaderParams = Object.assign({
336
- 'User-Agent': 'edgeimpulse-api nodejs'
337
- }, this.defaultHeaders);
363
+ let localVarHeaderParams = {
364
+ 'User-Agent': 'edgeimpulse-api nodejs',
365
+ 'Content-Type': 'application/json',
366
+ ...this.defaultHeaders,
367
+ };
338
368
  const produces = ['application/json'];
339
369
  // give precedence to 'application/json'
340
370
  if (produces.indexOf('application/json') >= 0) {
@@ -343,7 +373,7 @@ class OrganizationDataCampaignsApi {
343
373
  else {
344
374
  localVarHeaderParams.Accept = produces.join(',');
345
375
  }
346
- let localVarFormParams = {};
376
+ let localVarFormParams;
347
377
  // verify required parameter 'organizationId' is not null or undefined
348
378
  if (organizationId === null || organizationId === undefined) {
349
379
  throw new Error('Required parameter organizationId was null or undefined when calling deleteOrganizationDataCampaignDashboard.');
@@ -352,55 +382,51 @@ class OrganizationDataCampaignsApi {
352
382
  if (campaignDashboardId === null || campaignDashboardId === undefined) {
353
383
  throw new Error('Required parameter campaignDashboardId was null or undefined when calling deleteOrganizationDataCampaignDashboard.');
354
384
  }
355
- Object.assign(localVarHeaderParams, options.headers);
356
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
357
- let localVarUseFormData = false;
385
+ localVarHeaderParams = {
386
+ ...localVarHeaderParams,
387
+ ...options.headers,
388
+ ...this.opts.extraHeaders,
389
+ };
390
+ const queryString = Object.entries(localVarQueryParameters)
391
+ .filter(([, value]) => value !== undefined)
392
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
393
+ .join('&');
394
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
358
395
  let localVarRequestOptions = {
359
396
  method: 'DELETE',
360
- qs: localVarQueryParameters,
361
- headers: localVarHeaderParams,
362
- uri: localVarPath,
363
- useQuerystring: this._useQuerystring,
364
- agentOptions: { keepAlive: false },
365
- json: true,
397
+ headers: { ...localVarHeaderParams },
366
398
  };
367
- let authenticationPromise = Promise.resolve();
368
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
369
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
370
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
371
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
372
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
373
- return authenticationPromise.then(() => {
374
- if (Object.keys(localVarFormParams).length) {
375
- if (localVarUseFormData) {
376
- localVarRequestOptions.formData = localVarFormParams;
377
- }
378
- else {
379
- localVarRequestOptions.form = localVarFormParams;
380
- }
399
+ let requestOptions = localVarRequestOptions;
400
+ let url = localVarUrl;
401
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
402
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
403
+ url = auth_ApiKeyAuthentication.url;
404
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
405
+ requestOptions = auth_JWTAuthentication.requestOptions;
406
+ url = auth_JWTAuthentication.url;
407
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
408
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
409
+ url = auth_JWTHttpHeaderAuthentication.url;
410
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
411
+ requestOptions = auth_OAuth2.requestOptions;
412
+ url = auth_OAuth2.url;
413
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
414
+ requestOptions = authDefault.requestOptions;
415
+ url = authDefault.url;
416
+ if (localVarFormParams) {
417
+ delete requestOptions.headers['Content-Type'];
418
+ if (localVarFormParams instanceof FormData) {
419
+ // FormData: fetch will handle Content-Type automatically.
420
+ requestOptions.body = localVarFormParams;
381
421
  }
382
- return new Promise((resolve, reject) => {
383
- localVarRequest(localVarRequestOptions, (error, response, body) => {
384
- if (error) {
385
- reject(error);
386
- }
387
- else {
388
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
389
- if (typeof body.success === 'boolean' && !body.success) {
390
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
391
- reject(new Error(body.error || errString));
392
- }
393
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
394
- resolve(body);
395
- }
396
- else {
397
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
398
- reject(errString);
399
- }
400
- }
401
- });
402
- });
403
- });
422
+ else if (Object.keys(localVarFormParams).length > 0) {
423
+ // URL-encoded form
424
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
425
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
426
+ }
427
+ }
428
+ const response = await fetch(url, requestOptions);
429
+ return this.handleResponse(response, 'GenericApiResponse');
404
430
  }
405
431
  /**
406
432
  * Get a data campaign
@@ -413,9 +439,11 @@ class OrganizationDataCampaignsApi {
413
439
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
414
440
  .replace('{' + 'campaignId' + '}', encodeURIComponent(String(campaignId)));
415
441
  let localVarQueryParameters = {};
416
- let localVarHeaderParams = Object.assign({
417
- 'User-Agent': 'edgeimpulse-api nodejs'
418
- }, this.defaultHeaders);
442
+ let localVarHeaderParams = {
443
+ 'User-Agent': 'edgeimpulse-api nodejs',
444
+ 'Content-Type': 'application/json',
445
+ ...this.defaultHeaders,
446
+ };
419
447
  const produces = ['application/json'];
420
448
  // give precedence to 'application/json'
421
449
  if (produces.indexOf('application/json') >= 0) {
@@ -424,7 +452,7 @@ class OrganizationDataCampaignsApi {
424
452
  else {
425
453
  localVarHeaderParams.Accept = produces.join(',');
426
454
  }
427
- let localVarFormParams = {};
455
+ let localVarFormParams;
428
456
  // verify required parameter 'organizationId' is not null or undefined
429
457
  if (organizationId === null || organizationId === undefined) {
430
458
  throw new Error('Required parameter organizationId was null or undefined when calling getOrganizationDataCampaign.');
@@ -433,55 +461,51 @@ class OrganizationDataCampaignsApi {
433
461
  if (campaignId === null || campaignId === undefined) {
434
462
  throw new Error('Required parameter campaignId was null or undefined when calling getOrganizationDataCampaign.');
435
463
  }
436
- Object.assign(localVarHeaderParams, options.headers);
437
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
438
- let localVarUseFormData = false;
464
+ localVarHeaderParams = {
465
+ ...localVarHeaderParams,
466
+ ...options.headers,
467
+ ...this.opts.extraHeaders,
468
+ };
469
+ const queryString = Object.entries(localVarQueryParameters)
470
+ .filter(([, value]) => value !== undefined)
471
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
472
+ .join('&');
473
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
439
474
  let localVarRequestOptions = {
440
475
  method: 'GET',
441
- qs: localVarQueryParameters,
442
- headers: localVarHeaderParams,
443
- uri: localVarPath,
444
- useQuerystring: this._useQuerystring,
445
- agentOptions: { keepAlive: false },
446
- json: true,
476
+ headers: { ...localVarHeaderParams },
447
477
  };
448
- let authenticationPromise = Promise.resolve();
449
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
450
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
451
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
452
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
453
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
454
- return authenticationPromise.then(() => {
455
- if (Object.keys(localVarFormParams).length) {
456
- if (localVarUseFormData) {
457
- localVarRequestOptions.formData = localVarFormParams;
458
- }
459
- else {
460
- localVarRequestOptions.form = localVarFormParams;
461
- }
478
+ let requestOptions = localVarRequestOptions;
479
+ let url = localVarUrl;
480
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
481
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
482
+ url = auth_ApiKeyAuthentication.url;
483
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
484
+ requestOptions = auth_JWTAuthentication.requestOptions;
485
+ url = auth_JWTAuthentication.url;
486
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
487
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
488
+ url = auth_JWTHttpHeaderAuthentication.url;
489
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
490
+ requestOptions = auth_OAuth2.requestOptions;
491
+ url = auth_OAuth2.url;
492
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
493
+ requestOptions = authDefault.requestOptions;
494
+ url = authDefault.url;
495
+ if (localVarFormParams) {
496
+ delete requestOptions.headers['Content-Type'];
497
+ if (localVarFormParams instanceof FormData) {
498
+ // FormData: fetch will handle Content-Type automatically.
499
+ requestOptions.body = localVarFormParams;
462
500
  }
463
- return new Promise((resolve, reject) => {
464
- localVarRequest(localVarRequestOptions, (error, response, body) => {
465
- if (error) {
466
- reject(error);
467
- }
468
- else {
469
- body = models_1.ObjectSerializer.deserialize(body, "GetOrganizationDataCampaignResponse");
470
- if (typeof body.success === 'boolean' && !body.success) {
471
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
472
- reject(new Error(body.error || errString));
473
- }
474
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
475
- resolve(body);
476
- }
477
- else {
478
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
479
- reject(errString);
480
- }
481
- }
482
- });
483
- });
484
- });
501
+ else if (Object.keys(localVarFormParams).length > 0) {
502
+ // URL-encoded form
503
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
504
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
505
+ }
506
+ }
507
+ const response = await fetch(url, requestOptions);
508
+ return this.handleResponse(response, 'GetOrganizationDataCampaignResponse');
485
509
  }
486
510
  /**
487
511
  * Get a data campaign dashboard
@@ -494,9 +518,11 @@ class OrganizationDataCampaignsApi {
494
518
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
495
519
  .replace('{' + 'campaignDashboardId' + '}', encodeURIComponent(String(campaignDashboardId)));
496
520
  let localVarQueryParameters = {};
497
- let localVarHeaderParams = Object.assign({
498
- 'User-Agent': 'edgeimpulse-api nodejs'
499
- }, this.defaultHeaders);
521
+ let localVarHeaderParams = {
522
+ 'User-Agent': 'edgeimpulse-api nodejs',
523
+ 'Content-Type': 'application/json',
524
+ ...this.defaultHeaders,
525
+ };
500
526
  const produces = ['application/json'];
501
527
  // give precedence to 'application/json'
502
528
  if (produces.indexOf('application/json') >= 0) {
@@ -505,7 +531,7 @@ class OrganizationDataCampaignsApi {
505
531
  else {
506
532
  localVarHeaderParams.Accept = produces.join(',');
507
533
  }
508
- let localVarFormParams = {};
534
+ let localVarFormParams;
509
535
  // verify required parameter 'organizationId' is not null or undefined
510
536
  if (organizationId === null || organizationId === undefined) {
511
537
  throw new Error('Required parameter organizationId was null or undefined when calling getOrganizationDataCampaignDashboard.');
@@ -514,55 +540,51 @@ class OrganizationDataCampaignsApi {
514
540
  if (campaignDashboardId === null || campaignDashboardId === undefined) {
515
541
  throw new Error('Required parameter campaignDashboardId was null or undefined when calling getOrganizationDataCampaignDashboard.');
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, "GetOrganizationDataCampaignDashboardResponse");
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, 'GetOrganizationDataCampaignDashboardResponse');
566
588
  }
567
589
  /**
568
590
  * List all data campaign dashboards
@@ -573,9 +595,11 @@ class OrganizationDataCampaignsApi {
573
595
  const localVarPath = this.basePath + '/api/organizations/{organizationId}/campaign-dashboards'
574
596
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)));
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 OrganizationDataCampaignsApi {
584
608
  else {
585
609
  localVarHeaderParams.Accept = produces.join(',');
586
610
  }
587
- let localVarFormParams = {};
611
+ let localVarFormParams;
588
612
  // verify required parameter 'organizationId' is not null or undefined
589
613
  if (organizationId === null || organizationId === undefined) {
590
614
  throw new Error('Required parameter organizationId was null or undefined when calling getOrganizationDataCampaignDashboards.');
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;
618
652
  }
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, "GetOrganizationDataCampaignDashboardsResponse");
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
- });
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';
657
+ }
658
+ }
659
+ const response = await fetch(url, requestOptions);
660
+ return this.handleResponse(response, 'GetOrganizationDataCampaignDashboardsResponse');
641
661
  }
642
662
  /**
643
663
  * Get which items have changed for a data campaign. You post the data points and we\'ll return which data items are different in the past day.
@@ -651,9 +671,11 @@ class OrganizationDataCampaignsApi {
651
671
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
652
672
  .replace('{' + 'campaignId' + '}', encodeURIComponent(String(campaignId)));
653
673
  let localVarQueryParameters = {};
654
- let localVarHeaderParams = Object.assign({
655
- 'User-Agent': 'edgeimpulse-api nodejs'
656
- }, this.defaultHeaders);
674
+ let localVarHeaderParams = {
675
+ 'User-Agent': 'edgeimpulse-api nodejs',
676
+ 'Content-Type': 'application/json',
677
+ ...this.defaultHeaders,
678
+ };
657
679
  const produces = ['application/json'];
658
680
  // give precedence to 'application/json'
659
681
  if (produces.indexOf('application/json') >= 0) {
@@ -662,7 +684,7 @@ class OrganizationDataCampaignsApi {
662
684
  else {
663
685
  localVarHeaderParams.Accept = produces.join(',');
664
686
  }
665
- let localVarFormParams = {};
687
+ let localVarFormParams;
666
688
  // verify required parameter 'organizationId' is not null or undefined
667
689
  if (organizationId === null || organizationId === undefined) {
668
690
  throw new Error('Required parameter organizationId was null or undefined when calling getOrganizationDataCampaignDiff.');
@@ -675,56 +697,52 @@ class OrganizationDataCampaignsApi {
675
697
  if (organizationDataCampaignDiffRequest === null || organizationDataCampaignDiffRequest === undefined) {
676
698
  throw new Error('Required parameter organizationDataCampaignDiffRequest was null or undefined when calling getOrganizationDataCampaignDiff.');
677
699
  }
678
- Object.assign(localVarHeaderParams, options.headers);
679
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
680
- let localVarUseFormData = false;
700
+ localVarHeaderParams = {
701
+ ...localVarHeaderParams,
702
+ ...options.headers,
703
+ ...this.opts.extraHeaders,
704
+ };
705
+ const queryString = Object.entries(localVarQueryParameters)
706
+ .filter(([, value]) => value !== undefined)
707
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
708
+ .join('&');
709
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
681
710
  let localVarRequestOptions = {
682
711
  method: 'POST',
683
- qs: localVarQueryParameters,
684
- headers: localVarHeaderParams,
685
- uri: localVarPath,
686
- useQuerystring: this._useQuerystring,
687
- agentOptions: { keepAlive: false },
688
- json: true,
689
- body: models_1.ObjectSerializer.serialize(organizationDataCampaignDiffRequest, "OrganizationDataCampaignDiffRequest")
712
+ headers: { ...localVarHeaderParams },
690
713
  };
691
- let authenticationPromise = Promise.resolve();
692
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
693
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
694
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
695
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
696
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
697
- return authenticationPromise.then(() => {
698
- if (Object.keys(localVarFormParams).length) {
699
- if (localVarUseFormData) {
700
- localVarRequestOptions.formData = localVarFormParams;
701
- }
702
- else {
703
- localVarRequestOptions.form = localVarFormParams;
704
- }
714
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(organizationDataCampaignDiffRequest, "OrganizationDataCampaignDiffRequest"));
715
+ let requestOptions = localVarRequestOptions;
716
+ let url = localVarUrl;
717
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
718
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
719
+ url = auth_ApiKeyAuthentication.url;
720
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
721
+ requestOptions = auth_JWTAuthentication.requestOptions;
722
+ url = auth_JWTAuthentication.url;
723
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
724
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
725
+ url = auth_JWTHttpHeaderAuthentication.url;
726
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
727
+ requestOptions = auth_OAuth2.requestOptions;
728
+ url = auth_OAuth2.url;
729
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
730
+ requestOptions = authDefault.requestOptions;
731
+ url = authDefault.url;
732
+ if (localVarFormParams) {
733
+ delete requestOptions.headers['Content-Type'];
734
+ if (localVarFormParams instanceof FormData) {
735
+ // FormData: fetch will handle Content-Type automatically.
736
+ requestOptions.body = localVarFormParams;
705
737
  }
706
- return new Promise((resolve, reject) => {
707
- localVarRequest(localVarRequestOptions, (error, response, body) => {
708
- if (error) {
709
- reject(error);
710
- }
711
- else {
712
- body = models_1.ObjectSerializer.deserialize(body, "OrganizationDataCampaignDiffResponse");
713
- if (typeof body.success === 'boolean' && !body.success) {
714
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
715
- reject(new Error(body.error || errString));
716
- }
717
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
718
- resolve(body);
719
- }
720
- else {
721
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
722
- reject(errString);
723
- }
724
- }
725
- });
726
- });
727
- });
738
+ else if (Object.keys(localVarFormParams).length > 0) {
739
+ // URL-encoded form
740
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
741
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
742
+ }
743
+ }
744
+ const response = await fetch(url, requestOptions);
745
+ return this.handleResponse(response, 'OrganizationDataCampaignDiffResponse');
728
746
  }
729
747
  /**
730
748
  * Get a list of all data campaigns for a dashboard
@@ -737,9 +755,11 @@ class OrganizationDataCampaignsApi {
737
755
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
738
756
  .replace('{' + 'campaignDashboardId' + '}', encodeURIComponent(String(campaignDashboardId)));
739
757
  let localVarQueryParameters = {};
740
- let localVarHeaderParams = Object.assign({
741
- 'User-Agent': 'edgeimpulse-api nodejs'
742
- }, this.defaultHeaders);
758
+ let localVarHeaderParams = {
759
+ 'User-Agent': 'edgeimpulse-api nodejs',
760
+ 'Content-Type': 'application/json',
761
+ ...this.defaultHeaders,
762
+ };
743
763
  const produces = ['application/json'];
744
764
  // give precedence to 'application/json'
745
765
  if (produces.indexOf('application/json') >= 0) {
@@ -748,7 +768,7 @@ class OrganizationDataCampaignsApi {
748
768
  else {
749
769
  localVarHeaderParams.Accept = produces.join(',');
750
770
  }
751
- let localVarFormParams = {};
771
+ let localVarFormParams;
752
772
  // verify required parameter 'organizationId' is not null or undefined
753
773
  if (organizationId === null || organizationId === undefined) {
754
774
  throw new Error('Required parameter organizationId was null or undefined when calling getOrganizationDataCampaignsForDashboard.');
@@ -757,55 +777,51 @@ class OrganizationDataCampaignsApi {
757
777
  if (campaignDashboardId === null || campaignDashboardId === undefined) {
758
778
  throw new Error('Required parameter campaignDashboardId was null or undefined when calling getOrganizationDataCampaignsForDashboard.');
759
779
  }
760
- Object.assign(localVarHeaderParams, options.headers);
761
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
762
- let localVarUseFormData = false;
780
+ localVarHeaderParams = {
781
+ ...localVarHeaderParams,
782
+ ...options.headers,
783
+ ...this.opts.extraHeaders,
784
+ };
785
+ const queryString = Object.entries(localVarQueryParameters)
786
+ .filter(([, value]) => value !== undefined)
787
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
788
+ .join('&');
789
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
763
790
  let localVarRequestOptions = {
764
791
  method: 'GET',
765
- qs: localVarQueryParameters,
766
- headers: localVarHeaderParams,
767
- uri: localVarPath,
768
- useQuerystring: this._useQuerystring,
769
- agentOptions: { keepAlive: false },
770
- json: true,
792
+ headers: { ...localVarHeaderParams },
771
793
  };
772
- let authenticationPromise = Promise.resolve();
773
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
774
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
775
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
776
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
777
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
778
- return authenticationPromise.then(() => {
779
- if (Object.keys(localVarFormParams).length) {
780
- if (localVarUseFormData) {
781
- localVarRequestOptions.formData = localVarFormParams;
782
- }
783
- else {
784
- localVarRequestOptions.form = localVarFormParams;
785
- }
794
+ let requestOptions = localVarRequestOptions;
795
+ let url = localVarUrl;
796
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
797
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
798
+ url = auth_ApiKeyAuthentication.url;
799
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
800
+ requestOptions = auth_JWTAuthentication.requestOptions;
801
+ url = auth_JWTAuthentication.url;
802
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
803
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
804
+ url = auth_JWTHttpHeaderAuthentication.url;
805
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
806
+ requestOptions = auth_OAuth2.requestOptions;
807
+ url = auth_OAuth2.url;
808
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
809
+ requestOptions = authDefault.requestOptions;
810
+ url = authDefault.url;
811
+ if (localVarFormParams) {
812
+ delete requestOptions.headers['Content-Type'];
813
+ if (localVarFormParams instanceof FormData) {
814
+ // FormData: fetch will handle Content-Type automatically.
815
+ requestOptions.body = localVarFormParams;
786
816
  }
787
- return new Promise((resolve, reject) => {
788
- localVarRequest(localVarRequestOptions, (error, response, body) => {
789
- if (error) {
790
- reject(error);
791
- }
792
- else {
793
- body = models_1.ObjectSerializer.deserialize(body, "GetOrganizationDataCampaignsResponse");
794
- if (typeof body.success === 'boolean' && !body.success) {
795
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
796
- reject(new Error(body.error || errString));
797
- }
798
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
799
- resolve(body);
800
- }
801
- else {
802
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
803
- reject(errString);
804
- }
805
- }
806
- });
807
- });
808
- });
817
+ else if (Object.keys(localVarFormParams).length > 0) {
818
+ // URL-encoded form
819
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
820
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
821
+ }
822
+ }
823
+ const response = await fetch(url, requestOptions);
824
+ return this.handleResponse(response, 'GetOrganizationDataCampaignsResponse');
809
825
  }
810
826
  /**
811
827
  * Update a data campaign
@@ -819,9 +835,11 @@ class OrganizationDataCampaignsApi {
819
835
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
820
836
  .replace('{' + 'campaignId' + '}', encodeURIComponent(String(campaignId)));
821
837
  let localVarQueryParameters = {};
822
- let localVarHeaderParams = Object.assign({
823
- 'User-Agent': 'edgeimpulse-api nodejs'
824
- }, this.defaultHeaders);
838
+ let localVarHeaderParams = {
839
+ 'User-Agent': 'edgeimpulse-api nodejs',
840
+ 'Content-Type': 'application/json',
841
+ ...this.defaultHeaders,
842
+ };
825
843
  const produces = ['application/json'];
826
844
  // give precedence to 'application/json'
827
845
  if (produces.indexOf('application/json') >= 0) {
@@ -830,7 +848,7 @@ class OrganizationDataCampaignsApi {
830
848
  else {
831
849
  localVarHeaderParams.Accept = produces.join(',');
832
850
  }
833
- let localVarFormParams = {};
851
+ let localVarFormParams;
834
852
  // verify required parameter 'organizationId' is not null or undefined
835
853
  if (organizationId === null || organizationId === undefined) {
836
854
  throw new Error('Required parameter organizationId was null or undefined when calling updateOrganizationDataCampaign.');
@@ -843,56 +861,52 @@ class OrganizationDataCampaignsApi {
843
861
  if (updateOrganizationDataCampaignRequest === null || updateOrganizationDataCampaignRequest === undefined) {
844
862
  throw new Error('Required parameter updateOrganizationDataCampaignRequest was null or undefined when calling updateOrganizationDataCampaign.');
845
863
  }
846
- Object.assign(localVarHeaderParams, options.headers);
847
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
848
- let localVarUseFormData = false;
864
+ localVarHeaderParams = {
865
+ ...localVarHeaderParams,
866
+ ...options.headers,
867
+ ...this.opts.extraHeaders,
868
+ };
869
+ const queryString = Object.entries(localVarQueryParameters)
870
+ .filter(([, value]) => value !== undefined)
871
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
872
+ .join('&');
873
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
849
874
  let localVarRequestOptions = {
850
875
  method: 'POST',
851
- qs: localVarQueryParameters,
852
- headers: localVarHeaderParams,
853
- uri: localVarPath,
854
- useQuerystring: this._useQuerystring,
855
- agentOptions: { keepAlive: false },
856
- json: true,
857
- body: models_1.ObjectSerializer.serialize(updateOrganizationDataCampaignRequest, "UpdateOrganizationDataCampaignRequest")
876
+ headers: { ...localVarHeaderParams },
858
877
  };
859
- let authenticationPromise = Promise.resolve();
860
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
861
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
862
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
863
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
864
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
865
- return authenticationPromise.then(() => {
866
- if (Object.keys(localVarFormParams).length) {
867
- if (localVarUseFormData) {
868
- localVarRequestOptions.formData = localVarFormParams;
869
- }
870
- else {
871
- localVarRequestOptions.form = localVarFormParams;
872
- }
878
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(updateOrganizationDataCampaignRequest, "UpdateOrganizationDataCampaignRequest"));
879
+ let requestOptions = localVarRequestOptions;
880
+ let url = localVarUrl;
881
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
882
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
883
+ url = auth_ApiKeyAuthentication.url;
884
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
885
+ requestOptions = auth_JWTAuthentication.requestOptions;
886
+ url = auth_JWTAuthentication.url;
887
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
888
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
889
+ url = auth_JWTHttpHeaderAuthentication.url;
890
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
891
+ requestOptions = auth_OAuth2.requestOptions;
892
+ url = auth_OAuth2.url;
893
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
894
+ requestOptions = authDefault.requestOptions;
895
+ url = authDefault.url;
896
+ if (localVarFormParams) {
897
+ delete requestOptions.headers['Content-Type'];
898
+ if (localVarFormParams instanceof FormData) {
899
+ // FormData: fetch will handle Content-Type automatically.
900
+ requestOptions.body = localVarFormParams;
873
901
  }
874
- return new Promise((resolve, reject) => {
875
- localVarRequest(localVarRequestOptions, (error, response, body) => {
876
- if (error) {
877
- reject(error);
878
- }
879
- else {
880
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
881
- if (typeof body.success === 'boolean' && !body.success) {
882
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
883
- reject(new Error(body.error || errString));
884
- }
885
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
886
- resolve(body);
887
- }
888
- else {
889
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
890
- reject(errString);
891
- }
892
- }
893
- });
894
- });
895
- });
902
+ else if (Object.keys(localVarFormParams).length > 0) {
903
+ // URL-encoded form
904
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
905
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
906
+ }
907
+ }
908
+ const response = await fetch(url, requestOptions);
909
+ return this.handleResponse(response, 'GenericApiResponse');
896
910
  }
897
911
  /**
898
912
  * Update a data campaign dashboard
@@ -906,9 +920,11 @@ class OrganizationDataCampaignsApi {
906
920
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
907
921
  .replace('{' + 'campaignDashboardId' + '}', encodeURIComponent(String(campaignDashboardId)));
908
922
  let localVarQueryParameters = {};
909
- let localVarHeaderParams = Object.assign({
910
- 'User-Agent': 'edgeimpulse-api nodejs'
911
- }, this.defaultHeaders);
923
+ let localVarHeaderParams = {
924
+ 'User-Agent': 'edgeimpulse-api nodejs',
925
+ 'Content-Type': 'application/json',
926
+ ...this.defaultHeaders,
927
+ };
912
928
  const produces = ['application/json'];
913
929
  // give precedence to 'application/json'
914
930
  if (produces.indexOf('application/json') >= 0) {
@@ -917,7 +933,7 @@ class OrganizationDataCampaignsApi {
917
933
  else {
918
934
  localVarHeaderParams.Accept = produces.join(',');
919
935
  }
920
- let localVarFormParams = {};
936
+ let localVarFormParams;
921
937
  // verify required parameter 'organizationId' is not null or undefined
922
938
  if (organizationId === null || organizationId === undefined) {
923
939
  throw new Error('Required parameter organizationId was null or undefined when calling updateOrganizationDataCampaignDashboard.');
@@ -930,56 +946,52 @@ class OrganizationDataCampaignsApi {
930
946
  if (updateOrganizationDataCampaignDashboardRequest === null || updateOrganizationDataCampaignDashboardRequest === undefined) {
931
947
  throw new Error('Required parameter updateOrganizationDataCampaignDashboardRequest was null or undefined when calling updateOrganizationDataCampaignDashboard.');
932
948
  }
933
- Object.assign(localVarHeaderParams, options.headers);
934
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
935
- let localVarUseFormData = false;
949
+ localVarHeaderParams = {
950
+ ...localVarHeaderParams,
951
+ ...options.headers,
952
+ ...this.opts.extraHeaders,
953
+ };
954
+ const queryString = Object.entries(localVarQueryParameters)
955
+ .filter(([, value]) => value !== undefined)
956
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
957
+ .join('&');
958
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
936
959
  let localVarRequestOptions = {
937
960
  method: 'POST',
938
- qs: localVarQueryParameters,
939
- headers: localVarHeaderParams,
940
- uri: localVarPath,
941
- useQuerystring: this._useQuerystring,
942
- agentOptions: { keepAlive: false },
943
- json: true,
944
- body: models_1.ObjectSerializer.serialize(updateOrganizationDataCampaignDashboardRequest, "UpdateOrganizationDataCampaignDashboardRequest")
961
+ headers: { ...localVarHeaderParams },
945
962
  };
946
- let authenticationPromise = Promise.resolve();
947
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
948
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
949
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
950
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
951
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
952
- return authenticationPromise.then(() => {
953
- if (Object.keys(localVarFormParams).length) {
954
- if (localVarUseFormData) {
955
- localVarRequestOptions.formData = localVarFormParams;
956
- }
957
- else {
958
- localVarRequestOptions.form = localVarFormParams;
959
- }
963
+ localVarRequestOptions.body = JSON.stringify(models_1.ObjectSerializer.serialize(updateOrganizationDataCampaignDashboardRequest, "UpdateOrganizationDataCampaignDashboardRequest"));
964
+ let requestOptions = localVarRequestOptions;
965
+ let url = localVarUrl;
966
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
967
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
968
+ url = auth_ApiKeyAuthentication.url;
969
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
970
+ requestOptions = auth_JWTAuthentication.requestOptions;
971
+ url = auth_JWTAuthentication.url;
972
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
973
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
974
+ url = auth_JWTHttpHeaderAuthentication.url;
975
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
976
+ requestOptions = auth_OAuth2.requestOptions;
977
+ url = auth_OAuth2.url;
978
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
979
+ requestOptions = authDefault.requestOptions;
980
+ url = authDefault.url;
981
+ if (localVarFormParams) {
982
+ delete requestOptions.headers['Content-Type'];
983
+ if (localVarFormParams instanceof FormData) {
984
+ // FormData: fetch will handle Content-Type automatically.
985
+ requestOptions.body = localVarFormParams;
960
986
  }
961
- return new Promise((resolve, reject) => {
962
- localVarRequest(localVarRequestOptions, (error, response, body) => {
963
- if (error) {
964
- reject(error);
965
- }
966
- else {
967
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
968
- if (typeof body.success === 'boolean' && !body.success) {
969
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
970
- reject(new Error(body.error || errString));
971
- }
972
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
973
- resolve(body);
974
- }
975
- else {
976
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
977
- reject(errString);
978
- }
979
- }
980
- });
981
- });
982
- });
987
+ else if (Object.keys(localVarFormParams).length > 0) {
988
+ // URL-encoded form
989
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
990
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
991
+ }
992
+ }
993
+ const response = await fetch(url, requestOptions);
994
+ return this.handleResponse(response, 'GenericApiResponse');
983
995
  }
984
996
  /**
985
997
  * Used internally to upload a picture of a screenshot
@@ -993,9 +1005,11 @@ class OrganizationDataCampaignsApi {
993
1005
  .replace('{' + 'organizationId' + '}', encodeURIComponent(String(organizationId)))
994
1006
  .replace('{' + 'campaignDashboardId' + '}', encodeURIComponent(String(campaignDashboardId)));
995
1007
  let localVarQueryParameters = {};
996
- let localVarHeaderParams = Object.assign({
997
- 'User-Agent': 'edgeimpulse-api nodejs'
998
- }, this.defaultHeaders);
1008
+ let localVarHeaderParams = {
1009
+ 'User-Agent': 'edgeimpulse-api nodejs',
1010
+ 'Content-Type': 'application/json',
1011
+ ...this.defaultHeaders,
1012
+ };
999
1013
  const produces = ['application/json'];
1000
1014
  // give precedence to 'application/json'
1001
1015
  if (produces.indexOf('application/json') >= 0) {
@@ -1004,7 +1018,7 @@ class OrganizationDataCampaignsApi {
1004
1018
  else {
1005
1019
  localVarHeaderParams.Accept = produces.join(',');
1006
1020
  }
1007
- let localVarFormParams = {};
1021
+ let localVarFormParams;
1008
1022
  // verify required parameter 'organizationId' is not null or undefined
1009
1023
  if (organizationId === null || organizationId === undefined) {
1010
1024
  throw new Error('Required parameter organizationId was null or undefined when calling uploadDashboardScreenshot.');
@@ -1017,59 +1031,69 @@ class OrganizationDataCampaignsApi {
1017
1031
  if (params.image === null || params.image === undefined) {
1018
1032
  throw new Error('Required parameter params.image was null or undefined when calling uploadDashboardScreenshot.');
1019
1033
  }
1020
- Object.assign(localVarHeaderParams, options.headers);
1021
- Object.assign(localVarHeaderParams, this.opts.extraHeaders);
1022
- let localVarUseFormData = false;
1034
+ localVarHeaderParams = {
1035
+ ...localVarHeaderParams,
1036
+ ...options.headers,
1037
+ ...this.opts.extraHeaders,
1038
+ };
1023
1039
  if (params.image !== undefined) {
1024
- localVarFormParams['image'] = params.image;
1040
+ if (!(localVarFormParams instanceof FormData)) {
1041
+ const existingParams = localVarFormParams;
1042
+ localVarFormParams = new FormData();
1043
+ if (existingParams && typeof existingParams === 'object') {
1044
+ Object.keys(existingParams).forEach(key => {
1045
+ localVarFormParams.append(key, existingParams[key]);
1046
+ });
1047
+ }
1048
+ }
1049
+ const imageFiles = Array.isArray(params.image) ? params.image : [params.image];
1050
+ const Blob = globalThis.Blob || require('buffer').Blob;
1051
+ imageFiles.forEach((f) => {
1052
+ localVarFormParams.append('image', new Blob([f.value], {
1053
+ type: f.options.contentType
1054
+ }), f.options.filename);
1055
+ });
1025
1056
  }
1026
- localVarUseFormData = true;
1057
+ const queryString = Object.entries(localVarQueryParameters)
1058
+ .filter(([, value]) => value !== undefined)
1059
+ .map(([key, value]) => `${key}=${encodeURIComponent(String(value))}`)
1060
+ .join('&');
1061
+ let localVarUrl = localVarPath + (queryString ? `?${queryString}` : '');
1027
1062
  let localVarRequestOptions = {
1028
1063
  method: 'POST',
1029
- qs: localVarQueryParameters,
1030
- headers: localVarHeaderParams,
1031
- uri: localVarPath,
1032
- useQuerystring: this._useQuerystring,
1033
- agentOptions: { keepAlive: false },
1034
- json: true,
1064
+ headers: { ...localVarHeaderParams },
1035
1065
  };
1036
- let authenticationPromise = Promise.resolve();
1037
- authenticationPromise = authenticationPromise.then(() => this.authentications.ApiKeyAuthentication.applyToRequest(localVarRequestOptions));
1038
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTAuthentication.applyToRequest(localVarRequestOptions));
1039
- authenticationPromise = authenticationPromise.then(() => this.authentications.JWTHttpHeaderAuthentication.applyToRequest(localVarRequestOptions));
1040
- authenticationPromise = authenticationPromise.then(() => this.authentications.OAuth2.applyToRequest(localVarRequestOptions));
1041
- authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions));
1042
- return authenticationPromise.then(() => {
1043
- if (Object.keys(localVarFormParams).length) {
1044
- if (localVarUseFormData) {
1045
- localVarRequestOptions.formData = localVarFormParams;
1046
- }
1047
- else {
1048
- localVarRequestOptions.form = localVarFormParams;
1049
- }
1066
+ let requestOptions = localVarRequestOptions;
1067
+ let url = localVarUrl;
1068
+ const auth_ApiKeyAuthentication = await this.authentications.ApiKeyAuthentication.applyToRequest(requestOptions, url);
1069
+ requestOptions = auth_ApiKeyAuthentication.requestOptions;
1070
+ url = auth_ApiKeyAuthentication.url;
1071
+ const auth_JWTAuthentication = await this.authentications.JWTAuthentication.applyToRequest(requestOptions, url);
1072
+ requestOptions = auth_JWTAuthentication.requestOptions;
1073
+ url = auth_JWTAuthentication.url;
1074
+ const auth_JWTHttpHeaderAuthentication = await this.authentications.JWTHttpHeaderAuthentication.applyToRequest(requestOptions, url);
1075
+ requestOptions = auth_JWTHttpHeaderAuthentication.requestOptions;
1076
+ url = auth_JWTHttpHeaderAuthentication.url;
1077
+ const auth_OAuth2 = await this.authentications.OAuth2.applyToRequest(requestOptions, url);
1078
+ requestOptions = auth_OAuth2.requestOptions;
1079
+ url = auth_OAuth2.url;
1080
+ const authDefault = await this.authentications.default.applyToRequest(requestOptions, url);
1081
+ requestOptions = authDefault.requestOptions;
1082
+ url = authDefault.url;
1083
+ if (localVarFormParams) {
1084
+ delete requestOptions.headers['Content-Type'];
1085
+ if (localVarFormParams instanceof FormData) {
1086
+ // FormData: fetch will handle Content-Type automatically.
1087
+ requestOptions.body = localVarFormParams;
1050
1088
  }
1051
- return new Promise((resolve, reject) => {
1052
- localVarRequest(localVarRequestOptions, (error, response, body) => {
1053
- if (error) {
1054
- reject(error);
1055
- }
1056
- else {
1057
- body = models_1.ObjectSerializer.deserialize(body, "GenericApiResponse");
1058
- if (typeof body.success === 'boolean' && !body.success) {
1059
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1060
- reject(new Error(body.error || errString));
1061
- }
1062
- else if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) {
1063
- resolve(body);
1064
- }
1065
- else {
1066
- const errString = `Failed to call "${localVarPath}", returned ${response.statusCode}: ` + response.body;
1067
- reject(errString);
1068
- }
1069
- }
1070
- });
1071
- });
1072
- });
1089
+ else if (Object.keys(localVarFormParams).length > 0) {
1090
+ // URL-encoded form
1091
+ requestOptions.body = new URLSearchParams(localVarFormParams).toString();
1092
+ requestOptions.headers['Content-Type'] = 'application/x-www-form-urlencoded';
1093
+ }
1094
+ }
1095
+ const response = await fetch(url, requestOptions);
1096
+ return this.handleResponse(response, 'GenericApiResponse');
1073
1097
  }
1074
1098
  }
1075
1099
  exports.OrganizationDataCampaignsApi = OrganizationDataCampaignsApi;