-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathOverride.php
More file actions
91 lines (82 loc) · 2.07 KB
/
Copy pathOverride.php
File metadata and controls
91 lines (82 loc) · 2.07 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace Typesense;
use Http\Client\Exception as HttpClientException;
use Typesense\Exceptions\TypesenseClientError;
/**
* Class Override
*
* @package \Typesense
* @date 4/5/20
* @author Abdullah Al-Faqeir <abdullah@devloops.net>
*/
class Override
{
/**
* @var string
*/
private string $collectionName;
/**
* @var string
*/
private string $overrideId;
/**
* @var ApiCall
*/
private ApiCall $apiCall;
/**
* Override constructor.
*
* @param string $collectionName
* @param string $overrideId
* @param ApiCall $apiCall
*/
public function __construct(string $collectionName, string $overrideId, ApiCall $apiCall)
{
$this->collectionName = $collectionName;
$this->overrideId = $overrideId;
$this->apiCall = $apiCall;
}
/**
* @return string
*/
private function endPointPath(): string
{
return sprintf(
'%s/%s/%s/%s',
Collections::RESOURCE_PATH,
encodeURIComponent($this->collectionName),
Overrides::RESOURCE_PATH,
encodeURIComponent($this->overrideId)
);
}
/**
* Retrieve an override (curation rule) by ID on this collection.
*
* @example
* $client->collections['products']->overrides['promote-hat']->retrieve()
*
* @see https://typesense.org/docs/latest/api/curation.html
*
* @return array
* @throws TypesenseClientError|HttpClientException
*/
public function retrieve(): array
{
return $this->apiCall->get($this->endPointPath(), []);
}
/**
* Delete an override (curation rule) by ID on this collection.
*
* @example
* $client->collections['products']->overrides['promote-hat']->delete()
*
* @see https://typesense.org/docs/latest/api/curation.html
*
* @return array
* @throws TypesenseClientError|HttpClientException
*/
public function delete(): array
{
return $this->apiCall->delete($this->endPointPath());
}
}