Skip to content

Commit

Permalink
feat(specs): add /schedule endpoint (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3350

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Fernando Beck <fe.beck25@gmail.com>
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
  • Loading branch information
3 people committed Aug 20, 2024
1 parent 04055ab commit a1b2456
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/client-abtesting/model/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
8 changes: 8 additions & 0 deletions packages/client-abtesting/model/scheduleABTestResponse.ts
Original file line number Diff line number Diff line change
@@ -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;
};
25 changes: 25 additions & 0 deletions packages/client-abtesting/model/scheduleABTestsRequest.ts
Original file line number Diff line number Diff line change
@@ -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;
};
57 changes: 57 additions & 0 deletions packages/client-abtesting/src/abtestingClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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<ScheduleABTestResponse> {
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.
*
Expand Down

0 comments on commit a1b2456

Please sign in to comment.