allow to manually define the auth token for client and settings

This commit is contained in:
Anthony Bellancourt
2025-01-21 17:21:53 +01:00
parent 7c2253c896
commit 9b1ded7968
3 changed files with 14 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ namespace Pb;
class Client class Client
{ {
private string $url; private string $url;
private string $token = '';
public function __construct(string $url) public function __construct(string $url)
{ {
@@ -13,11 +14,16 @@ class Client
public function collection(string $collection): Collection public function collection(string $collection): Collection
{ {
return new Collection($this->url ,$collection); return new Collection($this->url ,$collection, $this->token);
} }
public function settings(): Settings 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 $url
* @param string $collection * @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->url = $url;
$this->collection = $collection; $this->collection = $collection;
self::$token = $token;
} }
/** /**

View File

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