@@ -8,7 +8,7 @@ import type {
88 Request ,
99 RequestOptions ,
1010} from '@algolia/client-common' ;
11- import { createAuth , createTransporter , getAlgoliaAgent } from '@algolia/client-common' ;
11+ import { createAuth , createTransporter , getAlgoliaAgent , validateRequired } from '@algolia/client-common' ;
1212
1313import type { ABTest } from '../model/aBTest' ;
1414import type { ABTestResponse } from '../model/aBTestResponse' ;
@@ -30,7 +30,7 @@ import type {
3030 StopABTestProps ,
3131} from '../model/clientMethodProps' ;
3232
33- export const apiClientVersion = '1.19 .0' ;
33+ export const apiClientVersion = '1.20 .0' ;
3434
3535export const REGIONS = [ 'de' , 'us' ] as const ;
3636export type Region = ( typeof REGIONS ) [ number ] ;
@@ -130,22 +130,12 @@ export function createAbtestingV3Client({
130130 * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
131131 */
132132 addABTests ( addABTestsRequest : AddABTestsRequest , requestOptions ?: RequestOptions ) : Promise < ABTestResponse > {
133- if ( ! addABTestsRequest ) {
134- throw new Error ( 'Parameter `addABTestsRequest` is required when calling `addABTests`.' ) ;
135- }
133+ validateRequired ( 'addABTestsRequest' , 'addABTests' , addABTestsRequest ) ;
136134
137- if ( ! addABTestsRequest . name ) {
138- throw new Error ( 'Parameter `addABTestsRequest.name` is required when calling `addABTests`.' ) ;
139- }
140- if ( ! addABTestsRequest . variants ) {
141- throw new Error ( 'Parameter `addABTestsRequest.variants` is required when calling `addABTests`.' ) ;
142- }
143- if ( ! addABTestsRequest . metrics ) {
144- throw new Error ( 'Parameter `addABTestsRequest.metrics` is required when calling `addABTests`.' ) ;
145- }
146- if ( ! addABTestsRequest . endAt ) {
147- throw new Error ( 'Parameter `addABTestsRequest.endAt` is required when calling `addABTests`.' ) ;
148- }
135+ validateRequired ( 'addABTestsRequest.name' , 'addABTests' , addABTestsRequest . name ) ;
136+ validateRequired ( 'addABTestsRequest.variants' , 'addABTests' , addABTestsRequest . variants ) ;
137+ validateRequired ( 'addABTestsRequest.metrics' , 'addABTests' , addABTestsRequest . metrics ) ;
138+ validateRequired ( 'addABTestsRequest.endAt' , 'addABTests' , addABTestsRequest . endAt ) ;
149139
150140 const requestPath = '/3/abtests' ;
151141 const headers : Headers = { } ;
@@ -173,9 +163,7 @@ export function createAbtestingV3Client({
173163 { path, parameters } : CustomDeleteProps ,
174164 requestOptions ?: RequestOptions ,
175165 ) : Promise < Record < string , unknown > > {
176- if ( ! path ) {
177- throw new Error ( 'Parameter `path` is required when calling `customDelete`.' ) ;
178- }
166+ validateRequired ( 'path' , 'customDelete' , path ) ;
179167
180168 const requestPath = '/{path}' . replace ( '{path}' , path ) ;
181169 const headers : Headers = { } ;
@@ -199,9 +187,7 @@ export function createAbtestingV3Client({
199187 * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
200188 */
201189 customGet ( { path, parameters } : CustomGetProps , requestOptions ?: RequestOptions ) : Promise < Record < string , unknown > > {
202- if ( ! path ) {
203- throw new Error ( 'Parameter `path` is required when calling `customGet`.' ) ;
204- }
190+ validateRequired ( 'path' , 'customGet' , path ) ;
205191
206192 const requestPath = '/{path}' . replace ( '{path}' , path ) ;
207193 const headers : Headers = { } ;
@@ -229,9 +215,7 @@ export function createAbtestingV3Client({
229215 { path, parameters, body } : CustomPostProps ,
230216 requestOptions ?: RequestOptions ,
231217 ) : Promise < Record < string , unknown > > {
232- if ( ! path ) {
233- throw new Error ( 'Parameter `path` is required when calling `customPost`.' ) ;
234- }
218+ validateRequired ( 'path' , 'customPost' , path ) ;
235219
236220 const requestPath = '/{path}' . replace ( '{path}' , path ) ;
237221 const headers : Headers = { } ;
@@ -260,9 +244,7 @@ export function createAbtestingV3Client({
260244 { path, parameters, body } : CustomPutProps ,
261245 requestOptions ?: RequestOptions ,
262246 ) : Promise < Record < string , unknown > > {
263- if ( ! path ) {
264- throw new Error ( 'Parameter `path` is required when calling `customPut`.' ) ;
265- }
247+ validateRequired ( 'path' , 'customPut' , path ) ;
266248
267249 const requestPath = '/{path}' . replace ( '{path}' , path ) ;
268250 const headers : Headers = { } ;
@@ -289,9 +271,7 @@ export function createAbtestingV3Client({
289271 * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
290272 */
291273 deleteABTest ( { id } : DeleteABTestProps , requestOptions ?: RequestOptions ) : Promise < ABTestResponse > {
292- if ( ! id ) {
293- throw new Error ( 'Parameter `id` is required when calling `deleteABTest`.' ) ;
294- }
274+ validateRequired ( 'id' , 'deleteABTest' , id ) ;
295275
296276 const requestPath = '/3/abtests/{id}' . replace ( '{id}' , encodeURIComponent ( id ) ) ;
297277 const headers : Headers = { } ;
@@ -319,16 +299,10 @@ export function createAbtestingV3Client({
319299 estimateABTestRequest : EstimateABTestRequest ,
320300 requestOptions ?: RequestOptions ,
321301 ) : Promise < EstimateABTestResponse > {
322- if ( ! estimateABTestRequest ) {
323- throw new Error ( 'Parameter `estimateABTestRequest` is required when calling `estimateABTest`.' ) ;
324- }
302+ validateRequired ( 'estimateABTestRequest' , 'estimateABTest' , estimateABTestRequest ) ;
325303
326- if ( ! estimateABTestRequest . configuration ) {
327- throw new Error ( 'Parameter `estimateABTestRequest.configuration` is required when calling `estimateABTest`.' ) ;
328- }
329- if ( ! estimateABTestRequest . variants ) {
330- throw new Error ( 'Parameter `estimateABTestRequest.variants` is required when calling `estimateABTest`.' ) ;
331- }
304+ validateRequired ( 'estimateABTestRequest.configuration' , 'estimateABTest' , estimateABTestRequest . configuration ) ;
305+ validateRequired ( 'estimateABTestRequest.variants' , 'estimateABTest' , estimateABTestRequest . variants ) ;
332306
333307 const requestPath = '/3/abtests/estimate' ;
334308 const headers : Headers = { } ;
@@ -355,9 +329,7 @@ export function createAbtestingV3Client({
355329 * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
356330 */
357331 getABTest ( { id } : GetABTestProps , requestOptions ?: RequestOptions ) : Promise < ABTest > {
358- if ( ! id ) {
359- throw new Error ( 'Parameter `id` is required when calling `getABTest`.' ) ;
360- }
332+ validateRequired ( 'id' , 'getABTest' , id ) ;
361333
362334 const requestPath = '/3/abtests/{id}' . replace ( '{id}' , encodeURIComponent ( id ) ) ;
363335 const headers : Headers = { } ;
@@ -389,9 +361,7 @@ export function createAbtestingV3Client({
389361 { id, startDate, endDate, metric } : GetTimeseriesProps ,
390362 requestOptions ?: RequestOptions ,
391363 ) : Promise < Timeseries > {
392- if ( ! id ) {
393- throw new Error ( 'Parameter `id` is required when calling `getTimeseries`.' ) ;
394- }
364+ validateRequired ( 'id' , 'getTimeseries' , id ) ;
395365
396366 const requestPath = '/3/abtests/{id}/timeseries' . replace ( '{id}' , encodeURIComponent ( id ) ) ;
397367 const headers : Headers = { } ;
@@ -480,9 +450,7 @@ export function createAbtestingV3Client({
480450 * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions.
481451 */
482452 stopABTest ( { id } : StopABTestProps , requestOptions ?: RequestOptions ) : Promise < ABTestResponse > {
483- if ( ! id ) {
484- throw new Error ( 'Parameter `id` is required when calling `stopABTest`.' ) ;
485- }
453+ validateRequired ( 'id' , 'stopABTest' , id ) ;
486454
487455 const requestPath = '/3/abtests/{id}/stop' . replace ( '{id}' , encodeURIComponent ( id ) ) ;
488456 const headers : Headers = { } ;
0 commit comments