Skip to content

Commit

Permalink
feat: pass instance id and sdk version
Browse files Browse the repository at this point in the history
  • Loading branch information
faustoq committed Jul 12, 2024
1 parent 57b8383 commit 01a1a38
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Client
private $http;
private $id;
private $collector;
private $headers;

public function __construct(array $params, HttpClient $http = null)
{
Expand All @@ -30,14 +31,21 @@ public function __construct(array $params, HttpClient $http = null)
$this->http = !is_null($http) ? $http : new HttpClient();
$this->apiKey = $params['api_key'];
$this->endpoint = $params['endpoint'];

$this->headers = (isset($_SERVER['HTTP_USER_AGENT'])) ? [
'User-Agent' => $_SERVER['HTTP_USER_AGENT']
] : [];
}

public function search(Query $query)
{
$endpoint = "{$this->endpoint}/search?api-key={$this->apiKey}";
$response = $this->http->request('POST', $endpoint, [
'headers' => $this->headers,
'form_params' => [
'q' => $query->toJson()
'q' => $query->toJson(),
'version' => 'php 1.0.0',
'id' => $this->id
]
]);

Expand Down
2 changes: 1 addition & 1 deletion src/Traits/GeneratesUniqueId.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ trait GeneratesUniqueId
{
public function generateUniqueId($prefix = '')
{
return substr(str_replace('.', '', uniqid($prefix, true) . str_shuffle('abcdefghjkmnpqrstvwxyz0123456789')), 0, 24);
return substr(str_replace('.', '', uniqid($prefix, true) . str_shuffle('abcdefghjklmnopqrstuvwxyz0123456789')), 0, 24);
}
}

0 comments on commit 01a1a38

Please sign in to comment.