-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathAnalyticsRule.php
More file actions
66 lines (59 loc) · 1.67 KB
/
Copy pathAnalyticsRule.php
File metadata and controls
66 lines (59 loc) · 1.67 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
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace Typesense;
class AnalyticsRule
{
private string $ruleName;
private ApiCall $apiCall;
public function __construct(string $ruleName, ApiCall $apiCall)
{
$this->ruleName = $ruleName;
$this->apiCall = $apiCall;
}
/**
* Retrieve the details of an analytics rule, given its name.
*
* @example
* $client->analytics->rules()['rule-1']->retrieve()
*
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
*
* @return array Response from the API
*/
public function retrieve()
{
return $this->apiCall->get($this->endpointPath(), []);
}
/**
* Permanently deletes an analytics rule, given its name.
*
* @example
* $client->analytics->rules()['rule-1']->delete()
*
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
*
* @return array Response from the API
*/
public function delete()
{
return $this->apiCall->delete($this->endpointPath());
}
/**
* Upserts an analytics rule with the given name.
*
* @example
* $client->analytics->rules()['rule-1']->update(['type' => 'popular_queries', 'params' => []])
*
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
*
* @param array $params Rule parameters
* @return array Response from the API
*/
public function update(array $params)
{
return $this->apiCall->put($this->endpointPath(), $params);
}
private function endpointPath()
{
return AnalyticsRules::RESOURCE_PATH . '/' . encodeURIComponent($this->ruleName);
}
}