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 информацию обо всех ККТ и ФН в рамках группы *