forked from typesense/typesense-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalyticsEventsV1.php
More file actions
54 lines (48 loc) · 1.1 KB
/
Copy pathAnalyticsEventsV1.php
File metadata and controls
54 lines (48 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace Typesense;
/**
* Class AnalyticsEventsV1
*
* @package \Typesense
*/
class AnalyticsEventsV1
{
const RESOURCE_PATH = '/analytics/events';
/**
* @var ApiCall
*/
private ApiCall $apiCall;
/**
* AnalyticsEventsV1 constructor.
*
* @param ApiCall $apiCall
*/
public function __construct(ApiCall $apiCall)
{
$this->apiCall = $apiCall;
}
/**
* Submit a legacy v1 analytics event.
*
* @example
* $client->analyticsV1->events()->create(['type' => 'click', 'name' => 'products_click', 'data' => []])
*
* @see https://typesense.org/docs/29.0/api/analytics-query-suggestions.html
*
* @param array $params
*
* @return array
* @throws TypesenseClientError|HttpClientException
*/
public function create($params)
{
return $this->apiCall->post($this->endpoint_path(), $params);
}
/**
* @return string
*/
private function endpoint_path($operation = null)
{
return self::RESOURCE_PATH . ($operation === null ? '' : "/$operation");
}
}