Skip to content

Commit 3817b9e

Browse files
algolia-botfebeckmillotp
committed
feat(specs): add /schedule endpoint (generated)
algolia/api-clients-automation#3350 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Fernando Beck <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 49c0ad7 commit 3817b9e

File tree

3 files changed

+617
-0
lines changed

3 files changed

+617
-0
lines changed

lib/Api/AbtestingClient.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Algolia\AlgoliaSearch\Algolia;
88
use Algolia\AlgoliaSearch\Configuration\AbtestingConfig;
99
use Algolia\AlgoliaSearch\Model\Abtesting\AddABTestsRequest;
10+
use Algolia\AlgoliaSearch\Model\Abtesting\ScheduleABTestsRequest;
1011
use Algolia\AlgoliaSearch\ObjectSerializer;
1112
use Algolia\AlgoliaSearch\RetryStrategy\ApiWrapper;
1213
use Algolia\AlgoliaSearch\RetryStrategy\ApiWrapperInterface;
@@ -408,6 +409,41 @@ public function listABTests($offset = null, $limit = null, $indexPrefix = null,
408409
return $this->sendRequest('GET', $resourcePath, $headers, $queryParameters, $httpBody, $requestOptions);
409410
}
410411

412+
/**
413+
* Schedule an A/B test to be started at a later time.
414+
*
415+
* Required API Key ACLs:
416+
* - editSettings
417+
*
418+
* @param array $scheduleABTestsRequest scheduleABTestsRequest (required)
419+
* - $scheduleABTestsRequest['name'] => (string) A/B test name. (required)
420+
* - $scheduleABTestsRequest['variants'] => (array) A/B test variants. (required)
421+
* - $scheduleABTestsRequest['scheduledAt'] => (string) Date and time when the A/B test is scheduled to start, in RFC 3339 format. (required)
422+
* - $scheduleABTestsRequest['endAt'] => (string) End date and time of the A/B test, in RFC 3339 format. (required)
423+
*
424+
* @see ScheduleABTestsRequest
425+
*
426+
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
427+
*
428+
* @return \Algolia\AlgoliaSearch\Model\Abtesting\ScheduleABTestResponse|array<string, mixed>
429+
*/
430+
public function scheduleABTest($scheduleABTestsRequest, $requestOptions = [])
431+
{
432+
// verify the required parameter 'scheduleABTestsRequest' is set
433+
if (!isset($scheduleABTestsRequest)) {
434+
throw new \InvalidArgumentException(
435+
'Parameter `scheduleABTestsRequest` is required when calling `scheduleABTest`.'
436+
);
437+
}
438+
439+
$resourcePath = '/2/abtests/schedule';
440+
$queryParameters = [];
441+
$headers = [];
442+
$httpBody = $scheduleABTestsRequest;
443+
444+
return $this->sendRequest('POST', $resourcePath, $headers, $queryParameters, $httpBody, $requestOptions);
445+
}
446+
411447
/**
412448
* Stops an A/B test by its ID. You can't restart stopped A/B tests.
413449
*
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
<?php
2+
3+
// 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.
4+
5+
namespace Algolia\AlgoliaSearch\Model\Abtesting;
6+
7+
use Algolia\AlgoliaSearch\Model\AbstractModel;
8+
9+
/**
10+
* ScheduleABTestResponse Class Doc Comment.
11+
*
12+
* @category Class
13+
*/
14+
class ScheduleABTestResponse extends AbstractModel implements ModelInterface, \ArrayAccess, \JsonSerializable
15+
{
16+
/**
17+
* Array of property to type mappings. Used for (de)serialization.
18+
*
19+
* @var string[]
20+
*/
21+
protected static $modelTypes = [
22+
'abTestScheduleID' => 'int',
23+
];
24+
25+
/**
26+
* Array of property to format mappings. Used for (de)serialization.
27+
*
28+
* @var string[]
29+
*/
30+
protected static $modelFormats = [
31+
'abTestScheduleID' => null,
32+
];
33+
34+
/**
35+
* Array of attributes where the key is the local name,
36+
* and the value is the original name.
37+
*
38+
* @var string[]
39+
*/
40+
protected static $attributeMap = [
41+
'abTestScheduleID' => 'abTestScheduleID',
42+
];
43+
44+
/**
45+
* Array of attributes to setter functions (for deserialization of responses).
46+
*
47+
* @var string[]
48+
*/
49+
protected static $setters = [
50+
'abTestScheduleID' => 'setAbTestScheduleID',
51+
];
52+
53+
/**
54+
* Array of attributes to getter functions (for serialization of requests).
55+
*
56+
* @var string[]
57+
*/
58+
protected static $getters = [
59+
'abTestScheduleID' => 'getAbTestScheduleID',
60+
];
61+
62+
/**
63+
* Associative array for storing property values.
64+
*
65+
* @var mixed[]
66+
*/
67+
protected $container = [];
68+
69+
/**
70+
* Constructor.
71+
*
72+
* @param mixed[] $data Associated array of property values
73+
*/
74+
public function __construct(?array $data = null)
75+
{
76+
if (isset($data['abTestScheduleID'])) {
77+
$this->container['abTestScheduleID'] = $data['abTestScheduleID'];
78+
}
79+
}
80+
81+
/**
82+
* Array of attributes where the key is the local name,
83+
* and the value is the original name.
84+
*
85+
* @return array
86+
*/
87+
public static function attributeMap()
88+
{
89+
return self::$attributeMap;
90+
}
91+
92+
/**
93+
* Array of property to type mappings. Used for (de)serialization.
94+
*
95+
* @return array
96+
*/
97+
public static function modelTypes()
98+
{
99+
return self::$modelTypes;
100+
}
101+
102+
/**
103+
* Array of property to format mappings. Used for (de)serialization.
104+
*
105+
* @return array
106+
*/
107+
public static function modelFormats()
108+
{
109+
return self::$modelFormats;
110+
}
111+
112+
/**
113+
* Array of attributes to setter functions (for deserialization of responses).
114+
*
115+
* @return array
116+
*/
117+
public static function setters()
118+
{
119+
return self::$setters;
120+
}
121+
122+
/**
123+
* Array of attributes to getter functions (for serialization of requests).
124+
*
125+
* @return array
126+
*/
127+
public static function getters()
128+
{
129+
return self::$getters;
130+
}
131+
132+
/**
133+
* Show all the invalid properties with reasons.
134+
*
135+
* @return array invalid properties with reasons
136+
*/
137+
public function listInvalidProperties()
138+
{
139+
$invalidProperties = [];
140+
141+
if (!isset($this->container['abTestScheduleID']) || null === $this->container['abTestScheduleID']) {
142+
$invalidProperties[] = "'abTestScheduleID' can't be null";
143+
}
144+
145+
return $invalidProperties;
146+
}
147+
148+
/**
149+
* Validate all the properties in the model
150+
* return true if all passed.
151+
*
152+
* @return bool True if all properties are valid
153+
*/
154+
public function valid()
155+
{
156+
return 0 === count($this->listInvalidProperties());
157+
}
158+
159+
/**
160+
* Gets abTestScheduleID.
161+
*
162+
* @return int
163+
*/
164+
public function getAbTestScheduleID()
165+
{
166+
return $this->container['abTestScheduleID'] ?? null;
167+
}
168+
169+
/**
170+
* Sets abTestScheduleID.
171+
*
172+
* @param int $abTestScheduleID unique scheduled A/B test identifier
173+
*
174+
* @return self
175+
*/
176+
public function setAbTestScheduleID($abTestScheduleID)
177+
{
178+
$this->container['abTestScheduleID'] = $abTestScheduleID;
179+
180+
return $this;
181+
}
182+
183+
/**
184+
* Returns true if offset exists. False otherwise.
185+
*
186+
* @param int $offset Offset
187+
*
188+
* @return bool
189+
*/
190+
public function offsetExists($offset)
191+
{
192+
return isset($this->container[$offset]);
193+
}
194+
195+
/**
196+
* Gets offset.
197+
*
198+
* @param int $offset Offset
199+
*
200+
* @return null|mixed
201+
*/
202+
public function offsetGet($offset)
203+
{
204+
return $this->container[$offset] ?? null;
205+
}
206+
207+
/**
208+
* Sets value based on offset.
209+
*
210+
* @param null|int $offset Offset
211+
* @param mixed $value Value to be set
212+
*/
213+
public function offsetSet($offset, $value)
214+
{
215+
if (is_null($offset)) {
216+
$this->container[] = $value;
217+
} else {
218+
$this->container[$offset] = $value;
219+
}
220+
}
221+
222+
/**
223+
* Unsets offset.
224+
*
225+
* @param int $offset Offset
226+
*/
227+
public function offsetUnset($offset)
228+
{
229+
unset($this->container[$offset]);
230+
}
231+
}

0 commit comments

Comments
 (0)