Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
faustoq committed Jul 4, 2024
1 parent a7f0e07 commit 7bf7609
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
12 changes: 7 additions & 5 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@

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;

$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()
Expand Down
17 changes: 0 additions & 17 deletions src/Endpoints.php

This file was deleted.

18 changes: 18 additions & 0 deletions src/Manager/Endpoints.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace OramaCloud\Manager;

class Endpoints
{
const WEBHOOKS_BASE_URL = 'https://api.askorama.ai/api/v1/webhooks';

const DEPLOY = self::WEBHOOKS_BASE_URL . '/[indexID]/deploy';

const EMPTY = self::WEBHOOKS_BASE_URL . '/[indexID]/empty';

const HAS_DATA = self::WEBHOOKS_BASE_URL . '/[indexID]/has-data';

const NOTIFY = self::WEBHOOKS_BASE_URL . '/[indexID]/notify';

const SNAPSHOT = self::WEBHOOKS_BASE_URL . '/[indexID]/snapshot';
}
7 changes: 4 additions & 3 deletions tests/Feature/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@

test('basic fulltext search', function () {
$client = new Client(API_ENDPOINT, PUBLIC_API_KEY);

$result = $client->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);
});

0 comments on commit 7bf7609

Please sign in to comment.