apiClient = new ApiClient($configuration); $this->searchAsset = new SearchAsset($configuration); } /** * Sets the Search API endpoint. * * @param string $endpoint The endpoint for the Search API. * * @return $this */ public function endpoint($endpoint) { $this->endpoint = $endpoint; return $this; } /** * Executes the search API request asynchronously. * * @return PromiseInterface * * @api */ public function executeAsync() { return $this->apiClient->postJsonAsync($this->getSearchEndpoint(), $this); } /** * Executes the search API request. * * @return ApiResponse * * @throws GeneralError * * @api */ public function execute() { return $this->executeAsync()->wait(); } /** * Creates a signed Search URL that can be used on the client side. * * @param int $ttl The time to live in seconds. * @param string $nextCursor Starting position. * * @return string The resulting search URL. */ public function toUrl($ttl = null, $nextCursor = null) { $this->searchAsset->query($this->asArray()); if ($ttl == null) { $ttl = $this->ttl; } return $this->searchAsset->toUrl($ttl, $nextCursor); } /** * Serializes to JSON. * * @return array data which can be serialized by json_encode */ #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->asArray(); } /** * Returns the search endpoint. * * @return string */ private function getSearchEndpoint() { return "{$this->endpoint}/search"; } }