Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the defaultAuth() method instead of withTokenAuth() #19

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip
tools: composer:v2
coverage: none
coverage: xdebug

- name: Setup problem matchers
run: |
Expand All @@ -52,4 +52,4 @@ jobs:
run: composer show -D

- name: Execute tests
run: vendor/bin/pest --ci
run: vendor/bin/pest --ci --coverage
10 changes: 9 additions & 1 deletion src/Connectors/PlausibleConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Illuminate\Support\Facades\Cache;
use Saloon\CachePlugin\Traits\HasCaching;
use Saloon\Http\Auth\TokenAuthenticator;
use Saloon\Http\Connector;
use Saloon\CachePlugin\Contracts\Driver;
use Saloon\CachePlugin\Drivers\LaravelCacheDriver;
Expand All @@ -13,9 +14,16 @@ class PlausibleConnector extends Connector implements Cacheable
{
use HasCaching;

protected ?string $token;

public function __construct()
{
$this->withTokenAuth(token: config(key: 'plausible.api_key'));
$this->token = config(key: 'plausible.api_key');
}

protected function defaultAuth(): TokenAuthenticator
{
return new TokenAuthenticator($this->token);
}

public function resolveBaseUrl(): string
Expand Down
Loading