From 5aeb35bab843c58729907c1d1cda1d8864d15cfb Mon Sep 17 00:00:00 2001 From: overtrue Date: Mon, 18 Jul 2022 21:53:40 +0800 Subject: [PATCH] =?UTF-8?q?hotfix:=20suiteTicket=20=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=BC=BA=E7=9C=81=E5=80=BC=20fixed=20#2542?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/OpenWork/SuiteAccessToken.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OpenWork/SuiteAccessToken.php b/src/OpenWork/SuiteAccessToken.php index c949964ef..a06b22cb2 100644 --- a/src/OpenWork/SuiteAccessToken.php +++ b/src/OpenWork/SuiteAccessToken.php @@ -26,13 +26,14 @@ class SuiteAccessToken implements RefreshableAccessTokenInterface public function __construct( protected string $suiteId, protected string $suiteSecret, - protected SuiteTicketInterface $suiteTicket, + protected ?SuiteTicketInterface $suiteTicket = null, protected ?string $key = null, ?CacheInterface $cache = null, ?HttpClientInterface $httpClient = null, ) { $this->httpClient = $httpClient ?? HttpClient::create(['base_uri' => 'https://qyapi.weixin.qq.com/']); $this->cache = $cache ?? new Psr16Cache(new FilesystemAdapter(namespace: 'easywechat', defaultLifetime: 1500)); + $this->suiteTicket ??= new SuiteTicket($this->suiteId, $this->cache); } public function getKey(): string @@ -98,7 +99,7 @@ public function refresh(): string 'json' => [ 'suite_id' => $this->suiteId, 'suite_secret' => $this->suiteSecret, - 'suite_ticket' => $this->suiteTicket->getTicket(), + 'suite_ticket' => $this->suiteTicket?->getTicket(), ], ])->toArray(false);