Метод KktMonitor::auth() перенесён в AtolClient для совместимости в фискализатором

pull/10/head
Anthony Axenov 2021-11-21 00:15:59 +08:00
parent b35b9bfa87
commit e89369348a
2 changed files with 12 additions and 17 deletions

View File

@ -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 для запроса авторизации

View File

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