Skip to content

Commit

Permalink
chore: generated code for commit 8727ddc. [skip ci]
Browse files Browse the repository at this point in the history
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed May 12, 2022
1 parent 8727ddc commit 9e2cc89
Show file tree
Hide file tree
Showing 9 changed files with 505 additions and 325 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,13 @@ export function createTransporter({
cacheable: baseRequestOptions?.cacheable,
timeout: baseRequestOptions?.timeout,
queryParameters: {
...methodOptions.queryParameters,
...baseRequestOptions?.queryParameters,
...methodOptions.queryParameters,
},
headers: {
Accept: 'application/json',
...methodOptions.headers,
...baseRequestOptions?.headers,
...methodOptions.headers,
},
};

Expand Down
72 changes: 47 additions & 25 deletions clients/algoliasearch-client-php/lib/Api/AbtestingClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getClientConfig()
*
* @see \Algolia\AlgoliaSearch\Model\Abtesting\AddABTestsRequest
*
* @param array $requestOptions Request Options
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
*
* @return array<string, mixed>|\Algolia\AlgoliaSearch\Model\Abtesting\ABTestResponse
*/
Expand All @@ -127,16 +127,17 @@ public function addABTests($addABTestsRequest, $requestOptions = [])

$resourcePath = '/2/abtests';
$queryParameters = [];
$headers = [];
$httpBody = [];

if (isset($addABTestsRequest)) {
$httpBody = $addABTestsRequest;
}
$requestOptions += $queryParameters;

return $this->sendRequest(
'POST',
$resourcePath,
$headers,
$queryParameters,
$httpBody,
$requestOptions
Expand All @@ -148,7 +149,7 @@ public function addABTests($addABTestsRequest, $requestOptions = [])
*
* @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required)
* @param array $parameters Query parameters to be applied to the current query. (optional)
* @param array $requestOptions Request Options
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
*
* @return array<string, mixed>|object
*/
Expand All @@ -163,6 +164,7 @@ public function del($path, $parameters = null, $requestOptions = [])

$resourcePath = '/1{path}';
$queryParameters = [];
$headers = [];
$httpBody = [];

if ($parameters !== null) {
Expand All @@ -187,11 +189,10 @@ public function del($path, $parameters = null, $requestOptions = [])
$resourcePath = str_replace('{path}', $path, $resourcePath);
}

$requestOptions += $queryParameters;

return $this->sendRequest(
'DELETE',
$resourcePath,
$headers,
$queryParameters,
$httpBody,
$requestOptions
Expand All @@ -202,7 +203,7 @@ public function del($path, $parameters = null, $requestOptions = [])
* Delete a test.
*
* @param int $id The A/B test ID. (required)
* @param array $requestOptions Request Options
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
*
* @return array<string, mixed>|\Algolia\AlgoliaSearch\Model\Abtesting\ABTestResponse
*/
Expand All @@ -217,6 +218,7 @@ public function deleteABTest($id, $requestOptions = [])

$resourcePath = '/2/abtests/{id}';
$queryParameters = [];
$headers = [];
$httpBody = [];

// path params
Expand All @@ -228,11 +230,10 @@ public function deleteABTest($id, $requestOptions = [])
);
}

$requestOptions += $queryParameters;

return $this->sendRequest(
'DELETE',
$resourcePath,
$headers,
$queryParameters,
$httpBody,
$requestOptions
Expand All @@ -244,7 +245,7 @@ public function deleteABTest($id, $requestOptions = [])
*
* @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required)
* @param array $parameters Query parameters to be applied to the current query. (optional)
* @param array $requestOptions Request Options
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
*
* @return array<string, mixed>|object
*/
Expand All @@ -259,6 +260,7 @@ public function get($path, $parameters = null, $requestOptions = [])

$resourcePath = '/1{path}';
$queryParameters = [];
$headers = [];
$httpBody = [];

if ($parameters !== null) {
Expand All @@ -283,11 +285,10 @@ public function get($path, $parameters = null, $requestOptions = [])
$resourcePath = str_replace('{path}', $path, $resourcePath);
}

$requestOptions += $queryParameters;

return $this->sendRequest(
'GET',
$resourcePath,
$headers,
$queryParameters,
$httpBody,
$requestOptions
Expand All @@ -298,7 +299,7 @@ public function get($path, $parameters = null, $requestOptions = [])
* Get a test.
*
* @param int $id The A/B test ID. (required)
* @param array $requestOptions Request Options
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
*
* @return array<string, mixed>|\Algolia\AlgoliaSearch\Model\Abtesting\ABTest
*/
Expand All @@ -313,6 +314,7 @@ public function getABTest($id, $requestOptions = [])

$resourcePath = '/2/abtests/{id}';
$queryParameters = [];
$headers = [];
$httpBody = [];

// path params
Expand All @@ -324,11 +326,10 @@ public function getABTest($id, $requestOptions = [])
);
}

$requestOptions += $queryParameters;

return $this->sendRequest(
'GET',
$resourcePath,
$headers,
$queryParameters,
$httpBody,
$requestOptions
Expand All @@ -340,7 +341,7 @@ public function getABTest($id, $requestOptions = [])
*
* @param int $offset Position of the starting record. Used for paging. 0 is the first record. (optional, default to 0)
* @param int $limit Number of records to return. Limit is the size of the page. (optional, default to 10)
* @param array $requestOptions Request Options
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
*
* @return array<string, mixed>|\Algolia\AlgoliaSearch\Model\Abtesting\ListABTestsResponse
*/
Expand All @@ -351,6 +352,7 @@ public function listABTests(
) {
$resourcePath = '/2/abtests';
$queryParameters = [];
$headers = [];
$httpBody = [];

if ($offset !== null) {
Expand Down Expand Up @@ -387,11 +389,10 @@ public function listABTests(
}
}

$requestOptions += $queryParameters;

return $this->sendRequest(
'GET',
$resourcePath,
$headers,
$queryParameters,
$httpBody,
$requestOptions
Expand All @@ -404,7 +405,7 @@ public function listABTests(
* @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required)
* @param array $parameters Query parameters to be applied to the current query. (optional)
* @param array $body The parameters to send with the custom request. (optional)
* @param array $requestOptions Request Options
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
*
* @return array<string, mixed>|object
*/
Expand All @@ -423,6 +424,7 @@ public function post(

$resourcePath = '/1{path}';
$queryParameters = [];
$headers = [];
$httpBody = [];

if ($parameters !== null) {
Expand Down Expand Up @@ -450,11 +452,11 @@ public function post(
if (isset($body)) {
$httpBody = $body;
}
$requestOptions += $queryParameters;

return $this->sendRequest(
'POST',
$resourcePath,
$headers,
$queryParameters,
$httpBody,
$requestOptions
Expand All @@ -467,7 +469,7 @@ public function post(
* @param string $path The path of the API endpoint to target, anything after the /1 needs to be specified. (required)
* @param array $parameters Query parameters to be applied to the current query. (optional)
* @param array $body The parameters to send with the custom request. (optional)
* @param array $requestOptions Request Options
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
*
* @return array<string, mixed>|object
*/
Expand All @@ -486,6 +488,7 @@ public function put(

$resourcePath = '/1{path}';
$queryParameters = [];
$headers = [];
$httpBody = [];

if ($parameters !== null) {
Expand Down Expand Up @@ -513,11 +516,11 @@ public function put(
if (isset($body)) {
$httpBody = $body;
}
$requestOptions += $queryParameters;

return $this->sendRequest(
'PUT',
$resourcePath,
$headers,
$queryParameters,
$httpBody,
$requestOptions
Expand All @@ -528,7 +531,7 @@ public function put(
* Stop a test.
*
* @param int $id The A/B test ID. (required)
* @param array $requestOptions Request Options
* @param array $requestOptions the requestOptions to send along with the query, they will be merged with the transporter requestOptions
*
* @return array<string, mixed>|\Algolia\AlgoliaSearch\Model\Abtesting\ABTestResponse
*/
Expand All @@ -543,6 +546,7 @@ public function stopABTest($id, $requestOptions = [])

$resourcePath = '/2/abtests/{id}/stop';
$queryParameters = [];
$headers = [];
$httpBody = [];

// path params
Expand All @@ -554,11 +558,10 @@ public function stopABTest($id, $requestOptions = [])
);
}

$requestOptions += $queryParameters;

return $this->sendRequest(
'POST',
$resourcePath,
$headers,
$queryParameters,
$httpBody,
$requestOptions
Expand All @@ -568,11 +571,30 @@ public function stopABTest($id, $requestOptions = [])
private function sendRequest(
$method,
$resourcePath,
$headers,
$queryParameters,
$httpBody,
$requestOptions
) {
$query = \GuzzleHttp\Psr7\Query::build($queryParameters);
if (!isset($requestOptions['headers'])) {
$requestOptions['headers'] = [];
}
if (!isset($requestOptions['queryParameters'])) {
$requestOptions['queryParameters'] = [];
}

$requestOptions['headers'] = array_merge(
$headers,
$requestOptions['headers']
);
$requestOptions['queryParameters'] = array_merge(
$queryParameters,
$requestOptions['queryParameters']
);

$query = \GuzzleHttp\Psr7\Query::build(
$requestOptions['queryParameters']
);

if ($method === 'GET') {
$request = $this->api->read(
Expand Down
Loading

0 comments on commit 9e2cc89

Please sign in to comment.