mirror of
https://github.com/jonathan-martz/pocketbase-php-sdk.git
synced 2026-04-03 07:27:42 +00:00
Merge pull request #2 from antharuu/master
allow to manually define the auth token for client and settings
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user