Skip to content

Commit 93439e7

Browse files
chore: generated code for commit 2b36ef0. [skip ci]
Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 2b36ef0 commit 93439e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1836
-1274
lines changed

clients/algoliasearch-client-php/lib/Api/InsightsClient.php

Lines changed: 65 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22

33
namespace Algolia\AlgoliaSearch\Api;
44

5+
use GuzzleHttp\Exception\RequestException;
6+
use GuzzleHttp\Exception\ConnectException;
7+
use GuzzleHttp\Psr7\MultipartStream;
8+
use GuzzleHttp\RequestOptions;
9+
use GuzzleHttp\Utils;
510
use Algolia\AlgoliaSearch\Algolia;
11+
use Algolia\AlgoliaSearch\ApiException;
612
use Algolia\AlgoliaSearch\Configuration\InsightsConfig;
13+
use Algolia\AlgoliaSearch\ObjectSerializer;
714
use Algolia\AlgoliaSearch\RetryStrategy\ApiWrapper;
815
use Algolia\AlgoliaSearch\RetryStrategy\ApiWrapperInterface;
916
use Algolia\AlgoliaSearch\RetryStrategy\ClusterHosts;
@@ -30,8 +37,10 @@ class InsightsClient
3037
* @param InsightsConfig $config
3138
* @param ApiWrapperInterface $apiWrapper
3239
*/
33-
public function __construct(ApiWrapperInterface $apiWrapper, InsightsConfig $config)
34-
{
40+
public function __construct(
41+
ApiWrapperInterface $apiWrapper,
42+
InsightsConfig $config
43+
) {
3544
$this->config = $config;
3645

3746
$this->api = $apiWrapper;
@@ -47,7 +56,12 @@ public function __construct(ApiWrapperInterface $apiWrapper, InsightsConfig $con
4756
public static function create($appId = null, $apiKey = null, $region = null)
4857
{
4958
$allowedRegions = explode('-', 'us-de');
50-
$config = InsightsConfig::create($appId, $apiKey, $region, $allowedRegions);
59+
$config = InsightsConfig::create(
60+
$appId,
61+
$apiKey,
62+
$region,
63+
$allowedRegions
64+
);
5165

5266
return static::createWithConfig($config);
5367
}
@@ -65,7 +79,9 @@ public static function createWithConfig(InsightsConfig $config)
6579
// If a list of hosts was passed, we ignore the cache
6680
$clusterHosts = ClusterHosts::create($hosts);
6781
} else {
68-
$clusterHosts = ClusterHosts::create('insights.'.$config->getRegion().'.algolia.io');
82+
$clusterHosts = ClusterHosts::create(
83+
'insights.' . $config->getRegion() . '.algolia.io'
84+
);
6985
}
7086

7187
$apiWrapper = new ApiWrapper(
@@ -118,14 +134,15 @@ public function del($path, $parameters = null)
118134

119135
// path params
120136
if ($path !== null) {
121-
$resourcePath = str_replace(
122-
'{path}',
123-
$path,
124-
$resourcePath
125-
);
137+
$resourcePath = str_replace('{path}', $path, $resourcePath);
126138
}
127139

128-
return $this->sendRequest('DELETE', $resourcePath, $queryParams, $httpBody);
140+
return $this->sendRequest(
141+
'DELETE',
142+
$resourcePath,
143+
$queryParams,
144+
$httpBody
145+
);
129146
}
130147

131148
/**
@@ -161,14 +178,15 @@ public function get($path, $parameters = null)
161178

162179
// path params
163180
if ($path !== null) {
164-
$resourcePath = str_replace(
165-
'{path}',
166-
$path,
167-
$resourcePath
168-
);
181+
$resourcePath = str_replace('{path}', $path, $resourcePath);
169182
}
170183

171-
return $this->sendRequest('GET', $resourcePath, $queryParams, $httpBody);
184+
return $this->sendRequest(
185+
'GET',
186+
$resourcePath,
187+
$queryParams,
188+
$httpBody
189+
);
172190
}
173191

174192
/**
@@ -205,34 +223,37 @@ public function post($path, $parameters = null, $body = null)
205223

206224
// path params
207225
if ($path !== null) {
208-
$resourcePath = str_replace(
209-
'{path}',
210-
$path,
211-
$resourcePath
212-
);
226+
$resourcePath = str_replace('{path}', $path, $resourcePath);
213227
}
214228

215229
if (isset($body)) {
216230
$httpBody = $body;
217231
}
218232

219-
return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody);
233+
return $this->sendRequest(
234+
'POST',
235+
$resourcePath,
236+
$queryParams,
237+
$httpBody
238+
);
220239
}
221240

222241
/**
223242
* Pushes an array of events.
224243
*
225244
* @param array $insightEvents insightEvents (required)
226245
* - $insightEvents['events'] => (array) Array of events sent. (required)
227-
*
228246
* @see \Algolia\AlgoliaSearch\Model\Insights\InsightEvents
229247
*
230248
* @return array<string, mixed>|\Algolia\AlgoliaSearch\Model\Insights\PushEventsResponse
231249
*/
232250
public function pushEvents($insightEvents)
233251
{
234252
// verify the required parameter 'insightEvents' is set
235-
if ($insightEvents === null || (is_array($insightEvents) && count($insightEvents) === 0)) {
253+
if (
254+
$insightEvents === null ||
255+
(is_array($insightEvents) && count($insightEvents) === 0)
256+
) {
236257
throw new \InvalidArgumentException(
237258
'Missing the required parameter $insightEvents when calling pushEvents'
238259
);
@@ -246,7 +267,12 @@ public function pushEvents($insightEvents)
246267
$httpBody = $insightEvents;
247268
}
248269

249-
return $this->sendRequest('POST', $resourcePath, $queryParams, $httpBody);
270+
return $this->sendRequest(
271+
'POST',
272+
$resourcePath,
273+
$queryParams,
274+
$httpBody
275+
);
250276
}
251277

252278
/**
@@ -283,25 +309,30 @@ public function put($path, $parameters = null, $body = null)
283309

284310
// path params
285311
if ($path !== null) {
286-
$resourcePath = str_replace(
287-
'{path}',
288-
$path,
289-
$resourcePath
290-
);
312+
$resourcePath = str_replace('{path}', $path, $resourcePath);
291313
}
292314

293315
if (isset($body)) {
294316
$httpBody = $body;
295317
}
296318

297-
return $this->sendRequest('PUT', $resourcePath, $queryParams, $httpBody);
319+
return $this->sendRequest(
320+
'PUT',
321+
$resourcePath,
322+
$queryParams,
323+
$httpBody
324+
);
298325
}
299326

300-
private function sendRequest($method, $resourcePath, $queryParams, $httpBody)
301-
{
327+
private function sendRequest(
328+
$method,
329+
$resourcePath,
330+
$queryParams,
331+
$httpBody
332+
) {
302333
$query = \GuzzleHttp\Psr7\Query::build($queryParams);
303334

304-
if ($method === 'GET') {
335+
if ($method == 'GET') {
305336
$request = $this->api->read(
306337
$method,
307338
$resourcePath . ($query ? "?{$query}" : '')

0 commit comments

Comments
 (0)