Skip to content

Commit

Permalink
Fix api endpoint URL
Browse files Browse the repository at this point in the history
  • Loading branch information
Joppe de Cuyper committed Apr 9, 2023
1 parent 60cd90f commit 44bcec2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

class Client
{
public const API_URL = 'https://api.logsnag.com/v1';

use HandlesLog;
use HandlesInsight;

Expand All @@ -24,14 +26,13 @@ class Client
private Insight $insight;

public function __construct(
string $url,
string $apiKey = null,
ClientInterface $httpClient = null,
RequestFactoryInterface $requestFactory = null,
array $clientAgents = [],
StreamFactoryInterface $streamFactory = null
) {
$this->http = new LogSnagClient($url, $apiKey, $httpClient, $requestFactory, $clientAgents, $streamFactory);
$this->http = new LogSnagClient(self::API_URL, $apiKey, $httpClient, $requestFactory, $clientAgents, $streamFactory);

$this->log = new Log($this->http);
$this->insight = new Insight($this->http);
Expand Down
5 changes: 3 additions & 2 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@

use JoppeDc\LogsnagPhpSdk\Client;
use JoppeDc\LogsnagPhpSdk\Contracts\LogPayload;
use JoppeDc\LogsnagPhpSdk\Exceptions\ApiException;
use JoppeDc\LogsnagPhpSdk\Exceptions\CommunicationException;
use PHPUnit\Framework\TestCase;

class ClientTest extends TestCase
{
public function testThrowCommunicationException(): void
{
$client = new Client('https://doesntexist:1234');
$client = new Client('testkey');

$this->expectException(CommunicationException::class);
$this->expectException(ApiException::class);
$client->createLog(new LogPayload('', '', ''));
}
}

0 comments on commit 44bcec2

Please sign in to comment.