@@ -74,10 +74,6 @@ export function createAbtestingApi(
74
74
addABTestsRequest : AddABTestsRequest ,
75
75
requestOptions ?: RequestOptions
76
76
) : Promise < ABTestResponse > {
77
- const requestPath = '/2/abtests' ;
78
- const headers : Headers = { } ;
79
- const queryParameters : QueryParameters = { } ;
80
-
81
77
if ( ! addABTestsRequest ) {
82
78
throw new Error (
83
79
'Parameter `addABTestsRequest` is required when calling `addABTests`.'
@@ -100,6 +96,10 @@ export function createAbtestingApi(
100
96
) ;
101
97
}
102
98
99
+ const requestPath = '/2/abtests' ;
100
+ const headers : Headers = { } ;
101
+ const queryParameters : QueryParameters = { } ;
102
+
103
103
const request : Request = {
104
104
method : 'POST' ,
105
105
path : requestPath ,
@@ -122,24 +122,20 @@ export function createAbtestingApi(
122
122
* @summary Send requests to the Algolia REST API.
123
123
* @param del - The del object.
124
124
* @param del.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
125
- * @param del.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key .
125
+ * @param del.parameters - Query parameters to be applied to the current query .
126
126
* @param del.body - The parameters to send with the custom request.
127
127
*/
128
128
del (
129
129
{ path, parameters, body } : DelProps ,
130
130
requestOptions ?: RequestOptions
131
131
) : Promise < Record < string , any > > {
132
- const requestPath = '/1{path}' . replace ( '{path}' , String ( path ) ) ;
133
- const headers : Headers = { } ;
134
- const queryParameters : QueryParameters = { } ;
135
-
136
132
if ( ! path ) {
137
133
throw new Error ( 'Parameter `path` is required when calling `del`.' ) ;
138
134
}
139
135
140
- if ( parameters !== undefined ) {
141
- queryParameters . parameters = parameters . toString ( ) ;
142
- }
136
+ const requestPath = '/1{path}' . replace ( '{path}' , path ) ;
137
+ const headers : Headers = { } ;
138
+ const queryParameters : QueryParameters = parameters || { } ;
143
139
144
140
const request : Request = {
145
141
method : 'DELETE' ,
@@ -168,19 +164,19 @@ export function createAbtestingApi(
168
164
{ id } : DeleteABTestProps ,
169
165
requestOptions ?: RequestOptions
170
166
) : Promise < ABTestResponse > {
171
- const requestPath = '/2/abtests/{id}' . replace (
172
- '{id}' ,
173
- encodeURIComponent ( String ( id ) )
174
- ) ;
175
- const headers : Headers = { } ;
176
- const queryParameters : QueryParameters = { } ;
177
-
178
167
if ( ! id ) {
179
168
throw new Error (
180
169
'Parameter `id` is required when calling `deleteABTest`.'
181
170
) ;
182
171
}
183
172
173
+ const requestPath = '/2/abtests/{id}' . replace (
174
+ '{id}' ,
175
+ encodeURIComponent ( id )
176
+ ) ;
177
+ const headers : Headers = { } ;
178
+ const queryParameters : QueryParameters = { } ;
179
+
184
180
const request : Request = {
185
181
method : 'DELETE' ,
186
182
path : requestPath ,
@@ -202,23 +198,19 @@ export function createAbtestingApi(
202
198
* @summary Send requests to the Algolia REST API.
203
199
* @param get - The get object.
204
200
* @param get.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
205
- * @param get.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key .
201
+ * @param get.parameters - Query parameters to be applied to the current query .
206
202
*/
207
203
get (
208
204
{ path, parameters } : GetProps ,
209
205
requestOptions ?: RequestOptions
210
206
) : Promise < Record < string , any > > {
211
- const requestPath = '/1{path}' . replace ( '{path}' , String ( path ) ) ;
212
- const headers : Headers = { } ;
213
- const queryParameters : QueryParameters = { } ;
214
-
215
207
if ( ! path ) {
216
208
throw new Error ( 'Parameter `path` is required when calling `get`.' ) ;
217
209
}
218
210
219
- if ( parameters !== undefined ) {
220
- queryParameters . parameters = parameters . toString ( ) ;
221
- }
211
+ const requestPath = '/1{path}' . replace ( '{path}' , path ) ;
212
+ const headers : Headers = { } ;
213
+ const queryParameters : QueryParameters = parameters || { } ;
222
214
223
215
const request : Request = {
224
216
method : 'GET' ,
@@ -246,17 +238,17 @@ export function createAbtestingApi(
246
238
{ id } : GetABTestProps ,
247
239
requestOptions ?: RequestOptions
248
240
) : Promise < ABTest > {
241
+ if ( ! id ) {
242
+ throw new Error ( 'Parameter `id` is required when calling `getABTest`.' ) ;
243
+ }
244
+
249
245
const requestPath = '/2/abtests/{id}' . replace (
250
246
'{id}' ,
251
- encodeURIComponent ( String ( id ) )
247
+ encodeURIComponent ( id )
252
248
) ;
253
249
const headers : Headers = { } ;
254
250
const queryParameters : QueryParameters = { } ;
255
251
256
- if ( ! id ) {
257
- throw new Error ( 'Parameter `id` is required when calling `getABTest`.' ) ;
258
- }
259
-
260
252
const request : Request = {
261
253
method : 'GET' ,
262
254
path : requestPath ,
@@ -317,24 +309,20 @@ export function createAbtestingApi(
317
309
* @summary Send requests to the Algolia REST API.
318
310
* @param post - The post object.
319
311
* @param post.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
320
- * @param post.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key .
312
+ * @param post.parameters - Query parameters to be applied to the current query .
321
313
* @param post.body - The parameters to send with the custom request.
322
314
*/
323
315
post (
324
316
{ path, parameters, body } : PostProps ,
325
317
requestOptions ?: RequestOptions
326
318
) : Promise < Record < string , any > > {
327
- const requestPath = '/1{path}' . replace ( '{path}' , String ( path ) ) ;
328
- const headers : Headers = { } ;
329
- const queryParameters : QueryParameters = { } ;
330
-
331
319
if ( ! path ) {
332
320
throw new Error ( 'Parameter `path` is required when calling `post`.' ) ;
333
321
}
334
322
335
- if ( parameters !== undefined ) {
336
- queryParameters . parameters = parameters . toString ( ) ;
337
- }
323
+ const requestPath = '/1{path}' . replace ( '{path}' , path ) ;
324
+ const headers : Headers = { } ;
325
+ const queryParameters : QueryParameters = parameters || { } ;
338
326
339
327
const request : Request = {
340
328
method : 'POST' ,
@@ -358,24 +346,20 @@ export function createAbtestingApi(
358
346
* @summary Send requests to the Algolia REST API.
359
347
* @param put - The put object.
360
348
* @param put.path - The path of the API endpoint to target, anything after the /1 needs to be specified.
361
- * @param put.parameters - URL-encoded query string. Force some query parameters to be applied for each query made with this API key .
349
+ * @param put.parameters - Query parameters to be applied to the current query .
362
350
* @param put.body - The parameters to send with the custom request.
363
351
*/
364
352
put (
365
353
{ path, parameters, body } : PutProps ,
366
354
requestOptions ?: RequestOptions
367
355
) : Promise < Record < string , any > > {
368
- const requestPath = '/1{path}' . replace ( '{path}' , String ( path ) ) ;
369
- const headers : Headers = { } ;
370
- const queryParameters : QueryParameters = { } ;
371
-
372
356
if ( ! path ) {
373
357
throw new Error ( 'Parameter `path` is required when calling `put`.' ) ;
374
358
}
375
359
376
- if ( parameters !== undefined ) {
377
- queryParameters . parameters = parameters . toString ( ) ;
378
- }
360
+ const requestPath = '/1{path}' . replace ( '{path}' , path ) ;
361
+ const headers : Headers = { } ;
362
+ const queryParameters : QueryParameters = parameters || { } ;
379
363
380
364
const request : Request = {
381
365
method : 'PUT' ,
@@ -404,19 +388,19 @@ export function createAbtestingApi(
404
388
{ id } : StopABTestProps ,
405
389
requestOptions ?: RequestOptions
406
390
) : Promise < ABTestResponse > {
407
- const requestPath = '/2/abtests/{id}/stop' . replace (
408
- '{id}' ,
409
- encodeURIComponent ( String ( id ) )
410
- ) ;
411
- const headers : Headers = { } ;
412
- const queryParameters : QueryParameters = { } ;
413
-
414
391
if ( ! id ) {
415
392
throw new Error (
416
393
'Parameter `id` is required when calling `stopABTest`.'
417
394
) ;
418
395
}
419
396
397
+ const requestPath = '/2/abtests/{id}/stop' . replace (
398
+ '{id}' ,
399
+ encodeURIComponent ( id )
400
+ ) ;
401
+ const headers : Headers = { } ;
402
+ const queryParameters : QueryParameters = { } ;
403
+
420
404
const request : Request = {
421
405
method : 'POST' ,
422
406
path : requestPath ,
@@ -442,9 +426,9 @@ export type DelProps = {
442
426
*/
443
427
path : string ;
444
428
/**
445
- * URL-encoded query string. Force some query parameters to be applied for each query made with this API key .
429
+ * Query parameters to be applied to the current query .
446
430
*/
447
- parameters ?: string ;
431
+ parameters ?: Record < string , any > ;
448
432
/**
449
433
* The parameters to send with the custom request.
450
434
*/
@@ -464,9 +448,9 @@ export type GetProps = {
464
448
*/
465
449
path : string ;
466
450
/**
467
- * URL-encoded query string. Force some query parameters to be applied for each query made with this API key .
451
+ * Query parameters to be applied to the current query .
468
452
*/
469
- parameters ?: string ;
453
+ parameters ?: Record < string , any > ;
470
454
} ;
471
455
472
456
export type GetABTestProps = {
@@ -493,9 +477,9 @@ export type PostProps = {
493
477
*/
494
478
path : string ;
495
479
/**
496
- * URL-encoded query string. Force some query parameters to be applied for each query made with this API key .
480
+ * Query parameters to be applied to the current query .
497
481
*/
498
- parameters ?: string ;
482
+ parameters ?: Record < string , any > ;
499
483
/**
500
484
* The parameters to send with the custom request.
501
485
*/
@@ -508,9 +492,9 @@ export type PutProps = {
508
492
*/
509
493
path : string ;
510
494
/**
511
- * URL-encoded query string. Force some query parameters to be applied for each query made with this API key .
495
+ * Query parameters to be applied to the current query .
512
496
*/
513
- parameters ?: string ;
497
+ parameters ?: Record < string , any > ;
514
498
/**
515
499
* The parameters to send with the custom request.
516
500
*/
0 commit comments