From 69d7b18a44a08976008f5c57def89315d9287d28 Mon Sep 17 00:00:00 2001 From: ging-dev Date: Tue, 9 Jul 2024 10:47:13 +0700 Subject: [PATCH] feat(misc): minor change --- src/Api/UnauthenticatedApi.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Api/UnauthenticatedApi.php b/src/Api/UnauthenticatedApi.php index 9e58d0f..2e0c85e 100644 --- a/src/Api/UnauthenticatedApi.php +++ b/src/Api/UnauthenticatedApi.php @@ -29,11 +29,7 @@ public function login(array $credentials): AuthenticatedApi ->setAllowedTypes('accessCode', 'string') ; - [$captchaId, $captchaCode] = $this->bypassCaptcha(); - - $parameters = $resolver->resolve($credentials); - $parameters['captchaId'] = $captchaId; - $parameters['captchaCode'] = $captchaCode; + $parameters = $resolver->resolve($credentials) + $this->bypassCaptcha(); /** @var array{sessionId: string, ...} */ $result = $this->post('signIn', $parameters); @@ -45,7 +41,7 @@ public function login(array $credentials): AuthenticatedApi } /** - * @return array{string,string} + * @return array{captchaId:string,captchaCode:string} */ private function bypassCaptcha(): array { @@ -53,7 +49,8 @@ private function bypassCaptcha(): array $svg = (string) $this->iPayClient->getClient() ->get(sprintf('api/get-captcha/%s', $captchaId)) ->getBody(); + $captchaCode = CaptchaSolver::solve($svg); - return [$captchaId, CaptchaSolver::solve($svg)]; + return compact('captchaId', 'captchaCode'); } }