diff --git a/src/Client.php b/src/Client.php index 388fb53..350fbc8 100644 --- a/src/Client.php +++ b/src/Client.php @@ -4,15 +4,16 @@ use GuzzleHttp\Client as HttpClient; -class Client { - +class Client +{ private $answersApiBaseURL; private $apiKey; private $endpoint; private $http; private $collector; - public function __construct($endpoint, $apiKey, $answersApiBaseURL = null) { + public function __construct($endpoint, $apiKey, $answersApiBaseURL = null) + { $this->apiKey = $apiKey; $this->endpoint = $endpoint; $this->answersApiBaseURL = $answersApiBaseURL; @@ -20,9 +21,10 @@ public function __construct($endpoint, $apiKey, $answersApiBaseURL = null) { $this->http = new HttpClient(); } - public function search(Query $query) { + public function search(Query $query) + { $endpoint = "{$this->endpoint}/search?api-key={$this->apiKey}"; - + $response = $this->http->request('POST', $endpoint, [ 'form_params' => [ 'q' => $query->toJson() diff --git a/src/Endpoints.php b/src/Endpoints.php deleted file mode 100644 index 3fc5ced..0000000 --- a/src/Endpoints.php +++ /dev/null @@ -1,17 +0,0 @@ -search( (new Query()) ->term('red shoes') ->mode('fulltext') ->limit(10) ); - + $this->assertArrayHasKey('hits', $result); $this->assertArrayHasKey('elapsed', $result); $this->assertArrayHasKey('count', $result); - + $this->assertTrue($result['count'] > 0); + $this->assertTrue(sizeof($result['hits']) <= 10); });