From a1b2456d69d573eb2b8b3c21e3b00b094b4b8ea8 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Tue, 20 Aug 2024 10:00:53 +0000 Subject: [PATCH] feat(specs): add /schedule endpoint (generated) https://github.com/algolia/api-clients-automation/pull/3350 Co-authored-by: algolia-bot Co-authored-by: Fernando Beck Co-authored-by: Pierre Millot --- packages/client-abtesting/model/index.ts | 2 + .../model/scheduleABTestResponse.ts | 8 +++ .../model/scheduleABTestsRequest.ts | 25 ++++++++ .../client-abtesting/src/abtestingClient.ts | 57 +++++++++++++++++++ 4 files changed, 92 insertions(+) create mode 100644 packages/client-abtesting/model/scheduleABTestResponse.ts create mode 100644 packages/client-abtesting/model/scheduleABTestsRequest.ts diff --git a/packages/client-abtesting/model/index.ts b/packages/client-abtesting/model/index.ts index dd5df5ad0..2c7d1ab83 100644 --- a/packages/client-abtesting/model/index.ts +++ b/packages/client-abtesting/model/index.ts @@ -18,6 +18,8 @@ export * from './listABTestsResponse'; export * from './minimumDetectableEffect'; export * from './outliers'; export * from './outliersFilter'; +export * from './scheduleABTestResponse'; +export * from './scheduleABTestsRequest'; export * from './status'; export * from './variant'; export * from './clientMethodProps'; diff --git a/packages/client-abtesting/model/scheduleABTestResponse.ts b/packages/client-abtesting/model/scheduleABTestResponse.ts new file mode 100644 index 000000000..842b8109f --- /dev/null +++ b/packages/client-abtesting/model/scheduleABTestResponse.ts @@ -0,0 +1,8 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +export type ScheduleABTestResponse = { + /** + * Unique scheduled A/B test identifier. + */ + abTestScheduleID: number; +}; diff --git a/packages/client-abtesting/model/scheduleABTestsRequest.ts b/packages/client-abtesting/model/scheduleABTestsRequest.ts new file mode 100644 index 000000000..227f2e820 --- /dev/null +++ b/packages/client-abtesting/model/scheduleABTestsRequest.ts @@ -0,0 +1,25 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import type { AddABTestsVariant } from './addABTestsVariant'; + +export type ScheduleABTestsRequest = { + /** + * A/B test name. + */ + name: string; + + /** + * A/B test variants. + */ + variants: AddABTestsVariant[]; + + /** + * Date and time when the A/B test is scheduled to start, in RFC 3339 format. + */ + scheduledAt: string; + + /** + * End date and time of the A/B test, in RFC 3339 format. + */ + endAt: string; +}; diff --git a/packages/client-abtesting/src/abtestingClient.ts b/packages/client-abtesting/src/abtestingClient.ts index eba666ec3..a133773c0 100644 --- a/packages/client-abtesting/src/abtestingClient.ts +++ b/packages/client-abtesting/src/abtestingClient.ts @@ -28,6 +28,8 @@ import type { StopABTestProps, } from '../model/clientMethodProps'; import type { ListABTestsResponse } from '../model/listABTestsResponse'; +import type { ScheduleABTestResponse } from '../model/scheduleABTestResponse'; +import type { ScheduleABTestsRequest } from '../model/scheduleABTestsRequest'; export const apiClientVersion = '5.0.2'; @@ -407,6 +409,61 @@ export function createAbtestingClient({ return transporter.request(request, requestOptions); }, + /** + * Schedule an A/B test to be started at a later time. + * + * Required API Key ACLs: + * - editSettings. + * + * @param scheduleABTestsRequest - The scheduleABTestsRequest object. + * @param requestOptions - The requestOptions to send along with the query, they will be merged with the transporter requestOptions. + */ + scheduleABTest( + scheduleABTestsRequest: ScheduleABTestsRequest, + requestOptions?: RequestOptions + ): Promise { + if (!scheduleABTestsRequest) { + throw new Error( + 'Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.' + ); + } + + if (!scheduleABTestsRequest.name) { + throw new Error( + 'Parameter `scheduleABTestsRequest.name` is required when calling `scheduleABTest`.' + ); + } + if (!scheduleABTestsRequest.variants) { + throw new Error( + 'Parameter `scheduleABTestsRequest.variants` is required when calling `scheduleABTest`.' + ); + } + if (!scheduleABTestsRequest.scheduledAt) { + throw new Error( + 'Parameter `scheduleABTestsRequest.scheduledAt` is required when calling `scheduleABTest`.' + ); + } + if (!scheduleABTestsRequest.endAt) { + throw new Error( + 'Parameter `scheduleABTestsRequest.endAt` is required when calling `scheduleABTest`.' + ); + } + + const requestPath = '/2/abtests/schedule'; + const headers: Headers = {}; + const queryParameters: QueryParameters = {}; + + const request: Request = { + method: 'POST', + path: requestPath, + queryParameters, + headers, + data: scheduleABTestsRequest, + }; + + return transporter.request(request, requestOptions); + }, + /** * Stops an A/B test by its ID. You can\'t restart stopped A/B tests. *