From 292db7e79503c88f2943c936bab009902ce0592f Mon Sep 17 00:00:00 2001 From: haakony Date: Mon, 26 Feb 2024 12:35:39 +0100 Subject: [PATCH] Adding count functionality to search --- src/Zendesk/API/Resources/Core/Search.php | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/Zendesk/API/Resources/Core/Search.php b/src/Zendesk/API/Resources/Core/Search.php index a94bad1c..ba23df11 100644 --- a/src/Zendesk/API/Resources/Core/Search.php +++ b/src/Zendesk/API/Resources/Core/Search.php @@ -18,6 +18,7 @@ protected function setUpRoutes() $this->setRoutes( [ 'find' => 'search.json', + 'count' => 'search/count.json', 'anonymous' => 'portal/search.json' ] ); @@ -64,4 +65,30 @@ public function anonymous($query, $queryParams = []) return $this->client->get($this->getRoute(__FUNCTION__), $queryParams); } + + + /** + * + * The search/count API is a unified search API that returns count of tickets, users, and organizations. You can define filters to + * narrow your search results according to resource type, dates, and object properties, such as ticket requester or + * tag. + * + * @param null $query + * @param array $queryParams + * + * @return \stdClass | null + * @throws MissingParametersException + * @throws \Zendesk\API\Exceptions\RouteException + */ + public function count($query = null, array $queryParams = []) + { + if (empty($query)) { + throw new MissingParametersException(__METHOD__, ['query']); + } + + $queryParams['query'] = $query; + + return $this->client->get($this->getRoute(__FUNCTION__), $queryParams); + } + }