Skip to content

Adding count functionality to search #528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions src/Zendesk/API/Resources/Core/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ protected function setUpRoutes()
$this->setRoutes(
[
'find' => 'search.json',
'count' => 'search/count.json',
'anonymous' => 'portal/search.json'
]
);
Expand Down Expand Up @@ -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);
}

}