Skip to content

Commit f5be49d

Browse files
Merge pull request #122 from tharropoulos/phpdocs
docs: add phpdoc summaries, examples, and docs links to resource classes
2 parents b1e3e73 + 46478cb commit f5be49d

46 files changed

Lines changed: 943 additions & 16 deletions

Some content is hidden

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

‎src/Alias.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ public function endPointPath(): string
4545
}
4646

4747
/**
48+
* Find out which collection an alias points to by fetching it.
49+
*
50+
* @example
51+
* $client->aliases['my-alias']->retrieve()
52+
*
53+
* @see https://typesense.org/docs/latest/api/collection-alias.html#retrieve-an-alias
54+
*
4855
* @return array
4956
* @throws TypesenseClientError|HttpClientException
5057
*/
@@ -54,6 +61,13 @@ public function retrieve(): array
5461
}
5562

5663
/**
64+
* Delete an alias.
65+
*
66+
* @example
67+
* $client->aliases['my-alias']->delete()
68+
*
69+
* @see https://typesense.org/docs/latest/api/collection-alias.html#delete-an-alias
70+
*
5771
* @return array
5872
* @throws TypesenseClientError|HttpClientException
5973
*/

‎src/Aliases.php‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ public function endPointPath(string $aliasName): string
4747
}
4848

4949
/**
50+
* Create or update an alias mapping for a collection.
51+
*
52+
* @example
53+
* $client->aliases->upsert('my-alias', ['collection_name' => 'products'])
54+
*
55+
* @see https://typesense.org/docs/latest/api/collection-alias.html#upsert-an-alias
56+
*
5057
* @param string $name
5158
* @param array $mapping
5259
*
@@ -59,6 +66,13 @@ public function upsert(string $name, array $mapping): array
5966
}
6067

6168
/**
69+
* List all aliases and the collections they map to.
70+
*
71+
* @example
72+
* $client->aliases->retrieve()
73+
*
74+
* @see https://typesense.org/docs/latest/api/collection-alias.html#list-all-aliases
75+
*
6276
* @return array
6377
* @throws TypesenseClientError|HttpClientException
6478
*/

‎src/Analytics.php‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,17 @@ public function __construct(ApiCall $apiCall)
1717
$this->apiCall = $apiCall;
1818
}
1919

20+
/**
21+
* Access the analytics rules resource. Use as a method-style endpoint to list or create rules,
22+
* or chain `[$id]` on the returned object to access a single rule.
23+
*
24+
* @example
25+
* $client->analytics->rules()->retrieve()
26+
* @example
27+
* $client->analytics->rules()['rule-1']->retrieve()
28+
*
29+
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
30+
*/
2031
public function rules()
2132
{
2233
if (!isset($this->rules)) {
@@ -25,6 +36,14 @@ public function rules()
2536
return $this->rules;
2637
}
2738

39+
/**
40+
* Access the analytics events resource to send analytics events.
41+
*
42+
* @example
43+
* $client->analytics->events()->create(['type' => 'click', 'name' => 'products_click', 'data' => []])
44+
*
45+
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
46+
*/
2847
public function events()
2948
{
3049
if (!isset($this->events)) {

‎src/AnalyticsEvents.php‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ public function __construct(ApiCall $apiCall)
2929
}
3030

3131
/**
32-
* Create an analytics event
33-
*
32+
* Submit a single analytics event. The event must correspond to an existing analytics rule by name.
33+
*
34+
* @example
35+
* $client->analytics->events()->create(['type' => 'click', 'name' => 'products_click', 'data' => []])
36+
*
37+
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
38+
*
3439
* @param array $params Event parameters including name, event_type, and data
3540
* @return array Response from the API
3641
* @throws TypesenseClientError|HttpClientException
@@ -41,8 +46,13 @@ public function create(array $params)
4146
}
4247

4348
/**
44-
* Retrieve analytics events
45-
*
49+
* Retrieve the most recent events for a user and rule.
50+
*
51+
* @example
52+
* $client->analytics->events()->retrieve(['user_id' => 'u1', 'name' => 'products_click', 'n' => 10])
53+
*
54+
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
55+
*
4656
* @param array $params Query parameters
4757
* @return array Response from the API
4858
*/

‎src/AnalyticsEventsV1.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ public function __construct(ApiCall $apiCall)
2727
}
2828

2929
/**
30+
* Submit a legacy v1 analytics event.
31+
*
32+
* @example
33+
* $client->analyticsV1->events()->create(['type' => 'click', 'name' => 'products_click', 'data' => []])
34+
*
35+
* @see https://typesense.org/docs/29.0/api/analytics-query-suggestions.html
36+
*
3037
* @param array $params
3138
*
3239
* @return array

‎src/AnalyticsRule.php‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@ public function __construct(string $ruleName, ApiCall $apiCall)
1414
}
1515

1616
/**
17-
* Retrieve a specific analytics rule
18-
*
17+
* Retrieve the details of an analytics rule, given its name.
18+
*
19+
* @example
20+
* $client->analytics->rules()['rule-1']->retrieve()
21+
*
22+
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
23+
*
1924
* @return array Response from the API
2025
*/
2126
public function retrieve()
@@ -24,8 +29,13 @@ public function retrieve()
2429
}
2530

2631
/**
27-
* Delete a specific analytics rule
28-
*
32+
* Permanently deletes an analytics rule, given its name.
33+
*
34+
* @example
35+
* $client->analytics->rules()['rule-1']->delete()
36+
*
37+
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
38+
*
2939
* @return array Response from the API
3040
*/
3141
public function delete()
@@ -34,8 +44,13 @@ public function delete()
3444
}
3545

3646
/**
37-
* Update a specific analytics rule
38-
*
47+
* Upserts an analytics rule with the given name.
48+
*
49+
* @example
50+
* $client->analytics->rules()['rule-1']->update(['type' => 'popular_queries', 'params' => []])
51+
*
52+
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
53+
*
3954
* @param array $params Rule parameters
4055
* @return array Response from the API
4156
*/

‎src/AnalyticsRuleV1.php‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,27 @@ public function __construct(string $ruleName, ApiCall $apiCall)
1313
$this->apiCall = $apiCall;
1414
}
1515

16+
/**
17+
* Retrieve a legacy v1 analytics rule by name.
18+
*
19+
* @example
20+
* $client->analyticsV1->rules()['rule-1']->retrieve()
21+
*
22+
* @see https://typesense.org/docs/29.0/api/analytics-query-suggestions.html
23+
*/
1624
public function retrieve()
1725
{
1826
return $this->apiCall->get($this->endpointPath(), []);
1927
}
2028

29+
/**
30+
* Delete a legacy v1 analytics rule by name.
31+
*
32+
* @example
33+
* $client->analyticsV1->rules()['rule-1']->delete()
34+
*
35+
* @see https://typesense.org/docs/29.0/api/analytics-query-suggestions.html
36+
*/
2137
public function delete()
2238
{
2339
return $this->apiCall->delete($this->endpointPath());

‎src/AnalyticsRules.php‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@ public function __construct(ApiCall $apiCall)
1919
}
2020

2121
/**
22-
* Create multiple analytics rules
23-
*
22+
* Create one or more analytics rules. You can send a single rule object or an array of rule objects.
23+
*
24+
* @example
25+
* $client->analytics->rules()->create(['name' => 'products_query_hits', 'type' => 'popular_queries', 'params' => []])
26+
*
27+
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
28+
*
2429
* @param array $rules Array of rule objects
2530
* @return array Response from the API
2631
*/
@@ -30,8 +35,13 @@ public function create(array $rules)
3035
}
3136

3237
/**
33-
* Retrieve all analytics rules
34-
*
38+
* Retrieve all analytics rules.
39+
*
40+
* @example
41+
* $client->analytics->rules()->retrieve()
42+
*
43+
* @see https://typesense.org/docs/latest/api/analytics-query-suggestions.html
44+
*
3545
* @return array Response from the API
3646
*/
3747
public function retrieve()

‎src/AnalyticsRulesV1.php‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,27 @@ public function __get($ruleName)
2222
return $this->analyticsRules[$ruleName];
2323
}
2424

25+
/**
26+
* Upsert a legacy v1 analytics rule by name.
27+
*
28+
* @example
29+
* $client->analyticsV1->rules()->upsert('products_query_hits', ['type' => 'popular_queries', 'params' => []])
30+
*
31+
* @see https://typesense.org/docs/29.0/api/analytics-query-suggestions.html
32+
*/
2533
public function upsert($ruleName, $params)
2634
{
2735
return $this->apiCall->put($this->endpoint_path($ruleName), $params);
2836
}
2937

38+
/**
39+
* Retrieve all legacy v1 analytics rules.
40+
*
41+
* @example
42+
* $client->analyticsV1->rules()->retrieve()
43+
*
44+
* @see https://typesense.org/docs/29.0/api/analytics-query-suggestions.html
45+
*/
3046
public function retrieve()
3147
{
3248
return $this->apiCall->get($this->endpoint_path(), []);

‎src/AnalyticsV1.php‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Typesense;
44

5+
/**
6+
* @deprecated Deprecated starting with Typesense Server v30. Please migrate to `$client->analytics` (new Analytics APIs).
7+
*/
58
class AnalyticsV1
69
{
710
const RESOURCE_PATH = '/analytics';
@@ -17,6 +20,19 @@ public function __construct(ApiCall $apiCall)
1720
$this->apiCall = $apiCall;
1821
}
1922

23+
/**
24+
* Access the legacy v1 analytics rules resource. Use as a method-style endpoint to list or upsert rules,
25+
* or chain `[$id]` on the returned object to access a single rule.
26+
*
27+
* @example
28+
* $client->analyticsV1->rules()->retrieve()
29+
* @example
30+
* $client->analyticsV1->rules()['rule-1']->retrieve()
31+
*
32+
* @see https://typesense.org/docs/29.0/api/analytics-query-suggestions.html
33+
*
34+
* @deprecated Deprecated starting with Typesense Server v30. Please migrate to `$client->analytics` (new Analytics APIs).
35+
*/
2036
public function rules()
2137
{
2238
if (!isset($this->rules)) {
@@ -25,6 +41,16 @@ public function rules()
2541
return $this->rules;
2642
}
2743

44+
/**
45+
* Access the legacy v1 analytics events resource to send analytics events.
46+
*
47+
* @example
48+
* $client->analyticsV1->events()->create(['type' => 'click', 'name' => 'products_click', 'data' => []])
49+
*
50+
* @see https://typesense.org/docs/29.0/api/analytics-query-suggestions.html
51+
*
52+
* @deprecated Deprecated starting with Typesense Server v30. Please migrate to `$client->analytics` (new Analytics APIs).
53+
*/
2854
public function events()
2955
{
3056
if (!isset($this->events)) {

0 commit comments

Comments
 (0)