forked from typesense/typesense-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalyticsRules.php
More file actions
70 lines (59 loc) · 1.47 KB
/
AnalyticsRules.php
File metadata and controls
70 lines (59 loc) · 1.47 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
67
68
69
70
<?php
namespace Typesense;
class AnalyticsRules implements \ArrayAccess
{
const RESOURCE_PATH = '/analytics/rules';
private ApiCall $apiCall;
public function __construct(ApiCall $apiCall)
{
$this->apiCall = $apiCall;
}
/**
* Create multiple analytics rules
*
* @param array $rules Array of rule objects
* @return array Response from the API
*/
public function create(array $rules)
{
return $this->apiCall->post(self::RESOURCE_PATH, $rules);
}
/**
* Retrieve all analytics rules
*
* @return array Response from the API
*/
public function retrieve()
{
return $this->apiCall->get(self::RESOURCE_PATH, []);
}
/**
* Get a specific rule by name
*
* @param string $ruleName
* @return AnalyticsRule
*/
public function __get($ruleName)
{
return new AnalyticsRule($ruleName, $this->apiCall);
}
/**
* ArrayAccess implementation for backwards compatibility
*/
public function offsetExists($offset): bool
{
return true; // Rules can be accessed by name
}
public function offsetGet($offset): AnalyticsRule
{
return new AnalyticsRule($offset, $this->apiCall);
}
public function offsetSet($offset, $value): void
{
// Not implemented for read-only access
}
public function offsetUnset($offset): void
{
// Not implemented for read-only access
}
}