From e89369348a13e0f7814bf5accd42a07c38e67b62 Mon Sep 17 00:00:00 2001 From: AnthonyAxenov Date: Sun, 21 Nov 2021 00:15:59 +0800 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=B5=D1=82=D0=BE=D0=B4=20KktMonitor::au?= =?UTF-8?q?th()=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=B5=D1=81=D1=91=D0=BD?= =?UTF-8?q?=20=D0=B2=20AtolClient=20=D0=B4=D0=BB=D1=8F=20=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=B8=D0=BC=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B8=20=D0=B2=20=D1=84=D0=B8=D1=81=D0=BA=D0=B0=D0=BB=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=82=D0=BE=D1=80=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Api/AtolClient.php | 14 ++++++++++++-- src/Api/KktMonitor.php | 15 --------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/Api/AtolClient.php b/src/Api/AtolClient.php index 213e790..51254e1 100644 --- a/src/Api/AtolClient.php +++ b/src/Api/AtolClient.php @@ -121,7 +121,7 @@ abstract class AtolClient * @param string|null $token * @return $this */ - public function setToken(?string $token): AtolClient + public function setToken(?string $token): self { $this->token = $token; return $this; @@ -283,7 +283,17 @@ abstract class AtolClient * @throws TooLongPasswordException * @throws GuzzleException */ - abstract public function auth(?string $login = null, ?string $password = null): bool; + public function auth(?string $login = null, ?string $password = null): bool + { + if (empty($this->getToken())) { + $login && $this->setLogin($login); + $password && $this->setPassword($password); + if ($token = $this->doAuth()) { + $this->setToken($token); + } + } + return !empty($this->getToken()); + } /** * Возвращает URL для запроса авторизации diff --git a/src/Api/KktMonitor.php b/src/Api/KktMonitor.php index f1fb41e..037af92 100644 --- a/src/Api/KktMonitor.php +++ b/src/Api/KktMonitor.php @@ -44,21 +44,6 @@ class KktMonitor extends AtolClient : 'https://online.atol.ru/api/kkt/v1'; } - /** - * @inheritDoc - */ - public function auth(?string $login = null, ?string $password = null): bool - { - if (empty($this->getToken())) { - $login && $this->setLogin($login); - $password && $this->setPassword($password); - if ($token = $this->doAuth()) { - $this->setToken($token); - } - } - return !empty($this->getToken()); - } - /** * Получает от API информацию обо всех ККТ и ФН в рамках группы *