From 5417db81f004d90bc181aa184c54841feb27eaaf Mon Sep 17 00:00:00 2001 From: Joseph Date: Sun, 21 Apr 2024 15:49:22 +0100 Subject: [PATCH 1/4] Update client.md --- docs/classes/client.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/classes/client.md b/docs/classes/client.md index d05f7fa..cb90d8e 100644 --- a/docs/classes/client.md +++ b/docs/classes/client.md @@ -3,7 +3,7 @@ Class for sending requests to a Ntfy server. ```PHP -Ntfy\Client(Server $server, ?Auth $auth = null) +Ntfy\Client(Server $server, ?AbstractAuth $auth = null) ``` ### Examples From cabc356da5bcf5ef98377ae1696e832dbffa7d3c Mon Sep 17 00:00:00 2001 From: Joseph Date: Sun, 21 Apr 2024 16:05:56 +0100 Subject: [PATCH 2/4] Update client.md --- docs/classes/client.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/classes/client.md b/docs/classes/client.md index cb90d8e..cd9f7f5 100644 --- a/docs/classes/client.md +++ b/docs/classes/client.md @@ -3,7 +3,7 @@ Class for sending requests to a Ntfy server. ```PHP -Ntfy\Client(Server $server, ?AbstractAuth $auth = null) +Ntfy\Client(Server $server, User|Token $auth = null) ``` ### Examples From d56d0f748a4b015ec1e6fe28d1a58b5cf9c01308 Mon Sep 17 00:00:00 2001 From: Joseph Date: Sun, 21 Apr 2024 16:06:04 +0100 Subject: [PATCH 3/4] Update Client.php --- src/Client.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Client.php b/src/Client.php index 4bb0fac..e7417b4 100644 --- a/src/Client.php +++ b/src/Client.php @@ -3,7 +3,8 @@ namespace Ntfy; use stdClass; -use Ntfy\Auth\AbstractAuth; +use Ntfy\Auth\User; +use Ntfy\Auth\Token; use Ntfy\Exception\NtfyException; class Client @@ -13,9 +14,9 @@ class Client /** * @param Server $server Server URI - * @param ?AbstractAuth $auth Authentication class instance + * @param User|Token $auth Authentication class instance */ - public function __construct(Server $server, ?AbstractAuth $auth = null) + public function __construct(Server $server, User|Token $auth = null) { $this->guzzle = new Guzzle( $server->get(), From e2c676fe945bdc75d67db9fd44e98c70eee66e3f Mon Sep 17 00:00:00 2001 From: Joseph Date: Sun, 21 Apr 2024 16:06:15 +0100 Subject: [PATCH 4/4] Update Guzzle.php --- src/Guzzle.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Guzzle.php b/src/Guzzle.php index f24aa05..cdc42cf 100644 --- a/src/Guzzle.php +++ b/src/Guzzle.php @@ -2,7 +2,8 @@ namespace Ntfy; -use Ntfy\Auth\AbstractAuth; +use Ntfy\Auth\User; +use Ntfy\Auth\Token; use GuzzleHttp\Client; use GuzzleHttp\RequestOptions; use GuzzleHttp\HandlerStack; @@ -28,10 +29,10 @@ class Guzzle /** * * @param string $uri Server URI - * @param ?AbstractAuth $auth Authentication class instance + * @param User|Token $auth Authentication class instance * @param ?HandlerStack $handlerStack Guzzle handler stack */ - public function __construct(string $uri, ?AbstractAuth $auth, ?HandlerStack $handlerStack = null) + public function __construct(string $uri, User|Token $auth = null, ?HandlerStack $handlerStack = null) { $config = $this->getConfig($uri, $auth, $handlerStack); $this->client = new Client($config); @@ -122,11 +123,11 @@ protected function request(string $method, string $endpoint, array $options = [] * Get GuzzleHttp client config * * @param string $uri Server URI - * @param ?AbstractAuth $auth Authentication class instance + * @param User|Token $auth Authentication class instance * @param ?HandlerStack $handlerStack Guzzle handler stack * @return array Returns client config array */ - private function getConfig(string $uri, ?AbstractAuth $auth, ?HandlerStack $handlerStack): array + private function getConfig(string $uri, User|Token $auth = null, ?HandlerStack $handlerStack = null): array { $config = [ 'base_uri' => $uri, @@ -150,10 +151,10 @@ private function getConfig(string $uri, ?AbstractAuth $auth, ?HandlerStack $hand /** * Get authentication config * - * @param ?AbstractAuth $auth Authentication class instance + * @param User|Token $auth Authentication class instance * @return array> */ - private function getAuthConfig(?AbstractAuth $auth): array + private function getAuthConfig(User|Token|null $auth): array { $config = [];