From 6a93d31375dd7e75ff9264f3024f2208ce602f49 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sat, 16 Nov 2024 16:03:42 +0000 Subject: [PATCH] Return null instead of throwing an exception on error 401. --- VERSION | 2 +- src/V1/V1Client.php | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 0ea3a94..0c62199 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.2.0 +0.2.1 diff --git a/src/V1/V1Client.php b/src/V1/V1Client.php index 08e2609..38dc86a 100644 --- a/src/V1/V1Client.php +++ b/src/V1/V1Client.php @@ -31,10 +31,13 @@ class V1Client { * * @todo Currently there's no format for apps on the server side. * @throws RuntimeException If there is no authenticated entity. - * @return V1User + * @return ?V1User */ - public function me(): V1User { + public function me(): ?V1User { $response = $this->httpClient->request('GET', $this->urls->getApiUrl('/v1/me')); + if($response->getStatusCode() === 401) + return null; + $response->ensureSuccessStatusCode(); $me = $response->getJsonBody();