diff --git a/composer.json b/composer.json index 0a77f48..7513c3b 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "require": { "php": ">=7.1", "ext-curl": "*", - "guzzlehttp/guzzle": "~6.0", + "guzzle/guzzle": "~3.7", "jms/serializer-bundle": "~0.12", "symfony/validator": "2.8.*" }, diff --git a/composer.lock b/composer.lock index 23306eb..aab5db1 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "4a04eaf2c87d2a5efd3a17846d459114", + "content-hash": "ff17ded3eeddcaca1b29f17e298ed1d7", "packages": [ { "name": "doctrine/annotations", @@ -203,44 +203,70 @@ "time": "2014-09-09T13:34:57+00:00" }, { - "name": "guzzlehttp/guzzle", - "version": "6.3.3", + "name": "guzzle/guzzle", + "version": "v3.9.3", "source": { "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" + "url": "https://github.com/guzzle/guzzle3.git", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", - "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", "shasum": "" }, "require": { - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.4", - "php": ">=5.5" + "ext-curl": "*", + "php": ">=5.3.3", + "symfony/event-dispatcher": "~2.1" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-error-response": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" }, "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", - "psr/log": "^1.0" + "doctrine/cache": "~1.3", + "monolog/monolog": "~1.0", + "phpunit/phpunit": "3.7.*", + "psr/log": "~1.0", + "symfony/class-loader": "~2.1", + "zendframework/zend-cache": "2.*,<2.3", + "zendframework/zend-log": "2.*,<2.3" }, "suggest": { - "psr/log": "Required for using the Log middleware" + "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.3-dev" + "dev-master": "3.9-dev" } }, "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" + "psr-0": { + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" } }, "notification-url": "https://packagist.org/downloads/", @@ -252,9 +278,13 @@ "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" } ], - "description": "Guzzle is a PHP HTTP client library", + "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", "homepage": "http://guzzlephp.org/", "keywords": [ "client", @@ -265,123 +295,8 @@ "rest", "web service" ], - "time": "2018-04-22T15:46:56+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "v1.3.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "time": "2016-12-20T10:07:11+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "1.4.2", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "reference": "f5b8a8512e2b58b0071a7280e39f14f72e05d87c", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "request", - "response", - "stream", - "uri", - "url" - ], - "time": "2017-03-20T17:10:46+00:00" + "abandoned": "guzzlehttp/guzzle", + "time": "2015-03-18T18:23:50+00:00" }, { "name": "ircmaxell/password-compat", @@ -798,56 +713,6 @@ ], "time": "2015-07-25T16:39:46+00:00" }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06T14:39:51+00:00" - }, { "name": "psr/log", "version": "1.0.2", @@ -1185,27 +1050,27 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.0.9", + "version": "v2.8.41", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "54da3ff63dec3c9c0e32ec3f95a7d94ef64baa00" + "reference": "9b69aad7d4c086dc94ebade2d5eb9145da5dac8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/54da3ff63dec3c9c0e32ec3f95a7d94ef64baa00", - "reference": "54da3ff63dec3c9c0e32ec3f95a7d94ef64baa00", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/9b69aad7d4c086dc94ebade2d5eb9145da5dac8c", + "reference": "9b69aad7d4c086dc94ebade2d5eb9145da5dac8c", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": ">=5.3.9" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~2.8|~3.0", - "symfony/expression-language": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0" + "symfony/config": "^2.0.5|~3.0.0", + "symfony/dependency-injection": "~2.6|~3.0.0", + "symfony/expression-language": "~2.6|~3.0.0", + "symfony/stopwatch": "~2.3|~3.0.0" }, "suggest": { "symfony/dependency-injection": "", @@ -1214,7 +1079,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.8-dev" } }, "autoload": { @@ -1241,7 +1106,7 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2016-07-19T10:44:15+00:00" + "time": "2018-04-06T07:35:03+00:00" }, { "name": "symfony/filesystem", diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..30c4b63 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,24 @@ + + + + + + + + + ./tests/*/Tests + + + + + diff --git a/src/AtolOnlineClient/AtolOnline.php b/src/AtolOnlineClient/AtolOnline.php index 7057c88..852b7b4 100644 --- a/src/AtolOnlineClient/AtolOnline.php +++ b/src/AtolOnlineClient/AtolOnline.php @@ -4,7 +4,9 @@ namespace AtolOnlineClient; use AtolOnlineClient\Configuration\Connection; use AtolOnlineClient\Response\OperationResponse; +use Guzzle\Http\Client; use JMS\Serializer\DeserializationContext; +use JMS\Serializer\SerializationContext; use JMS\Serializer\SerializerBuilder; class AtolOnline @@ -12,6 +14,9 @@ class AtolOnline private $serializer; + /** @var AtolOnlineApi */ + private $api; + public function __construct() { $this->serializer = SerializerBuilder::create()->build(); @@ -32,14 +37,44 @@ class AtolOnline ); } + public function deserializeCheckStatusResponse($response) + { + return $this->serializer->deserialize( + $response, + OperationResponse::class, + 'json', + DeserializationContext::create()->setGroups(['get']) + ); + } + + public function serializeOperationRequest($request) + { + return $this->serializer->serialize( + $request, + 'json', + SerializationContext::create()->setGroups(['set']) + ); + } + /** * @param $client * @param Connection $connection - * @param $isDebug * @return AtolOnlineApi */ - public function getApi($client, Connection $connection, $isDebug) + public function createApi(Client $client, Connection $connection) { - return new AtolOnlineApi($client, $connection, $isDebug); + if (!$this->api) { + $this->api = new AtolOnlineApi($client, $connection); + } + + return $this->api; + } + + /** + * @return AtolOnlineApi + */ + public function getApi() + { + return $this->api; } } \ No newline at end of file diff --git a/src/AtolOnlineClient/AtolOnlineApi.php b/src/AtolOnlineClient/AtolOnlineApi.php index cd540d0..85893be 100644 --- a/src/AtolOnlineClient/AtolOnlineApi.php +++ b/src/AtolOnlineClient/AtolOnlineApi.php @@ -3,10 +3,12 @@ namespace AtolOnlineClient; use AtolOnlineClient\Configuration\Connection; -use Doctrine\Common\Cache\CacheProvider; -use GuzzleHttp\Client; +use Doctrine\Common\Cache\Cache; + +use Guzzle\Http\Client; + +use Guzzle\Http\Message\Response; use GuzzleHttp\Exception\BadResponseException; -use GuzzleHttp\Psr7\Response; use Psr\Log\LoggerInterface; class AtolOnlineApi @@ -18,8 +20,7 @@ class AtolOnlineApi const TOKEN_CACHE_KEY = 'crm_fiscal_atol_online_token'; const TOKEN_CACHE_TIME = 60 * 60 * 24; -// private $baseApiUrl = 'https://online.atol.ru/possystem'; - private $baseApiUrl = 'https://testonline.atol.ru/possystem'; + private $baseApiUrl = 'https://online.atol.ru/possystem'; private $login; private $pass; @@ -32,7 +33,7 @@ class AtolOnlineApi private $logger; /** - * @var CacheProvider + * @var Cache */ private $cache; @@ -51,22 +52,25 @@ class AtolOnlineApi */ private $attemptsCheckStatus; + /** @var string */ private $version; /** * @param Client $client * @param Connection $connectionConfig - * @param bool $debug */ - public function __construct(Client $client, Connection $connectionConfig, $debug = false) + public function __construct(Client $client, Connection $connectionConfig) { $this->client = $client; $this->login = $connectionConfig->login; $this->pass = $connectionConfig->pass; $this->groupCode = $connectionConfig->group; $this->version = $connectionConfig->version; - $this->debug = $debug; + $this->debug = $connectionConfig->isDebug(); $this->attempts = 0; + if ($connectionConfig->isTestMode()) { + $this->baseApiUrl = 'https://testonline.atol.ru/possystem'; + } } /** @@ -136,9 +140,9 @@ class AtolOnlineApi } /** - * @param CacheProvider $cache + * @param Cache $cache */ - public function setCache(CacheProvider $cache) + public function setCache(Cache $cache) { $this->cache = $cache; } diff --git a/src/AtolOnlineClient/AtolOnlineApiV4.php b/src/AtolOnlineClient/AtolOnlineApiV4.php deleted file mode 100644 index b256a0c..0000000 --- a/src/AtolOnlineClient/AtolOnlineApiV4.php +++ /dev/null @@ -1,290 +0,0 @@ -client = $client; - $this->login = $connectionConfig->login; - $this->pass = $connectionConfig->pass; - $this->groupCode = $connectionConfig->group; - $this->version = $connectionConfig->version; - $this->debug = - $this->attempts = 0; - } - - /** - * Приход - * - * @param $paymentReceiptRequest - * @return string - */ - public function sell($paymentReceiptRequest) - { - if ($response = $this->sendOperationRequest('sell', $paymentReceiptRequest)) { - return $response->getBody()->__toString(); - }; - } - - /** - * Возврат прихода - * - * @param $paymentReceiptRequest - * @return string - */ - public function sellRefund($paymentReceiptRequest) - { - if ($response = $this->sendOperationRequest('sell_refund', $paymentReceiptRequest)) { - return $response->getBody()->__toString(); - }; - } - - /** - * Запрос для проверки статуса - * - * @param $uuid - * @return mixed - */ - public function checkStatus($uuid) - { - $token = $this->getToken(); - $url = $this->buildUrl('report/'.$uuid, $token); - $request = $this->client->get($url); - - $response = false; - try { - $this->attemptsCheckStatus++; - $response = $request->send(); - } catch (BadResponseException $e) { - $this->cache->delete($this->getTokenCacheKey()); - $body = json_decode($e->getResponse()->getBody()); - if ($this->isTokenExpired($body) && $this->attemptsCheckStatus <= 1) { - return $this->checkStatus($uuid); - } - $this->logDebug($url, $uuid, $e->getResponse()); - } - - if ($response) { - return $response->getBody()->__toString(); - } - - return false; - } - - /** - * @param $logger - */ - public function setLogger(LoggerInterface $logger) - { - $this->logger = $logger; - } - - /** - * @param CacheProvider $cache - */ - public function setCache(CacheProvider $cache) - { - $this->cache = $cache; - } - - /** - * @return mixed - */ - public function getVersion() - { - return $this->version; - } - - /** - * @param mixed $version - */ - public function setVersion($version): void - { - $this->version = $version; - } - - - /** - * @return mixed - */ - protected function getToken() - { - $data = [ - 'login' => $this->login, - 'pass' => $this->pass, - ]; - - if ($token = $this->cache->fetch($this->getTokenCacheKey())) { - return $token; - } - - $dataJson = json_encode((object)$data, JSON_UNESCAPED_UNICODE); - $url = $this->baseApiUrl - .'/'.$this->getVersion() - .'/getToken'; - - $request = $this->client->createRequest('POST', $url, null, $dataJson); - $response = false; - try { - $response = $this->client->send($request); - } catch (BadResponseException $e) { - if ($this->logger) { - $this->logger->error($e->getResponse()->getBody()); - } - } - - if ($response) { - $response = json_decode($response->getBody()); - - if (isset($response->code) && $response->code == 1 || $response->code == 0) { - $this->cache->save($this->getTokenCacheKey(), $response->token, self::TOKEN_CACHE_TIME); - - return $response->token; - } - } - - - return false; - } - - /** - * @param $data - * @return string - */ - protected function getTokenCacheKey() - { - return self::TOKEN_CACHE_KEY.'_'.md5($this->login.$this->pass); - } - - /** - * @param string $operation - * @param null $token - * @return string - */ - protected function buildUrl($operation, $token = null) - { - $url = $this->baseApiUrl - .'/'.$this->version - .'/'.$this->groupCode - .'/'.$operation; - - if ($token) { - if ($this->version === self::API_VERSION_V4) { - $url .= '?token='.$token; - } elseif ($this->version === self::API_VERSION_V3) { - $url .= '?tokenid='.$token; - } - } - - return $url; - } - - /** - * @param string $operation - * @param string $data - * @return Response|bool - */ - protected function sendOperationRequest($operation, $data) - { - $token = $this->getToken(); - $url = $this->buildUrl($operation, $token); - - $request = $this->client->createRequest('POST', $url, null, $data); - $response = false; - try { - $this->attempts++; - $response = $this->client->send($request); - } catch (BadResponseException $e) { - $this->cache->delete($this->getTokenCacheKey()); - $body = json_decode($e->getResponse()->getBody()); - if ($this->isTokenExpired($body) && $this->attempts <= 1) { - return $this->sendOperationRequest($operation, $data); - } - $this->logDebug($url, $data, $e->getResponse()); - } - if ($response) { - $this->logDebug($url, $data, $response); - } - - return $response; - } - - protected function logDebug($url, $data, Response $response) - { - if ($this->debug && $this->logger) { - $v = "* URL: ".$url; - $v .= "\n * POSTFILEDS: ".$data; - $v .= "\n * RESPONSE HEADERS: ".$response->getRawHeaders(); - $v .= "\n * RESPONSE BODY: ".$response->getBody(); - $v .= "\n * ATTEMPTS: ".$this->attempts; - $this->logger->debug($v); - } - } - - protected function isTokenExpiredCode($code) - { - return in_array($code, [4, 5, 6, 12, 13, 14]); - } - - private function isTokenExpired($body) - { - return isset($body->error) && $this->isTokenExpiredCode($body->error->code); - } -} diff --git a/src/AtolOnlineClient/Configuration.php b/src/AtolOnlineClient/Configuration.php index d0d3c22..8d6e1d9 100644 --- a/src/AtolOnlineClient/Configuration.php +++ b/src/AtolOnlineClient/Configuration.php @@ -17,12 +17,6 @@ class Configuration implements ConfigurationInterface /** @var bool */ public $debug; - /** @var bool */ - public $sendEmail; - - /** @var bool */ - public $sendSms; - /** * @param ClassMetadata $metadata */ @@ -32,26 +26,26 @@ class Configuration implements ConfigurationInterface $metadata->addPropertyConstraint('connections', new Assert\Valid()); } - public function loadConnections($connections) - { - if (!$connections) { - return; - } - foreach ($connections as $connectionItem) { - $connection = new Connection(); - $connection->login = $connectionItem['login']; - $connection->pass = $connectionItem['pass']; - $connection->group = $connectionItem['group']; -// $connection->legalEntity = $connectionItem['legalEntity']; - $connection->sno = $connectionItem['sno']; - $connection->enabled = (bool) $connectionItem['enabled']; -// $connection->paymentTypes = $connectionItem['paymentTypes']; -// $connection->paymentStatuses = $connectionItem['paymentStatuses']; - $connection->ofd = $connectionItem['ofd']; - $connection->version = $connectionItem['version']; - $this->connections[] = $connection; - } - } +// public function loadConnections($connections) +// { +// if (!$connections) { +// return; +// } +// foreach ($connections as $connectionItem) { +// $connection = new Connection(); +// $connection->login = $connectionItem['login']; +// $connection->pass = $connectionItem['pass']; +// $connection->group = $connectionItem['group']; +//// $connection->legalEntity = $connectionItem['legalEntity']; +// $connection->sno = $connectionItem['sno']; +// $connection->enabled = (bool) $connectionItem['enabled']; +//// $connection->paymentTypes = $connectionItem['paymentTypes']; +//// $connection->paymentStatuses = $connectionItem['paymentStatuses']; +// $connection->ofd = $connectionItem['ofd']; +// $connection->version = $connectionItem['version']; +// $this->connections[] = $connection; +// } +// } /** * @param bool $enabled @@ -61,30 +55,6 @@ class Configuration implements ConfigurationInterface $this->enabled = (bool) $enabled; } - /** - * @param bool $sendEmail - * - * @return $this - */ - public function setSendEmail($sendEmail) - { - $this->sendEmail = (bool) $sendEmail; - - return $this; - } - - /** - * @param bool $sendSms - * - * @return $this - */ - public function setSendSms($sendSms) - { - $this->sendSms = (bool) $sendSms; - - return $this; - } - /** * @param mixed $debug */ @@ -101,22 +71,6 @@ class Configuration implements ConfigurationInterface return (bool) $this->enabled; } - /** - * @return bool - */ - public function isSendEmail() - { - return (bool) $this->sendEmail; - } - - /** - * @return bool - */ - public function isSendSms() - { - return (bool) $this->sendSms; - } - /** * @return mixed */ @@ -124,28 +78,4 @@ class Configuration implements ConfigurationInterface { return $this->debug; } - - /** - * @param LegalEntity $legalentity - * @return bool|Connection - */ - public function getLegalEntityConnection(LegalEntity $legalentity) - { - if (!$this->connections || !$this->enabled) { - return false; - } - - foreach ($this->connections as $connection) { - if ($connection->enabled && $connection->legalEntity == $legalentity->getId()) { - return $connection; - } - } - - return false; - } - - protected function postLoadConfiguration() - { - - } } diff --git a/src/AtolOnlineClient/Configuration/Connection.php b/src/AtolOnlineClient/Configuration/Connection.php index bd9a8f2..d283dea 100644 --- a/src/AtolOnlineClient/Configuration/Connection.php +++ b/src/AtolOnlineClient/Configuration/Connection.php @@ -41,9 +41,11 @@ class Connection self::V4, ]; + /** @var string */ protected $url; + /** @var bool */ - protected $debug; + protected $debug = false; /** @var string */ public $login; @@ -54,15 +56,6 @@ class Connection /** @var string */ public $group; - /** @var int */ - public $legalEntity; - - /** @var array */ - public $paymentTypes; - - /** @var array */ - public $paymentStatuses; - /** @var boolean */ public $enabled; @@ -75,18 +68,23 @@ class Connection /** @var string */ public $version; + /** @var bool */ + public $testMode = false; + /** - * @param mixed $url + * @return bool */ - public function setUrl($url): void + public function isTestMode() { - $this->url = $url; + return $this->testMode; } - - public function __construct() + /** + * @param bool $testMode + */ + public function setTestMode(bool $testMode) { - $this->setUrl(''); + $this->testMode = $testMode; } /** @@ -113,7 +111,6 @@ class Connection $metadata->addPropertyConstraint('login', new Assert\NotBlank()); $metadata->addPropertyConstraint('pass', new Assert\NotBlank()); $metadata->addPropertyConstraint('group', new Assert\NotBlank()); - $metadata->addPropertyConstraint('legalEntity', new Assert\NotBlank()); $metadata->addPropertyConstraints('sno', [ new Assert\Choice([ 'choices' => self::snoTypes, @@ -129,8 +126,6 @@ class Connection 'choices' => self::versions, ]) ]); - $metadata->addPropertyConstraint('paymentTypes', new Assert\NotBlank()); - $metadata->addPropertyConstraint('paymentStatuses', new Assert\NotBlank()); } /** diff --git a/src/AtolOnlineClient/Response/OperationResponse.php b/src/AtolOnlineClient/Response/OperationResponse.php index bfd43d9..0383623 100644 --- a/src/AtolOnlineClient/Response/OperationResponse.php +++ b/src/AtolOnlineClient/Response/OperationResponse.php @@ -17,13 +17,13 @@ class OperationResponse private $uuid; /** - * @var string + * @var Error * * @Serializer\Groups({"post", "get"}) - * @Serializer\SerializedName("timestamp") - * @Serializer\Type("string") + * @Serializer\SerializedName("error") + * @Serializer\Type("AtolOnlineClient\Response\Error") */ - private $timestamp; + private $error; /** * @var string @@ -36,6 +36,52 @@ class OperationResponse */ private $status; + /** + * @var Payload + * + * @Serializer\Groups({"get"}) + * @Serializer\SerializedName("payload") + * @Serializer\Type("AtolOnlineClient\Response\Payload") + */ + private $payload; + + /** + * @var string + * + * @Serializer\Groups({"post", "get"}) + * @Serializer\SerializedName("timestamp") + * @Serializer\Type("string") + */ + private $timestamp; + + /** + * @var string + * + * @Serializer\Groups({"get"}) + * @Serializer\SerializedName("group_code") + * @Serializer\Type("string") + */ + private $groupCode; + + /** + * @var string + * + * @Serializer\Groups({"get"}) + * @Serializer\SerializedName("daemon_code") + * @Serializer\Type("string") + */ + private $daemonCode; + + /** + * @var string + * + * @Serializer\Groups({"get"}) + * @Serializer\SerializedName("device_code") + * @Serializer\Type("string") + */ + private $deviceCode; + + /** * @var string * @@ -45,23 +91,7 @@ class OperationResponse */ private $callbackUrl; - /** - * @var Payload - * - * @Serializer\Groups({"get"}) - * @Serializer\SerializedName("payload") - * @Serializer\Type("Intaro\CRMFiscalBundle\FiscalService\AtolOnline\Response\Payload") - */ - private $payload; - /** - * @var Error - * - * @Serializer\Groups({"post", "get"}) - * @Serializer\SerializedName("error") - * @Serializer\Type("Intaro\CRMFiscalBundle\FiscalService\AtolOnline\Response\Error") - */ - private $error; /** * @return string @@ -182,4 +212,52 @@ class OperationResponse return $this; } + + /** + * @return string + */ + public function getGroupCode() + { + return $this->groupCode; + } + + /** + * @param string $groupCode + */ + public function setGroupCode(string $groupCode) + { + $this->groupCode = $groupCode; + } + + /** + * @return string + */ + public function getDaemonCode() + { + return $this->daemonCode; + } + + /** + * @param string $daemonCode + */ + public function setDaemonCode(string $daemonCode) + { + $this->daemonCode = $daemonCode; + } + + /** + * @return string + */ + public function getDeviceCode() + { + return $this->deviceCode; + } + + /** + * @param string $deviceCode + */ + public function setDeviceCode(string $deviceCode) + { + $this->deviceCode = $deviceCode; + } } diff --git a/src/AtolOnlineClient/Response/Payload.php b/src/AtolOnlineClient/Response/Payload.php index 55d4731..f6d73d9 100644 --- a/src/AtolOnlineClient/Response/Payload.php +++ b/src/AtolOnlineClient/Response/Payload.php @@ -1,6 +1,6 @@ assertInstanceOf(Configuration::class, $atol->createConfiguration()); + } +} \ No newline at end of file