Merge pull request #2 from antharuu/master

allow to manually define the auth token for client and settings
This commit is contained in:
Jonathan Martz
2025-01-21 22:18:40 +01:00
committed by GitHub
3 changed files with 14 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ namespace Pb;
class Client
{
private string $url;
private string $token = '';
public function __construct(string $url)
{
@@ -13,11 +14,16 @@ class Client
public function collection(string $collection): Collection
{
return new Collection($this->url ,$collection);
return new Collection($this->url ,$collection, $this->token);
}
public function settings(): Settings
{
return new Settings($this->url);
return new Settings($this->url, $this->token);
}
public function setAuthToken(string $token): void
{
$this->token = $token;
}
}

View File

@@ -25,11 +25,13 @@ class Collection
/**
* @param string $url
* @param string $collection
* @param string $token
*/
public function __construct(string $url, string $collection)
public function __construct(string $url, string $collection, string $token)
{
$this->url = $url;
$this->collection = $collection;
self::$token = $token;
}
/**

View File

@@ -19,11 +19,12 @@ class Settings
/**
* @param string $url
* @param string $collection
* @param string $token
*/
public function __construct(string $url)
public function __construct(string $url, string $token)
{
$this->url = $url;
self::$token = $token;
}
public function authAsAdmin(string $email, string $password): void