Skip to content

Commit

Permalink
chore: generated code for commit 39ab5e8. [skip ci]
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Millot <pierre.millot@algolia.com>
  • Loading branch information
algolia-bot and millotp committed Apr 27, 2022
1 parent 39ab5e8 commit f387277
Show file tree
Hide file tree
Showing 200 changed files with 8,287 additions and 5,024 deletions.
126 changes: 88 additions & 38 deletions clients/algoliasearch-client-php/lib/Api/AbtestingClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

namespace Algolia\AlgoliaSearch\Api;

use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\RequestOptions;
use GuzzleHttp\Utils;
use Algolia\AlgoliaSearch\Algolia;
use Algolia\AlgoliaSearch\ApiException;
use Algolia\AlgoliaSearch\Configuration\AbtestingConfig;
use Algolia\AlgoliaSearch\ObjectSerializer;
use Algolia\AlgoliaSearch\RetryStrategy\ApiWrapper;
Expand Down Expand Up @@ -31,8 +37,10 @@ class AbtestingClient
* @param AbtestingConfig $config
* @param ApiWrapperInterface $apiWrapper
*/
public function __construct(ApiWrapperInterface $apiWrapper, AbtestingConfig $config)
{
public function __construct(
ApiWrapperInterface $apiWrapper,
AbtestingConfig $config
) {
$this->config = $config;

$this->api = $apiWrapper;
Expand All @@ -48,7 +56,12 @@ public function __construct(ApiWrapperInterface $apiWrapper, AbtestingConfig $co
public static function create($appId = null, $apiKey = null, $region = null)
{
$allowedRegions = explode('-', 'us-de');
$config = AbtestingConfig::create($appId, $apiKey, $region, $allowedRegions);
$config = AbtestingConfig::create(
$appId,
$apiKey,
$region,
$allowedRegions
);

return static::createWithConfig($config);
}
Expand All @@ -66,7 +79,9 @@ public static function createWithConfig(AbtestingConfig $config)
// If a list of hosts was passed, we ignore the cache
$clusterHosts = ClusterHosts::create($hosts);
} else {
$clusterHosts = ClusterHosts::create('analytics.'.$config->getRegion().'.algolia.com');
$clusterHosts = ClusterHosts::create(
'analytics.' . $config->getRegion() . '.algolia.com'
);
}

$apiWrapper = new ApiWrapper(
Expand All @@ -93,15 +108,17 @@ public function getClientConfig()
* - $addABTestsRequest['name'] => (string) A/B test name. (required)
* - $addABTestsRequest['variant'] => (array) List of 2 variants for the A/B test. (required)
* - $addABTestsRequest['endAt'] => (string) End date for the A/B test expressed as YYYY-MM-DDThh:mm:ssZ. (required)
*
* @see \Algolia\AlgoliaSearch\Model\Abtesting\AddABTestsRequest
*
* @return array<string, mixed>|\Algolia\AlgoliaSearch\Model\Abtesting\ABTestResponse
*/
public function addABTests($addABTestsRequest)
{
// verify the required parameter 'addABTestsRequest' is set
if ($addABTestsRequest === null || (is_array($addABTestsRequest) && count($addABTestsRequest) === 0)) {
if (
$addABTestsRequest === null ||
(is_array($addABTestsRequest) && count($addABTestsRequest) === 0)
) {
throw new \InvalidArgumentException(
'Missing the required parameter $addABTestsRequest when calling addABTests'
);
Expand All @@ -115,7 +132,12 @@ public function addABTests($addABTestsRequest)
$httpBody = $addABTestsRequest;
}

return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody);
return $this->sendRequest(
'POST',
$resourcePath,
$queryParams,
$httpBody
);
}

/**
Expand Down Expand Up @@ -151,14 +173,15 @@ public function del($path, $parameters = null)

// path params
if ($path !== null) {
$resourcePath = str_replace(
'{path}',
$path,
$resourcePath
);
$resourcePath = str_replace('{path}', $path, $resourcePath);
}

return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody);
return $this->sendRequest(
'DELETE',
$resourcePath,
$queryParams,
$httpBody
);
}

/**
Expand Down Expand Up @@ -190,7 +213,12 @@ public function deleteABTest($id)
);
}

return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody);
return $this->sendRequest(
'DELETE',
$resourcePath,
$queryParams,
$httpBody
);
}

/**
Expand Down Expand Up @@ -226,14 +254,15 @@ public function get($path, $parameters = null)

// path params
if ($path !== null) {
$resourcePath = str_replace(
'{path}',
$path,
$resourcePath
);
$resourcePath = str_replace('{path}', $path, $resourcePath);
}

return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody);
return $this->sendRequest(
'GET',
$resourcePath,
$queryParams,
$httpBody
);
}

/**
Expand Down Expand Up @@ -265,7 +294,12 @@ public function getABTest($id)
);
}

return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody);
return $this->sendRequest(
'GET',
$resourcePath,
$queryParams,
$httpBody
);
}

/**
Expand Down Expand Up @@ -302,7 +336,12 @@ public function listABTests($offset = 0, $limit = 10)
}
}

return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody);
return $this->sendRequest(
'GET',
$resourcePath,
$queryParams,
$httpBody
);
}

/**
Expand Down Expand Up @@ -339,18 +378,19 @@ public function post($path, $parameters = null, $body = null)

// path params
if ($path !== null) {
$resourcePath = str_replace(
'{path}',
$path,
$resourcePath
);
$resourcePath = str_replace('{path}', $path, $resourcePath);
}

if (isset($body)) {
$httpBody = $body;
}

return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody);
return $this->sendRequest(
'POST',
$resourcePath,
$queryParams,
$httpBody
);
}

/**
Expand Down Expand Up @@ -387,18 +427,19 @@ public function put($path, $parameters = null, $body = null)

// path params
if ($path !== null) {
$resourcePath = str_replace(
'{path}',
$path,
$resourcePath
);
$resourcePath = str_replace('{path}', $path, $resourcePath);
}

if (isset($body)) {
$httpBody = $body;
}

return $this->sendRequest('PUT', $resourcePath, $queryParams, $httpBody);
return $this->sendRequest(
'PUT',
$resourcePath,
$queryParams,
$httpBody
);
}

/**
Expand Down Expand Up @@ -430,14 +471,23 @@ public function stopABTest($id)
);
}

return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody);
return $this->sendRequest(
'POST',
$resourcePath,
$queryParams,
$httpBody
);
}

private function sendRequest($method, $resourcePath, $queryParams, $httpBody)
{
private function sendRequest(
$method,
$resourcePath,
$queryParams,
$httpBody
) {
$query = \GuzzleHttp\Psr7\Query::build($queryParams);

if ($method === 'GET') {
if ($method == 'GET') {
$request = $this->api->read(
$method,
$resourcePath . ($query ? "?{$query}" : '')
Expand Down
Loading

0 comments on commit f387277

Please sign in to comment.