diff --git a/.env.dist b/.env.dist index 163c9a3..15e3584 100644 --- a/.env.dist +++ b/.env.dist @@ -1,3 +1,3 @@ -MG_BOT_URL="" +MG_BOT_URL="https://mg-test.retailcrm.pro/" MG_BOT_KEY="" MG_BOT_DBG="" diff --git a/.gitignore b/.gitignore index a9004ee..5ac2b6c 100644 --- a/.gitignore +++ b/.gitignore @@ -61,6 +61,7 @@ cmake-build-release/ # IntelliJ out/ +.idea/ # mpeltonen/sbt-idea plugin .idea_modules/ @@ -184,3 +185,15 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk /.php_cs.cache + +# phpDocumentor +phpDocumentor.phar +phpDocumentor.phar.pubkey +mg-bot-api-client-php.pages/* +build/* + +# Test report +test-report.xml + +# GraphViz Dot +dot/* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index fe2315f..94e53ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,10 @@ php: - '7.0' - '7.1' - '7.2' + - '7.3' before_script: - flags="-o" - composer install $flags -script: make test +script: make travis \ No newline at end of file diff --git a/Makefile b/Makefile index 79babc0..5862033 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) SRC_DIR=$(ROOT_DIR)/src BIN_DIR=$(ROOT_DIR)/bin +export PATH := $(PATH):$(ROOT_DIR)/dot deps: @echo "==> Installing dependencies" @@ -10,6 +11,10 @@ deps: test: @echo "==> Running tests" @cd $(ROOT_DIR) +ifeq ($(wildcard .env), ) + @echo "==> Creating .env file for testing purposes..." + @cp .env.dist .env +endif @php -d memory_limit=-1 $(BIN_DIR)/phpunit -c phpunit.xml.dist --log-junit $(ROOT_DIR)/test-report.xml @echo "==> Testing complete" @@ -17,3 +22,6 @@ stan: @echo "==> Running analysis" @php $(BIN_DIR)/phpstan analyse -l 4 -c $(ROOT_DIR)/phpstan.neon $(SRC_DIR) @echo "==> Analysis complete" + +travis: test stan + @echo "==> Completed" \ No newline at end of file diff --git a/apigen.neon b/apigen.neon deleted file mode 100644 index 5c74aed..0000000 --- a/apigen.neon +++ /dev/null @@ -1,32 +0,0 @@ -extensions: - - php - -source: - - src - -exclude: - - tests/ - - vendor/ - - bin/ - - docs/ - -charset: - - auto - - UTF-8 - - Windows-1251 - -title: retailCRM PHP MG Bot API client -templateTheme: bootstrap -groups: auto - -accessLevels: - - public - - protected - -internal: true -php: false -tree: true -deprecated: true -todo: true -destination: ../mg-bot-api-client-php.pages/ -download: false diff --git a/composer.json b/composer.json index 13565df..a42e510 100644 --- a/composer.json +++ b/composer.json @@ -15,18 +15,37 @@ "php": ">=7.0", "ext-curl": "*", "ext-json": "*", - "jms/serializer": "1.13.*", - "symfony/validator": "^4.2", - "doctrine/annotations": "^1.6", - "doctrine/cache": "^1.8" + "jms/serializer": "1.14.*", + "symfony/validator": "3.*", + "doctrine/annotations": "1.4.*", + "doctrine/cache": "1.6.*", + "guzzlehttp/guzzle": "6.*", + "doctrine/instantiator": "1.0.*", + "symfony/translation": "3.*", + "symfony/dependency-injection": "3.*", + "symfony/config": "3.*", + "symfony/finder": "3.4.*", + "symfony/filesystem": "3.*" }, "require-dev": { - "phpunit/phpunit": "6.5.*", - "phpmd/phpmd": "2.6.*", - "phpstan/phpstan": "0.9.*", + "phpmd/phpmd": "2.*", "squizlabs/php_codesniffer": "3.4.*", - "symfony/dotenv": "^4.2", - "friendsofphp/php-cs-fixer": "^2.14" + "symfony/dotenv": "3.*", + "friendsofphp/php-cs-fixer": "2.*", + "phpunit/phpunit": "6.*", + "nette/bootstrap": "2.*", + "nette/neon": "2.*", + "nette/php-generator": "3.0.*", + "phpstan/phpstan": "0.9.*", + "ocramius/package-versions": "1.2.*", + "nette/finder": "2.4.*", + "symfony/console": "3.*", + "symfony/debug": "3.*", + "symfony/event-dispatcher": "3.*", + "symfony/options-resolver": "3.4.*", + "symfony/process": "3.4.*", + "symfony/stopwatch": "3.4.*", + "myclabs/deep-copy": "1.6.*" }, "support": { "email": "support@retailcrm.ru" diff --git a/composer.lock b/composer.lock index 3553733..f064c7a 100644 --- a/composer.lock +++ b/composer.lock @@ -1,37 +1,37 @@ { "_readme": [ "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "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": "e2dc59137064db9a4933e3049f8e0c34", + "content-hash": "eb2db3a82485e57635ef21c116770aa8", "packages": [ { "name": "doctrine/annotations", - "version": "v1.6.1", + "version": "v1.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/annotations.git", - "reference": "53120e0eb10355388d6ccbe462f1fea34ddadb24" + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/annotations/zipball/53120e0eb10355388d6ccbe462f1fea34ddadb24", - "reference": "53120e0eb10355388d6ccbe462f1fea34ddadb24", + "url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97", + "reference": "54cacc9b81758b14e3ce750f205a393d52339e97", "shasum": "" }, "require": { "doctrine/lexer": "1.*", - "php": "^7.1" + "php": "^5.6 || ^7.0" }, "require-dev": { "doctrine/cache": "1.*", - "phpunit/phpunit": "^6.4" + "phpunit/phpunit": "^5.7" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.6.x-dev" + "dev-master": "1.4.x-dev" } }, "autoload": { @@ -72,42 +72,37 @@ "docblock", "parser" ], - "time": "2019-03-25T19:12:02+00:00" + "time": "2017-02-24T16:22:25+00:00" }, { "name": "doctrine/cache", - "version": "v1.8.0", + "version": "v1.6.2", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "d768d58baee9a4862ca783840eca1b9add7a7f57" + "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/d768d58baee9a4862ca783840eca1b9add7a7f57", - "reference": "d768d58baee9a4862ca783840eca1b9add7a7f57", + "url": "https://api.github.com/repos/doctrine/cache/zipball/eb152c5100571c7a45470ff2a35095ab3f3b900b", + "reference": "eb152c5100571c7a45470ff2a35095ab3f3b900b", "shasum": "" }, "require": { - "php": "~7.1" + "php": "~5.5|~7.0" }, "conflict": { "doctrine/common": ">2.2,<2.4" }, "require-dev": { - "alcaeus/mongo-php-adapter": "^1.1", - "doctrine/coding-standard": "^4.0", - "mongodb/mongodb": "^1.1", - "phpunit/phpunit": "^7.0", - "predis/predis": "~1.0" - }, - "suggest": { - "alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver" + "phpunit/phpunit": "~4.8|~5.0", + "predis/predis": "~1.0", + "satooshi/php-coveralls": "~0.6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -142,43 +137,41 @@ } ], "description": "Caching library offering an object-oriented API for many cache backends", - "homepage": "https://www.doctrine-project.org", + "homepage": "http://www.doctrine-project.org", "keywords": [ "cache", "caching" ], - "time": "2018-08-21T18:01:43+00:00" + "time": "2017-07-22T12:49:21+00:00" }, { "name": "doctrine/instantiator", - "version": "1.2.0", + "version": "1.0.5", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "a2c590166b2133a4633738648b6b064edae0814a" + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a", - "reference": "a2c590166b2133a4633738648b6b064edae0814a", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", "shasum": "" }, "require": { - "php": "^7.1" + "php": ">=5.3,<8.0-DEV" }, "require-dev": { - "doctrine/coding-standard": "^6.0", + "athletic/athletic": "~0.1.8", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { @@ -198,30 +191,33 @@ } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "homepage": "https://github.com/doctrine/instantiator", "keywords": [ "constructor", "instantiate" ], - "time": "2019-03-17T17:37:11+00:00" + "time": "2015-06-14T21:17:01+00:00" }, { "name": "doctrine/lexer", - "version": "v1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/doctrine/lexer.git", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c" + "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/lexer/zipball/83893c552fd2045dd78aef794c31e694c37c0b8c", - "reference": "83893c552fd2045dd78aef794c31e694c37c0b8c", + "url": "https://api.github.com/repos/doctrine/lexer/zipball/1febd6c3ef84253d7c815bed85fc622ad207a9f8", + "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8", "shasum": "" }, "require": { "php": ">=5.3.2" }, + "require-dev": { + "phpunit/phpunit": "^4.5" + }, "type": "library", "extra": { "branch-alias": { @@ -229,8 +225,8 @@ } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\Lexer\\": "lib/" + "psr-4": { + "Doctrine\\Common\\Lexer\\": "lib/Doctrine/Common/Lexer" } }, "notification-url": "https://packagist.org/downloads/", @@ -251,13 +247,199 @@ "email": "schmittjoh@gmail.com" } ], - "description": "Base library for a lexer that can be used in Top-Down, Recursive Descent Parsers.", - "homepage": "http://www.doctrine-project.org", + "description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.", + "homepage": "https://www.doctrine-project.org/projects/lexer.html", "keywords": [ + "annotations", + "docblock", "lexer", - "parser" + "parser", + "php" ], - "time": "2014-09-09T13:34:57+00:00" + "time": "2019-06-08T11:03:04+00:00" + }, + { + "name": "guzzlehttp/guzzle", + "version": "6.3.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "^1.0", + "guzzlehttp/psr7": "^1.4", + "php": ">=5.5" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", + "psr/log": "^1.0" + }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.3-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "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.5.2", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "9f83dded91781a01c63574e387eaa769be769115" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115", + "reference": "9f83dded91781a01c63574e387eaa769be769115", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.5-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", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "time": "2018-12-04T20:46:45+00:00" }, { "name": "jms/metadata", @@ -351,16 +533,16 @@ }, { "name": "jms/serializer", - "version": "1.13.0", + "version": "1.14.0", "source": { "type": "git", "url": "https://github.com/schmittjoh/serializer.git", - "reference": "00863e1d55b411cc33ad3e1de09a4c8d3aae793c" + "reference": "ee96d57024af9a7716d56fcbe3aa94b3d030f3ca" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/00863e1d55b411cc33ad3e1de09a4c8d3aae793c", - "reference": "00863e1d55b411cc33ad3e1de09a4c8d3aae793c", + "url": "https://api.github.com/repos/schmittjoh/serializer/zipball/ee96d57024af9a7716d56fcbe3aa94b3d030f3ca", + "reference": "ee96d57024af9a7716d56fcbe3aa94b3d030f3ca", "shasum": "" }, "require": { @@ -400,7 +582,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-1.x": "1.13-dev" + "dev-1.x": "1.14-dev" } }, "autoload": { @@ -431,7 +613,7 @@ "serialization", "xml" ], - "time": "2018-07-25T13:58:54+00:00" + "time": "2019-04-17T08:12:16+00:00" }, { "name": "phpcollection/phpcollection", @@ -532,45 +714,129 @@ "time": "2015-07-25T16:39:46+00:00" }, { - "name": "symfony/contracts", - "version": "v1.0.2", + "name": "psr/container", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/symfony/contracts.git", - "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf" + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf", - "reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "shasum": "" }, "require": { - "php": "^7.1.3" - }, - "require-dev": { - "psr/cache": "^1.0", - "psr/container": "^1.0" - }, - "suggest": { - "psr/cache": "When using the Cache contracts", - "psr/container": "When using the Service contracts", - "symfony/cache-contracts-implementation": "", - "symfony/service-contracts-implementation": "", - "symfony/translation-contracts-implementation": "" + "php": ">=5.3.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.0.x-dev" } }, "autoload": { "psr-4": { - "Symfony\\Contracts\\": "" - }, - "exclude-from-classmap": [ - "**/Tests/" + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+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": "ralouphie/getallheaders", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7.0", + "satooshi/php-coveralls": ">=1.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -579,25 +845,246 @@ ], "authors": [ { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2016-02-11T07:05:27+00:00" + }, + { + "name": "symfony/config", + "version": "v3.4.28", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "177a276c01575253c95cefe0866e3d1b57637fe0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/177a276c01575253c95cefe0866e3d1b57637fe0", + "reference": "177a276c01575253c95cefe0866e3d1b57637fe0", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/filesystem": "~2.8|~3.0|~4.0", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/dependency-injection": "<3.3", + "symfony/finder": "<3.3" + }, + "require-dev": { + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/event-dispatcher": "~3.3|~4.0", + "symfony/finder": "~3.3|~4.0", + "symfony/yaml": "~3.0|~4.0" + }, + "suggest": { + "symfony/yaml": "To use the yaml reference dumper" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "A set of abstractions extracted out of the Symfony components", + "description": "Symfony Config Component", "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" + "time": "2019-02-23T15:06:07+00:00" + }, + { + "name": "symfony/dependency-injection", + "version": "v3.4.28", + "source": { + "type": "git", + "url": "https://github.com/symfony/dependency-injection.git", + "reference": "8f2a0452f086a66f6d6cf53a432867b575887768" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/8f2a0452f086a66f6d6cf53a432867b575887768", + "reference": "8f2a0452f086a66f6d6cf53a432867b575887768", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "psr/container": "^1.0" + }, + "conflict": { + "symfony/config": "<3.3.7", + "symfony/finder": "<3.3", + "symfony/proxy-manager-bridge": "<3.4", + "symfony/yaml": "<3.4" + }, + "provide": { + "psr/container-implementation": "1.0" + }, + "require-dev": { + "symfony/config": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/yaml": "~3.4|~4.0" + }, + "suggest": { + "symfony/config": "", + "symfony/expression-language": "For using expressions in service container configuration", + "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", + "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\DependencyInjection\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" ], - "time": "2018-12-05T08:06:11+00:00" + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony DependencyInjection Component", + "homepage": "https://symfony.com", + "time": "2019-05-19T14:11:39+00:00" + }, + { + "name": "symfony/filesystem", + "version": "v3.4.28", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "acf99758b1df8e9295e6b85aa69f294565c9fedb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/acf99758b1df8e9295e6b85aa69f294565c9fedb", + "reference": "acf99758b1df8e9295e6b85aa69f294565c9fedb", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "https://symfony.com", + "time": "2019-02-04T21:34:32+00:00" + }, + { + "name": "symfony/finder", + "version": "v3.4.28", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "fa5d962a71f2169dfe1cbae217fa5a2799859f6c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/fa5d962a71f2169dfe1cbae217fa5a2799859f6c", + "reference": "fa5d962a71f2169dfe1cbae217fa5a2799859f6c", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Finder Component", + "homepage": "https://symfony.com", + "time": "2019-05-24T12:25:55+00:00" }, { "name": "symfony/polyfill-ctype", @@ -717,47 +1204,114 @@ "time": "2019-02-06T07:57:58+00:00" }, { - "name": "symfony/validator", - "version": "v4.2.5", + "name": "symfony/translation", + "version": "v3.4.28", "source": { "type": "git", - "url": "https://github.com/symfony/validator.git", - "reference": "db5457ed88aacc1a040d4961ee52cddad3e5a4aa" + "url": "https://github.com/symfony/translation.git", + "reference": "301a5d627220a1c4ee522813b0028653af6c4f54" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/validator/zipball/db5457ed88aacc1a040d4961ee52cddad3e5a4aa", - "reference": "db5457ed88aacc1a040d4961ee52cddad3e5a4aa", + "url": "https://api.github.com/repos/symfony/translation/zipball/301a5d627220a1c4ee522813b0028653af6c4f54", + "reference": "301a5d627220a1c4ee522813b0028653af6c4f54", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/contracts": "^1.0.2", - "symfony/polyfill-ctype": "~1.8", + "php": "^5.5.9|>=7.0.8", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", + "symfony/config": "<2.8", "symfony/dependency-injection": "<3.4", - "symfony/http-kernel": "<3.4", - "symfony/intl": "<4.1", - "symfony/translation": "<4.2", + "symfony/yaml": "<3.4" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/finder": "~2.8|~3.0|~4.0", + "symfony/http-kernel": "~3.4|~4.0", + "symfony/intl": "^2.8.18|^3.2.5|~4.0", + "symfony/var-dumper": "~3.4|~4.0", + "symfony/yaml": "~3.4|~4.0" + }, + "suggest": { + "psr/log-implementation": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Translation Component", + "homepage": "https://symfony.com", + "time": "2019-05-01T11:10:09+00:00" + }, + { + "name": "symfony/validator", + "version": "v3.4.28", + "source": { + "type": "git", + "url": "https://github.com/symfony/validator.git", + "reference": "23cf394faaffb6257f5764fbfc2db12ec30956f1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/validator/zipball/23cf394faaffb6257f5764fbfc2db12ec30956f1", + "reference": "23cf394faaffb6257f5764fbfc2db12ec30956f1", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.0", + "symfony/translation": "~2.8|~3.0|~4.0" + }, + "conflict": { + "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", + "symfony/dependency-injection": "<3.3", + "symfony/http-kernel": "<3.3.5", "symfony/yaml": "<3.4" }, "require-dev": { "doctrine/annotations": "~1.0", "doctrine/cache": "~1.0", "egulias/email-validator": "^1.2.8|~2.0", - "symfony/cache": "~3.4|~4.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/http-foundation": "~4.1", - "symfony/http-kernel": "~3.4|~4.0", - "symfony/intl": "~4.1", - "symfony/property-access": "~3.4|~4.0", - "symfony/translation": "~4.2", - "symfony/var-dumper": "~3.4|~4.0", + "symfony/cache": "~3.1|~4.0", + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/http-foundation": "~2.8|~3.0|~4.0", + "symfony/http-kernel": "^3.3.5|~4.0", + "symfony/intl": "^2.8.18|^3.2.5|~4.0", + "symfony/property-access": "~2.8|~3.0|~4.0", + "symfony/var-dumper": "~3.3|~4.0", "symfony/yaml": "~3.4|~4.0" }, "suggest": { @@ -770,13 +1324,12 @@ "symfony/http-foundation": "", "symfony/intl": "", "symfony/property-access": "For accessing properties within comparison constraints", - "symfony/translation": "For translating validation errors.", "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -803,7 +1356,7 @@ ], "description": "Symfony Validator Component", "homepage": "https://symfony.com", - "time": "2019-03-30T15:58:42+00:00" + "time": "2019-05-05T16:11:06+00:00" } ], "packages-dev": [ @@ -871,16 +1424,16 @@ }, { "name": "composer/xdebug-handler", - "version": "1.3.2", + "version": "1.3.3", "source": { "type": "git", "url": "https://github.com/composer/xdebug-handler.git", - "reference": "d17708133b6c276d6e42ef887a877866b909d892" + "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/d17708133b6c276d6e42ef887a877866b909d892", - "reference": "d17708133b6c276d6e42ef887a877866b909d892", + "url": "https://api.github.com/repos/composer/xdebug-handler/zipball/46867cbf8ca9fb8d60c506895449eb799db1184f", + "reference": "46867cbf8ca9fb8d60c506895449eb799db1184f", "shasum": "" }, "require": { @@ -911,20 +1464,20 @@ "Xdebug", "performance" ], - "time": "2019-01-28T20:25:53+00:00" + "time": "2019-05-27T17:52:04+00:00" }, { "name": "friendsofphp/php-cs-fixer", - "version": "v2.14.2", + "version": "v2.15.1", "source": { "type": "git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", - "reference": "ff401e58261ffc5934a58f795b3f95b355e276cb" + "reference": "20064511ab796593a3990669eff5f5b535001f7c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/ff401e58261ffc5934a58f795b3f95b355e276cb", - "reference": "ff401e58261ffc5934a58f795b3f95b355e276cb", + "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/20064511ab796593a3990669eff5f5b535001f7c", + "reference": "20064511ab796593a3990669eff5f5b535001f7c", "shasum": "" }, "require": { @@ -952,11 +1505,11 @@ "mikey179/vfsstream": "^1.6", "php-coveralls/php-coveralls": "^2.1", "php-cs-fixer/accessible-object": "^1.0", - "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.0.1", - "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.0.1", + "php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.1", + "php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.1", "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1", - "phpunitgoodpractices/traits": "^1.5.1", - "symfony/phpunit-bridge": "^4.0" + "phpunitgoodpractices/traits": "^1.8", + "symfony/phpunit-bridge": "^4.3" }, "suggest": { "ext-mbstring": "For handling non-UTF8 characters in cache signature.", @@ -999,7 +1552,7 @@ } ], "description": "A tool to automatically fix PHP code style", - "time": "2019-02-17T17:44:13+00:00" + "time": "2019-06-01T10:32:12+00:00" }, { "name": "jean85/pretty-package-versions", @@ -1054,43 +1607,37 @@ }, { "name": "myclabs/deep-copy", - "version": "1.8.1", + "version": "1.6.1", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" + "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", - "reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8e6e04167378abf1ddb4d3522d8755c5fd90d102", + "reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102", "shasum": "" }, "require": { - "php": "^7.1" - }, - "replace": { - "myclabs/deep-copy": "self.version" + "php": ">=5.4.0" }, "require-dev": { - "doctrine/collections": "^1.0", - "doctrine/common": "^2.6", - "phpunit/phpunit": "^7.1" + "doctrine/collections": "1.*", + "phpunit/phpunit": "~4.1" }, "type": "library", "autoload": { "psr-4": { "DeepCopy\\": "src/DeepCopy/" - }, - "files": [ - "src/DeepCopy/deep_copy.php" - ] + } }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "description": "Create deep copies (clones) of your objects", + "homepage": "https://github.com/myclabs/DeepCopy", "keywords": [ "clone", "copy", @@ -1098,40 +1645,43 @@ "object", "object graph" ], - "time": "2018-06-11T23:09:50+00:00" + "time": "2017-04-12T18:52:22+00:00" }, { "name": "nette/bootstrap", - "version": "v3.0.0", + "version": "v2.4.6", "source": { "type": "git", "url": "https://github.com/nette/bootstrap.git", - "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3" + "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/bootstrap/zipball/e1075af05c211915e03e0c86542f3ba5433df4a3", - "reference": "e1075af05c211915e03e0c86542f3ba5433df4a3", + "url": "https://api.github.com/repos/nette/bootstrap/zipball/268816e3f1bb7426c3a4ceec2bd38a036b532543", + "reference": "268816e3f1bb7426c3a4ceec2bd38a036b532543", "shasum": "" }, "require": { - "nette/di": "^3.0", - "nette/utils": "^3.0", - "php": ">=7.1" + "nette/di": "~2.4.7", + "nette/utils": "~2.4", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" }, "require-dev": { - "latte/latte": "^2.2", - "nette/application": "^3.0", - "nette/caching": "^3.0", - "nette/database": "^3.0", - "nette/forms": "^3.0", - "nette/http": "^3.0", - "nette/mail": "^3.0", - "nette/robot-loader": "^3.0", - "nette/safe-stream": "^2.2", - "nette/security": "^3.0", - "nette/tester": "^2.0", - "tracy/tracy": "^2.6" + "latte/latte": "~2.2", + "nette/application": "~2.3", + "nette/caching": "~2.3", + "nette/database": "~2.3", + "nette/forms": "~2.3", + "nette/http": "~2.4.0", + "nette/mail": "~2.3", + "nette/robot-loader": "^2.4.2 || ^3.0", + "nette/safe-stream": "~2.2", + "nette/security": "~2.3", + "nette/tester": "~2.0", + "tracy/tracy": "^2.4.1" }, "suggest": { "nette/robot-loader": "to use Configurator::createRobotLoader()", @@ -1140,7 +1690,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1164,57 +1714,53 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🅱 Nette Bootstrap: the simple way to configure and bootstrap your Nette application.", + "description": "? Nette Bootstrap: the simple way to configure and bootstrap your Nette application.", "homepage": "https://nette.org", "keywords": [ "bootstrapping", "configurator", "nette" ], - "time": "2019-03-26T12:59:07+00:00" + "time": "2018-05-17T12:52:20+00:00" }, { "name": "nette/di", - "version": "v3.0.0", + "version": "v2.4.15", "source": { "type": "git", "url": "https://github.com/nette/di.git", - "reference": "19d83539245aaacb59470828919182411061841f" + "reference": "d0561b8f77e8ef2ed6d83328860e16c81a5a8649" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/di/zipball/19d83539245aaacb59470828919182411061841f", - "reference": "19d83539245aaacb59470828919182411061841f", + "url": "https://api.github.com/repos/nette/di/zipball/d0561b8f77e8ef2ed6d83328860e16c81a5a8649", + "reference": "d0561b8f77e8ef2ed6d83328860e16c81a5a8649", "shasum": "" }, "require": { "ext-tokenizer": "*", - "nette/neon": "^3.0", - "nette/php-generator": "^3.2.2", - "nette/robot-loader": "^3.2", - "nette/schema": "^1.0", - "nette/utils": "^3.0", - "php": ">=7.1" + "nette/neon": "^2.3.3 || ~3.0.0", + "nette/php-generator": "^2.6.1 || ^3.0.0", + "nette/utils": "^2.5.0 || ~3.0.0", + "php": ">=5.6.0" }, "conflict": { - "nette/bootstrap": "<3.0" + "nette/bootstrap": "<2.4", + "nette/nette": "<2.2" }, "require-dev": { - "nette/tester": "^2.2", + "nette/tester": "^2.0", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.4-dev" } }, "autoload": { "classmap": [ "src/" - ], - "files": [ - "src/compatibility.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1233,7 +1779,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "💎 Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.", + "description": "? Nette Dependency Injection Container: Flexible, compiled and full-featured DIC with perfectly usable autowiring and support for all new PHP 7.1 features.", "homepage": "https://nette.org", "keywords": [ "compiled", @@ -1244,37 +1790,37 @@ "nette", "static" ], - "time": "2019-04-03T19:35:46+00:00" + "time": "2019-01-30T13:26:05+00:00" }, { "name": "nette/finder", - "version": "v2.5.0", + "version": "v2.4.2", "source": { "type": "git", "url": "https://github.com/nette/finder.git", - "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2" + "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/finder/zipball/6be1b83ea68ac558aff189d640abe242e0306fe2", - "reference": "6be1b83ea68ac558aff189d640abe242e0306fe2", + "url": "https://api.github.com/repos/nette/finder/zipball/ee951a656cb8ac622e5dd33474a01fd2470505a0", + "reference": "ee951a656cb8ac622e5dd33474a01fd2470505a0", "shasum": "" }, "require": { - "nette/utils": "^2.4 || ~3.0.0", - "php": ">=7.1" + "nette/utils": "~2.4", + "php": ">=5.6.0" }, "conflict": { "nette/nette": "<2.2" }, "require-dev": { - "nette/tester": "^2.0", + "nette/tester": "~2.0", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1306,35 +1852,35 @@ "iterator", "nette" ], - "time": "2019-02-28T18:13:25+00:00" + "time": "2018-06-28T11:49:23+00:00" }, { "name": "nette/neon", - "version": "v3.0.0", + "version": "v2.4.3", "source": { "type": "git", "url": "https://github.com/nette/neon.git", - "reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb" + "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/neon/zipball/cbff32059cbdd8720deccf9e9eace6ee516f02eb", - "reference": "cbff32059cbdd8720deccf9e9eace6ee516f02eb", + "url": "https://api.github.com/repos/nette/neon/zipball/5e72b1dd3e2d34f0863c5561139a19df6a1ef398", + "reference": "5e72b1dd3e2d34f0863c5561139a19df6a1ef398", "shasum": "" }, "require": { "ext-iconv": "*", "ext-json": "*", - "php": ">=7.0" + "php": ">=5.6.0" }, "require-dev": { - "nette/tester": "^2.0", + "nette/tester": "~2.0", "tracy/tracy": "^2.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.4-dev" } }, "autoload": { @@ -1367,25 +1913,28 @@ "nette", "yaml" ], - "time": "2019-02-05T21:30:40+00:00" + "time": "2018-03-21T12:12:21+00:00" }, { "name": "nette/php-generator", - "version": "v3.2.2", + "version": "v3.0.5", "source": { "type": "git", "url": "https://github.com/nette/php-generator.git", - "reference": "acff8b136fad84b860a626d133e791f95781f9f5" + "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/php-generator/zipball/acff8b136fad84b860a626d133e791f95781f9f5", - "reference": "acff8b136fad84b860a626d133e791f95781f9f5", + "url": "https://api.github.com/repos/nette/php-generator/zipball/ea90209c2e8a7cd087b2742ca553c047a8df5eff", + "reference": "ea90209c2e8a7cd087b2742ca553c047a8df5eff", "shasum": "" }, "require": { "nette/utils": "^2.4.2 || ~3.0.0", - "php": ">=7.1" + "php": ">=7.0" + }, + "conflict": { + "nette/nette": "<2.2" }, "require-dev": { "nette/tester": "^2.0", @@ -1394,7 +1943,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1418,7 +1967,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🐘 Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.3 features.", + "description": "? Nette PHP Generator: generates neat PHP code for you. Supports new PHP 7.2 features.", "homepage": "https://nette.org", "keywords": [ "code", @@ -1426,27 +1975,30 @@ "php", "scaffolding" ], - "time": "2019-03-15T03:41:13+00:00" + "time": "2018-08-09T14:32:27+00:00" }, { "name": "nette/robot-loader", - "version": "v3.2.0", + "version": "v3.1.1", "source": { "type": "git", "url": "https://github.com/nette/robot-loader.git", - "reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c" + "reference": "3e8d75d6d976e191bdf46752ca40a286671219d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/robot-loader/zipball/0712a0e39ae7956d6a94c0ab6ad41aa842544b5c", - "reference": "0712a0e39ae7956d6a94c0ab6ad41aa842544b5c", + "url": "https://api.github.com/repos/nette/robot-loader/zipball/3e8d75d6d976e191bdf46752ca40a286671219d2", + "reference": "3e8d75d6d976e191bdf46752ca40a286671219d2", "shasum": "" }, "require": { "ext-tokenizer": "*", - "nette/finder": "^2.5", - "nette/utils": "^3.0", - "php": ">=7.1" + "nette/finder": "^2.3 || ^3.0", + "nette/utils": "^2.4 || ^3.0", + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" }, "require-dev": { "nette/tester": "^2.0", @@ -1455,7 +2007,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "3.1-dev" } }, "autoload": { @@ -1488,81 +2040,27 @@ "nette", "trait" ], - "time": "2019-03-08T21:57:24+00:00" - }, - { - "name": "nette/schema", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/nette/schema.git", - "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nette/schema/zipball/6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", - "reference": "6241d8d4da39e825dd6cb5bfbe4242912f4d7e4d", - "shasum": "" - }, - "require": { - "nette/utils": "^3.0.1", - "php": ">=7.1" - }, - "require-dev": { - "nette/tester": "^2.2", - "tracy/tracy": "^2.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause", - "GPL-2.0", - "GPL-3.0" - ], - "authors": [ - { - "name": "David Grudl", - "homepage": "https://davidgrudl.com" - }, - { - "name": "Nette Community", - "homepage": "https://nette.org/contributors" - } - ], - "description": "📐 Nette Schema: validating data structures against a given Schema.", - "homepage": "https://nette.org", - "keywords": [ - "config", - "nette" - ], - "time": "2019-04-03T15:53:25+00:00" + "time": "2019-03-01T20:23:02+00:00" }, { "name": "nette/utils", - "version": "v3.0.1", + "version": "v2.5.3", "source": { "type": "git", "url": "https://github.com/nette/utils.git", - "reference": "bd961f49b211997202bda1d0fbc410905be370d4" + "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nette/utils/zipball/bd961f49b211997202bda1d0fbc410905be370d4", - "reference": "bd961f49b211997202bda1d0fbc410905be370d4", + "url": "https://api.github.com/repos/nette/utils/zipball/17b9f76f2abd0c943adfb556e56f2165460b15ce", + "reference": "17b9f76f2abd0c943adfb556e56f2165460b15ce", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=5.6.0" + }, + "conflict": { + "nette/nette": "<2.2" }, "require-dev": { "nette/tester": "~2.0", @@ -1571,7 +2069,7 @@ "suggest": { "ext-gd": "to use Image", "ext-iconv": "to use Strings::webalize() and toAscii()", - "ext-intl": "to use Strings::webalize(), toAscii(), normalize() and compare()", + "ext-intl": "for script transliteration in Strings::webalize() and toAscii()", "ext-json": "to use Nette\\Utils\\Json", "ext-mbstring": "to use Strings::lower() etc...", "ext-xml": "to use Strings::length() etc. when mbstring is not available" @@ -1579,12 +2077,15 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "2.5-dev" } }, "autoload": { "classmap": [ "src/" + ], + "files": [ + "src/loader.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1603,7 +2104,7 @@ "homepage": "https://nette.org/contributors" } ], - "description": "🛠 Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", + "description": "? Nette Utils: lightweight utilities for string & array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.", "homepage": "https://nette.org", "keywords": [ "array", @@ -1621,7 +2122,7 @@ "utility", "validation" ], - "time": "2019-03-22T01:00:30+00:00" + "time": "2018-09-18T10:22:16+00:00" }, { "name": "nikic/php-parser", @@ -1676,28 +2177,27 @@ }, { "name": "ocramius/package-versions", - "version": "1.4.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/Ocramius/PackageVersions.git", - "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb" + "reference": "ad8a245decad4897cc6b432743913dad0d69753c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", - "reference": "a4d4b60d0e60da2487bd21a2c6ac089f85570dbb", + "url": "https://api.github.com/repos/Ocramius/PackageVersions/zipball/ad8a245decad4897cc6b432743913dad0d69753c", + "reference": "ad8a245decad4897cc6b432743913dad0d69753c", "shasum": "" }, "require": { - "composer-plugin-api": "^1.0.0", - "php": "^7.1.0" + "composer-plugin-api": "^1.0", + "php": "~7.0" }, "require-dev": { - "composer/composer": "^1.6.3", - "doctrine/coding-standard": "^5.0.1", + "composer/composer": "^1.3", "ext-zip": "*", - "infection/infection": "^0.7.1", - "phpunit/phpunit": "^7.0.0" + "humbug/humbug": "dev-master", + "phpunit/phpunit": "^6.4" }, "type": "composer-plugin", "extra": { @@ -1722,7 +2222,7 @@ } ], "description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)", - "time": "2019-02-21T12:16:21+00:00" + "time": "2017-11-24T11:07:03+00:00" }, { "name": "paragonie/random_compat", @@ -2018,16 +2518,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "4.3.0", + "version": "4.3.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08" + "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", - "reference": "94fd0001232e47129dd3504189fa1c7225010d08", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", + "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c", "shasum": "" }, "require": { @@ -2065,7 +2565,7 @@ } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2017-11-30T07:14:17+00:00" + "time": "2019-04-30T17:48:53+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -2182,16 +2682,16 @@ }, { "name": "phpspec/prophecy", - "version": "1.8.0", + "version": "1.8.1", "source": { "type": "git", "url": "https://github.com/phpspec/prophecy.git", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", - "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/1927e75f4ed19131ec9bcc3b002e07fb1173ee76", + "reference": "1927e75f4ed19131ec9bcc3b002e07fb1173ee76", "shasum": "" }, "require": { @@ -2212,8 +2712,8 @@ } }, "autoload": { - "psr-0": { - "Prophecy\\": "src/" + "psr-4": { + "Prophecy\\": "src/Prophecy" } }, "notification-url": "https://packagist.org/downloads/", @@ -2241,7 +2741,7 @@ "spy", "stub" ], - "time": "2018-08-05T17:53:17+00:00" + "time": "2019-06-13T12:50:23+00:00" }, { "name": "phpstan/phpdoc-parser", @@ -2744,55 +3244,6 @@ "abandoned": true, "time": "2018-08-09T05:50:03+00:00" }, - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-02-14T16:28:37+00:00" - }, { "name": "psr/log", "version": "1.1.0", @@ -3401,16 +3852,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.4.1", + "version": "3.4.2", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "5b4333b4010625d29580eb4a41f1e53251be6baa" + "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/5b4333b4010625d29580eb4a41f1e53251be6baa", - "reference": "5b4333b4010625d29580eb4a41f1e53251be6baa", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", + "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", "shasum": "" }, "require": { @@ -3448,88 +3899,25 @@ "phpcs", "standards" ], - "time": "2019-03-19T03:22:27+00:00" - }, - { - "name": "symfony/config", - "version": "v4.2.5", - "source": { - "type": "git", - "url": "https://github.com/symfony/config.git", - "reference": "0e745ead307d5dcd4e163e94a47ec04b1428943f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/0e745ead307d5dcd4e163e94a47ec04b1428943f", - "reference": "0e745ead307d5dcd4e163e94a47ec04b1428943f", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "symfony/filesystem": "~3.4|~4.0", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/finder": "<3.4" - }, - "require-dev": { - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~3.4|~4.0", - "symfony/finder": "~3.4|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "symfony/yaml": "To use the yaml reference dumper" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Config\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Config Component", - "homepage": "https://symfony.com", - "time": "2019-04-01T14:03:25+00:00" + "time": "2019-04-10T23:49:02+00:00" }, { "name": "symfony/console", - "version": "v4.2.5", + "version": "v3.4.28", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "24206aff3efe6962593297e57ef697ebb220e384" + "reference": "8e1d1e406dd31727fa70cd5a99cda202e9d6a5c6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/24206aff3efe6962593297e57ef697ebb220e384", - "reference": "24206aff3efe6962593297e57ef697ebb220e384", + "url": "https://api.github.com/repos/symfony/console/zipball/8e1d1e406dd31727fa70cd5a99cda202e9d6a5c6", + "reference": "8e1d1e406dd31727fa70cd5a99cda202e9d6a5c6", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/contracts": "^1.0", + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0|~4.0", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { @@ -3541,11 +3929,11 @@ }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", + "symfony/config": "~3.3|~4.0", "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", "symfony/lock": "~3.4|~4.0", - "symfony/process": "~3.4|~4.0" + "symfony/process": "~3.3|~4.0" }, "suggest": { "psr/log": "For using the console logger", @@ -3556,7 +3944,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -3583,58 +3971,41 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2019-04-01T07:32:59+00:00" + "time": "2019-05-09T08:42:51+00:00" }, { - "name": "symfony/dependency-injection", - "version": "v4.2.5", + "name": "symfony/debug", + "version": "v3.4.28", "source": { "type": "git", - "url": "https://github.com/symfony/dependency-injection.git", - "reference": "1806e43ff6bff57398d33b326cd753a12d9f434f" + "url": "https://github.com/symfony/debug.git", + "reference": "671fc55bd14800668b1d0a3708c3714940e30a8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/1806e43ff6bff57398d33b326cd753a12d9f434f", - "reference": "1806e43ff6bff57398d33b326cd753a12d9f434f", + "url": "https://api.github.com/repos/symfony/debug/zipball/671fc55bd14800668b1d0a3708c3714940e30a8c", + "reference": "671fc55bd14800668b1d0a3708c3714940e30a8c", "shasum": "" }, "require": { - "php": "^7.1.3", - "psr/container": "^1.0", - "symfony/contracts": "^1.0" + "php": "^5.5.9|>=7.0.8", + "psr/log": "~1.0" }, "conflict": { - "symfony/config": "<4.2", - "symfony/finder": "<3.4", - "symfony/proxy-manager-bridge": "<3.4", - "symfony/yaml": "<3.4" - }, - "provide": { - "psr/container-implementation": "1.0", - "symfony/service-contracts-implementation": "1.0" + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" }, "require-dev": { - "symfony/config": "~4.2", - "symfony/expression-language": "~3.4|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "symfony/config": "", - "symfony/expression-language": "For using expressions in service container configuration", - "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" + "symfony/http-kernel": "~2.8|~3.0|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { "psr-4": { - "Symfony\\Component\\DependencyInjection\\": "" + "Symfony\\Component\\Debug\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -3654,34 +4025,34 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony DependencyInjection Component", + "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2019-03-30T15:58:42+00:00" + "time": "2019-05-18T13:32:47+00:00" }, { "name": "symfony/dotenv", - "version": "v4.2.5", + "version": "v3.4.28", "source": { "type": "git", "url": "https://github.com/symfony/dotenv.git", - "reference": "b541d63b83532be55a020db8ed2e50598385a583" + "reference": "7b33c7b6f497898a173e4b9d6a7698cd789d54ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/dotenv/zipball/b541d63b83532be55a020db8ed2e50598385a583", - "reference": "b541d63b83532be55a020db8ed2e50598385a583", + "url": "https://api.github.com/repos/symfony/dotenv/zipball/7b33c7b6f497898a173e4b9d6a7698cd789d54ce", + "reference": "7b33c7b6f497898a173e4b9d6a7698cd789d54ce", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^5.5.9|>=7.0.8" }, "require-dev": { - "symfony/process": "~3.4|~4.0" + "symfony/process": "~3.2|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -3713,35 +4084,34 @@ "env", "environment" ], - "time": "2019-04-01T07:32:59+00:00" + "time": "2019-04-01T07:08:40+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v4.2.5", + "version": "v3.4.28", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "ca5af306fbc37f3cf597e91bc9cfa0c7d3f33544" + "reference": "a088aafcefb4eef2520a290ed82e4374092a6dff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ca5af306fbc37f3cf597e91bc9cfa0c7d3f33544", - "reference": "ca5af306fbc37f3cf597e91bc9cfa0c7d3f33544", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a088aafcefb4eef2520a290ed82e4374092a6dff", + "reference": "a088aafcefb4eef2520a290ed82e4374092a6dff", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/contracts": "^1.0" + "php": "^5.5.9|>=7.0.8" }, "conflict": { - "symfony/dependency-injection": "<3.4" + "symfony/dependency-injection": "<3.3" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/stopwatch": "~3.4|~4.0" + "symfony/config": "~2.8|~3.0|~4.0", + "symfony/dependency-injection": "~3.3|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/stopwatch": "~2.8|~3.0|~4.0" }, "suggest": { "symfony/dependency-injection": "", @@ -3750,7 +4120,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -3777,128 +4147,29 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "https://symfony.com", - "time": "2019-03-30T15:58:42+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v4.2.5", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "e16b9e471703b2c60b95f14d31c1239f68f11601" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/e16b9e471703b2c60b95f14d31c1239f68f11601", - "reference": "e16b9e471703b2c60b95f14d31c1239f68f11601", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "symfony/polyfill-ctype": "~1.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2019-02-07T11:40:08+00:00" - }, - { - "name": "symfony/finder", - "version": "v4.2.5", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "267b7002c1b70ea80db0833c3afe05f0fbde580a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/267b7002c1b70ea80db0833c3afe05f0fbde580a", - "reference": "267b7002c1b70ea80db0833c3afe05f0fbde580a", - "shasum": "" - }, - "require": { - "php": "^7.1.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "time": "2019-02-23T15:42:05+00:00" + "time": "2019-04-02T08:51:52+00:00" }, { "name": "symfony/options-resolver", - "version": "v4.2.5", + "version": "v3.4.28", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "3896e5a7d06fd15fa4947694c8dcdd371ff147d1" + "reference": "ed3b397f9c07c8ca388b2a1ef744403b4d4ecc44" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/3896e5a7d06fd15fa4947694c8dcdd371ff147d1", - "reference": "3896e5a7d06fd15fa4947694c8dcdd371ff147d1", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/ed3b397f9c07c8ca388b2a1ef744403b4d4ecc44", + "reference": "ed3b397f9c07c8ca388b2a1ef744403b4d4ecc44", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": "^5.5.9|>=7.0.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -3930,7 +4201,7 @@ "configuration", "options" ], - "time": "2019-02-23T15:17:42+00:00" + "time": "2019-04-10T16:00:48+00:00" }, { "name": "symfony/polyfill-php70", @@ -4047,26 +4318,84 @@ "time": "2019-02-06T07:57:58+00:00" }, { - "name": "symfony/process", - "version": "v4.2.5", + "name": "symfony/polyfill-php73", + "version": "v1.11.0", "source": { "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "1e6cbb41dadcaf29e0db034d6ad0d039a9df06e6" + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/1e6cbb41dadcaf29e0db034d6ad0d039a9df06e6", - "reference": "1e6cbb41dadcaf29e0db034d6ad0d039a9df06e6", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", + "reference": "d1fb4abcc0c47be136208ad9d68bf59f1ee17abd", "shasum": "" }, "require": { - "php": "^7.1.3" + "php": ">=5.3.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "1.11-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2019-02-06T07:57:58+00:00" + }, + { + "name": "symfony/process", + "version": "v3.4.28", + "source": { + "type": "git", + "url": "https://github.com/symfony/process.git", + "reference": "afe411c2a6084f25cff55a01d0d4e1474c97ff13" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/process/zipball/afe411c2a6084f25cff55a01d0d4e1474c97ff13", + "reference": "afe411c2a6084f25cff55a01d0d4e1474c97ff13", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-dev" } }, "autoload": { @@ -4093,30 +4422,29 @@ ], "description": "Symfony Process Component", "homepage": "https://symfony.com", - "time": "2019-03-10T20:07:02+00:00" + "time": "2019-05-22T12:54:11+00:00" }, { "name": "symfony/stopwatch", - "version": "v4.2.5", + "version": "v3.4.28", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", - "reference": "b1a5f646d56a3290230dbc8edf2a0d62cda23f67" + "reference": "2a651c2645c10bbedd21170771f122d935e0dd58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/stopwatch/zipball/b1a5f646d56a3290230dbc8edf2a0d62cda23f67", - "reference": "b1a5f646d56a3290230dbc8edf2a0d62cda23f67", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/2a651c2645c10bbedd21170771f122d935e0dd58", + "reference": "2a651c2645c10bbedd21170771f122d935e0dd58", "shasum": "" }, "require": { - "php": "^7.1.3", - "symfony/contracts": "^1.0" + "php": "^5.5.9|>=7.0.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.2-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -4143,20 +4471,20 @@ ], "description": "Symfony Stopwatch Component", "homepage": "https://symfony.com", - "time": "2019-01-16T20:31:39+00:00" + "time": "2019-01-16T09:39:14+00:00" }, { "name": "theseer/tokenizer", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://github.com/theseer/tokenizer.git", - "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8" + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/theseer/tokenizer/zipball/1c42705be2b6c1de5904f8afacef5895cab44bf8", - "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/11336f6f84e16a720dae9d8e6ed5019efa85a0f9", + "reference": "11336f6f84e16a720dae9d8e6ed5019efa85a0f9", "shasum": "" }, "require": { @@ -4183,7 +4511,7 @@ } ], "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", - "time": "2019-04-04T09:56:43+00:00" + "time": "2019-06-13T22:48:21+00:00" }, { "name": "webmozart/assert", diff --git a/src/Bot/Client.php b/src/Bot/Client.php index 59b9827..cf21e89 100644 --- a/src/Bot/Client.php +++ b/src/Bot/Client.php @@ -13,13 +13,14 @@ namespace RetailCrm\Mg\Bot; -use RetailCrm\Common\Exception\CurlException; +use Psr\Http\Message\ResponseInterface; use RetailCrm\Common\Exception\InvalidJsonException; use RetailCrm\Common\Url; use RetailCrm\Common\Serializer; -use RetailCrm\Mg\Bot\Model; -use Exception; -use InvalidArgumentException; +use RetailCrm\Mg\Bot\Model\Request\UploadFileByUrlRequest; +use RetailCrm\Mg\Bot\Model\Response\FullFileResponse; +use RetailCrm\Mg\Bot\Model\Response\ListResponse; +use RetailCrm\Mg\Bot\Model\Response\UploadFileResponse; /** * PHP version 7.0 @@ -33,313 +34,500 @@ use InvalidArgumentException; */ class Client { + /** + * @internal + */ const VERSION = 'v1'; + /** + * @internal + */ + const ERROR_ONLY_RESPONSE = 'ErrorOnlyResponse'; + + /** + * @var HttpClient + */ protected $client; /** * Init * - * @param string $url api url - * @param string $token api key - * @param bool $debug debug flag + * @param string $url MG API URL + * @param string $token MG API Key + * @param bool $debug Enable or disable debug mode - will log all requests to STDOUT (default: false) + * @param \GuzzleHttp\HandlerStack $handler GuzzleHttp::HandlerStack instance (default: null) */ - public function __construct($url, $token, $debug = false) + public function __construct($url, $token, $debug = false, $handler = null) { $url = sprintf("%sapi/bot/%s", Url::normalizeUrl($url), self::VERSION); - $this->client = new Request($url, $token, $debug); + $this->client = new HttpClient($url, $token, $debug ? STDOUT : null, $handler); + } + + /** + * @param string $path + * @param string $method + * @param object|null $request Request parameters + * @param string $responseType + * @param bool $arrayOfObjects + * + * @return object|null + * @throws \Exception + */ + private function submitRequest( + $path, + $method, + $request, + $responseType, + $arrayOfObjects = false + ) { + $response = $this->client->makeRequest( + $path, + $method, + $request + ); + + $statusCode = $response->getStatusCode(); + $data = json_decode((string) $response->getBody(), true); + + if (json_last_error() == JSON_ERROR_NONE) { + if ($arrayOfObjects) { + return new ListResponse($responseType, $data, $statusCode); + } else { + $obj = Serializer::deserialize($data, $responseType, Serializer::S_ARRAY); + + if ($statusCode >= 400 + && method_exists($obj, 'setErrors') + && method_exists($obj, 'getErrors') + && count(call_user_func([$obj, 'getErrors'])) == 0 + ) { + call_user_func_array([$obj, 'setErrors'], [['Status Code ' . $response->getStatusCode()]]); + } + + if (method_exists($obj, 'setStatusCode')) { + call_user_func_array([$obj, 'setStatusCode'], [$statusCode]); + } + + return $obj; + } + } else { + throw new InvalidJsonException('Received invalid JSON', 1); + } + } + + /** + * @param bool $fromRoot + * @param string ...$classes + * + * @return string + */ + private static function concatClasspath($fromRoot, ...$classes) + { + $path = ''; + + foreach ($classes as $class) { + if (empty($path) && !$fromRoot) { + $path .= $class; + } else { + $path .= '\\' . $class; + } + } + + return $path; + } + + /** + * @param string ...$classes + * + * @return string + */ + private static function getEntityClass(...$classes) + { + return static::concatClasspath(true, 'RetailCrm', 'Mg', 'Bot', 'Model', 'Entity', ...$classes); + } + + /** + * @param string ...$classes + * + * @return string + */ + private static function getResponseClass(...$classes) + { + return static::concatClasspath(true, 'RetailCrm', 'Mg', 'Bot', 'Model', 'Response', ...$classes); } /** * Returns filtered bots list * - * @param Model\Request\BotsRequest $request + * @param Model\Request\BotsRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object + * @throws \Exception */ public function bots(Model\Request\BotsRequest $request) { - return $this->client->makeRequest('/bots', Request::METHOD_GET, $request, Serializer::S_ARRAY); + return $this->submitRequest( + '/bots', + HttpClient::METHOD_GET, + $request, + static::getEntityClass('Bot'), + true + ); } /** * Edit bot info * - * @param Model\Request\InfoRequest $request + * @param Model\Request\InfoRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws CurlException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object + * @throws \Exception */ public function info(Model\Request\InfoRequest $request) { - return $this->client->makeRequest('/my/info', Request::METHOD_PATCH, $request); + return $this->submitRequest( + '/my/info', + HttpClient::METHOD_PATCH, + $request, + static::getResponseClass(self::ERROR_ONLY_RESPONSE) + ); } /** * Returns filtered channels list * - * @param Model\Request\ChannelsRequest $request + * @param Model\Request\ChannelsRequest $request Request parameters * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object * @throws \Exception */ public function channels(Model\Request\ChannelsRequest $request) { - return $this->client->makeRequest('/channels', Request::METHOD_GET, $request, Serializer::S_ARRAY); + return $this->submitRequest( + '/channels', + HttpClient::METHOD_GET, + $request, + static::getEntityClass('Channel', 'Channel'), + true + ); } /** * Returns filtered chats list * - * @param Model\Request\ChatsRequest $request + * @param Model\Request\ChatsRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object + * @throws \Exception */ public function chats(Model\Request\ChatsRequest $request) { - return $this->client->makeRequest('/chats', Request::METHOD_GET, $request, Serializer::S_ARRAY); + return $this->submitRequest( + '/chats', + HttpClient::METHOD_GET, + $request, + static::getEntityClass('Chat', 'Chat'), + true + ); } /** * Returns filtered commands list * - * @param Model\Request\CommandsRequest $request + * @param Model\Request\CommandsRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object + * @throws \Exception */ public function commands(Model\Request\CommandsRequest $request) { - return $this->client->makeRequest('/my/commands', Request::METHOD_GET, $request, Serializer::S_ARRAY); + return $this->submitRequest( + '/my/commands', + HttpClient::METHOD_GET, + $request, + static::getEntityClass('Command'), + true + ); } /** * Edit commands for exact bot * - * @param Model\Request\CommandEditRequest $request + * @param Model\Request\CommandEditRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object + * @throws \Exception */ public function commandEdit(Model\Request\CommandEditRequest $request) { - return $this->client->makeRequest( + return $this->submitRequest( sprintf("/my/commands/%s", $request->getName()), - Request::METHOD_PUT, - $request + HttpClient::METHOD_PUT, + $request, + static::getResponseClass(self::ERROR_ONLY_RESPONSE) ); } /** * Delete command for exact bot * - * @param string $request + * @param string $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object + * @throws \Exception */ public function commandDelete(string $request) { - return $this->client->makeRequest(sprintf("/my/commands/%s", $request), Request::METHOD_DELETE); + return $this->submitRequest( + sprintf("/my/commands/%s", $request), + HttpClient::METHOD_DELETE, + null, + static::getResponseClass(self::ERROR_ONLY_RESPONSE) + ); } /** * Returns filtered customers list * - * @param Model\Request\CustomersRequest $request + * @param Model\Request\CustomersRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object + * @throws \Exception */ public function customers(Model\Request\CustomersRequest $request) { - return $this->client->makeRequest('/customers', Request::METHOD_GET, $request, Serializer::S_ARRAY); + return $this->submitRequest( + '/customers', + HttpClient::METHOD_GET, + $request, + static::getEntityClass('Customer'), + true + ); } /** * Returns filtered dialogs list * - * @param Model\Request\DialogsRequest $request + * @param Model\Request\DialogsRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object + * @throws \Exception */ public function dialogs(Model\Request\DialogsRequest $request) { - return $this->client->makeRequest('/dialogs', Request::METHOD_GET, $request, Serializer::S_ARRAY); + return $this->submitRequest( + '/dialogs', + HttpClient::METHOD_GET, + $request, + static::getEntityClass('Dialog'), + true + ); } /** * Assign dialog to exact user * - * @param Model\Request\DialogAssignRequest $request + * @param Model\Request\DialogAssignRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\AssignResponse|object + * @throws \Exception */ public function dialogAssign(Model\Request\DialogAssignRequest $request) { - return $this->client->makeRequest( + return $this->submitRequest( sprintf("/dialogs/%d/assign", $request->getDialogId()), - Request::METHOD_PATCH, - $request + HttpClient::METHOD_PATCH, + $request, + static::getResponseClass('AssignResponse') ); } /** * Close exact dialog * - * @param string $request + * @param string $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object + * @throws \Exception */ public function dialogClose(string $request) { - return $this->client->makeRequest(sprintf("/dialogs/%d/close", $request), Request::METHOD_DELETE); + return $this->submitRequest( + sprintf("/dialogs/%d/close", $request), + HttpClient::METHOD_DELETE, + null, + static::getResponseClass(self::ERROR_ONLY_RESPONSE) + ); } /** * Returns filtered members list * - * @param Model\Request\MembersRequest $request + * @param Model\Request\MembersRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object + * @throws \Exception */ public function members(Model\Request\MembersRequest $request) { - return $this->client->makeRequest('/members', Request::METHOD_GET, $request, Serializer::S_ARRAY); + return $this->submitRequest( + '/members', + HttpClient::METHOD_GET, + $request, + static::getEntityClass('Chat', 'ChatMember'), + true + ); } /** * Returns filtered messages list * - * @param Model\Request\MessagesRequest $request + * @param Model\Request\MessagesRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object + * @throws \Exception */ public function messages(Model\Request\MessagesRequest $request) { - return $this->client->makeRequest('/messages', Request::METHOD_GET, $request, Serializer::S_ARRAY); + return $this->submitRequest( + '/messages', + HttpClient::METHOD_GET, + $request, + self::getEntityClass('Message', 'Message'), + true + ); } /** * Send a message * - * @param Model\Request\MessageSendRequest $request + * @param Model\Request\MessageSendRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\MessageSendResponse|object + * @throws \Exception */ public function messageSend(Model\Request\MessageSendRequest $request) { - return $this->client->makeRequest('/messages', Request::METHOD_POST, $request); + return $this->submitRequest( + '/messages', + HttpClient::METHOD_POST, + $request, + static::getResponseClass('MessageSendResponse') + ); } /** * Edit a message * - * @param Model\Request\MessageEditRequest $request + * @param Model\Request\MessageEditRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\MessageSendResponse|object + * @throws \Exception */ public function messageEdit(Model\Request\MessageEditRequest $request) { - return $this->client->makeRequest('/messages/%d', Request::METHOD_PATCH, $request->getId()); + return $this->submitRequest( + sprintf("/messages/%d", $request->getId()), + HttpClient::METHOD_PATCH, + $request, + static::getResponseClass('MessageSendResponse') + ); } /** * Delete a message * - * @param string $request + * @param string $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object + * @throws \Exception */ public function messageDelete(string $request) { - return $this->client->makeRequest(sprintf("/messages/%d", $request), Request::METHOD_DELETE); + return $this->submitRequest( + sprintf("/messages/%d", $request), + HttpClient::METHOD_DELETE, + null, + static::getResponseClass(self::ERROR_ONLY_RESPONSE) + ); } /** * Returns filtered users list * - * @param Model\Request\UsersRequest $request + * @param Model\Request\UsersRequest $request Request parameters * - * @throws InvalidArgumentException - * @throws CurlException - * @throws InvalidJsonException - * @throws Exception - * - * @return Response + * @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object + * @throws \Exception */ public function users(Model\Request\UsersRequest $request) { - return $this->client->makeRequest('/users', Request::METHOD_GET, $request, Serializer::S_ARRAY); + return $this->submitRequest( + '/users', + HttpClient::METHOD_GET, + $request, + self::getEntityClass('User'), + true + ); + } + + /** + * Returns filtered users list + * + * @param string $url File URL + * + * @return \RetailCrm\Mg\Bot\Model\Response\UploadFileResponse|object + * @throws \Exception + */ + public function uploadFileByUrl(string $url) + { + $request = new UploadFileByUrlRequest(); + $request->setUrl($url); + + return $this->submitRequest( + '/files/upload_by_url', + HttpClient::METHOD_POST, + $request, + self::getResponseClass('UploadFileResponse') + ); + } + + /** + * @param string $filename + * @return Model\Response\UploadFileResponse|null + * + * @throws \Exception + */ + public function uploadFile(string $filename) + { + $response = $this->client->postFile($filename); + + if ($response instanceof ResponseInterface) { + $obj = Serializer::deserialize( + (string) $response->getBody(), + self::getResponseClass('UploadFileResponse') + ); + + return $obj instanceof UploadFileResponse ? $obj : null; + } + + return null; + } + + /** + * @param string $fileId + * @return Model\Response\FullFileResponse|null + * + * @throws \Exception + */ + public function getFileById(string $fileId) + { + $obj = $this->submitRequest( + \sprintf('/files/%s', $fileId), + HttpClient::METHOD_GET, + null, + self::getResponseClass('FullFileResponse') + ); + + return ($obj instanceof FullFileResponse) ? $obj : null; } } diff --git a/src/Bot/HttpClient.php b/src/Bot/HttpClient.php new file mode 100644 index 0000000..83fd8e3 --- /dev/null +++ b/src/Bot/HttpClient.php @@ -0,0 +1,291 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot; + +use RetailCrm\Common\Exception\InvalidJsonException; +use RetailCrm\Common\Exception\LimitException; +use InvalidArgumentException; +use RetailCrm\Common\Serializer; +use RetailCrm\Common\Url; +use Symfony\Component\Validator\Validation; +use GuzzleHttp\Client; +use GuzzleHttp\Psr7\Request; +use GuzzleHttp\Exception\GuzzleException; +use Psr\Http\Message\ResponseInterface; +use function GuzzleHttp\Psr7\stream_for; + +/** + * PHP version 7.0 + * + * HttpClient class + * + * @package RetailCrm\Mg\Bot + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class HttpClient +{ + /** + * GET HTTP Method constant + */ + const METHOD_GET = 'GET'; + + /** + * POST HTTP Method constant + */ + const METHOD_POST = 'POST'; + + /** + * PUT HTTP Method constant + */ + const METHOD_PUT = 'PUT'; + + /** + * PATCH HTTP Method constant + */ + const METHOD_PATCH = 'PATCH'; + + /** + * DELETE HTTP Method constant + */ + const METHOD_DELETE = 'DELETE'; + + protected $basePath; + protected $token; + private $allowedMethods; + private $stdout; + private $client; + + /** + * HTTP Client constructor. + * Provide $stdout (for example: STDOUT) to log all requests. + * + * @param string $url MG API URL + * @param string $token MG API Key + * @param null|resource $stdout Output to log all requests (optional, default: null) + * @param \GuzzleHttp\HandlerStack $handler GuzzleHttp::HandlerStack instance (default: null) + */ + public function __construct($url, $token, $stdout = null, $handler = null) + { + if (false === stripos($url, 'https://')) { + throw new InvalidArgumentException('API schema requires HTTPS protocol'); + } + + $this->basePath = parse_url($url, PHP_URL_PATH); + $this->token = $token; + $this->stdout = $stdout; + $this->client = new Client(array_filter([ + 'base_uri' => Url::normalizeUrl($url), + 'timeout' => 60, + 'handler' => $handler + ])); + $this->allowedMethods = [ + self::METHOD_GET, + self::METHOD_POST, + self::METHOD_PUT, + self::METHOD_PATCH, + self::METHOD_DELETE + ]; + } + + /** + * Make HTTP request + * + * @param string $path Request URL + * @param string $method Request method (default: 'GET') + * @param mixed $request Request model (default: null) + * + * @return ResponseInterface + * @throws \Exception + */ + public function makeRequest($path, $method, $request = null) + { + $getParameters = ''; + + $this->validateMethod($method); + + if (!is_null($request)) { + $this->validateRequest($request); + } + + if ($method == self::METHOD_GET && !is_null($request)) { + $getParameters = Url::buildGetParameters(Serializer::serialize($request, Serializer::S_ARRAY)); + } + + $requestBody = is_null($request) ? null : Serializer::serialize($request, Serializer::S_JSON); + $request = new Request( + $method, + \sprintf("%s%s%s", $this->basePath, $path, $getParameters), + [ + 'Content-Type' => 'application/json', + 'X-Bot-Token' => $this->token + ] + ); + + if (in_array($method, [self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_DELETE])) { + $request = $request->withBody(stream_for($requestBody)); + } + + $responseObject = null; + + try { + $responseObject = $this->client->send( + $request, + [ + 'debug' => $this->stdout, + 'allow_redirects' => true, + 'http_errors' => false, + 'verify' => false + ] + ); + } catch (GuzzleException $exception) { + throw new \Exception($exception->getMessage(), $exception->getCode(), $exception); + } + + $statusCode = $responseObject->getStatusCode(); + $response = self::parseJSON((string) $responseObject->getBody()); + $errorMessage = !empty($response['errorMsg']) ? $response['errorMsg'] : ''; + $errorMessage = !empty($response['errors']) ? $this->getErrors($response['errors']) : $errorMessage; + + /** + * responses with 400 & 460 http codes contains extended error data + * therefore they are not handled as exceptions + */ + if (in_array($statusCode, [403, 404, 500])) { + throw new \InvalidArgumentException($errorMessage); + } + + if ($statusCode == 503) { + throw new LimitException($errorMessage); + } + + return $responseObject; + } + + /** + * @param string $filename + * @return ResponseInterface|null + * + * @throws \Exception + */ + public function postFile(string $filename) + { + if (!file_exists($filename)) { + throw new \InvalidArgumentException("File doesn't exist"); + } + + if (filesize($filename) == 0) { + throw new \InvalidArgumentException("Empty file provided"); + } + + try { + $responseData = $this->client->request( + self::METHOD_POST, + \sprintf("%s/files/upload", $this->basePath), + [ + 'headers' => [ + 'X-Bot-Token' => $this->token + ], + 'body' => fopen($filename, 'r') + ] + ); + } catch (GuzzleException $exception) { + throw new \Exception($exception->getMessage(), $exception->getCode(), $exception); + } + + return isset($responseData) ? $responseData : null; + } + + /** + * Validate HTTP method + * + * @param string $method + */ + private function validateMethod($method) + { + if (!in_array($method, $this->allowedMethods, false)) { + throw new InvalidArgumentException( + sprintf( + 'Method "%s" is not valid. Allowed methods are %s', + $method, + implode(', ', $this->allowedMethods) + ) + ); + } + } + + /** + * Validate given class + * + * @param string $class + * + * @return void + */ + private function validateRequest($class) + { + if (!is_string($class) && method_exists($class, 'validate')) { + $errors = $class->validate(); + } else { + $validator = Validation::createValidatorBuilder() + ->enableAnnotationMapping() + ->getValidator(); + + $errors = $validator->validate($class); + } + + if ((is_object($errors) && call_user_func([$errors, 'count']) > 0) || is_string($errors)) { + $message = (string) $errors; + throw new InvalidArgumentException($message); + } + } + + /** + * @param array $errors + * + * @return string + */ + private function getErrors(array $errors) + { + $errorString = ''; + + foreach ($errors as $error) { + $errorString .= $error . " "; + } + + return $errorString; + } + + /** + * @param string $responseBody + * + * @return array + */ + public static function parseJSON($responseBody): array + { + $result = []; + + if (!empty($responseBody)) { + $response = json_decode($responseBody, true); + + if (!$response && JSON_ERROR_NONE !== ($error = json_last_error())) { + throw new InvalidJsonException("Invalid JSON in the API response body. Error code #$error", $error); + } + + $result = $response; + } + + return $result; + } +} diff --git a/src/Bot/Model/Entity/Bot.php b/src/Bot/Model/Entity/Bot.php new file mode 100644 index 0000000..c80dad0 --- /dev/null +++ b/src/Bot/Model/Entity/Bot.php @@ -0,0 +1,330 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * Bot class + * + * @package RetailCrm\Mg\Bot\Model\Entity + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class Bot +{ + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + */ + private $id; + + /** + * @var \DateTime $createdAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getCreatedAt",setter="setCreatedAt") + * @SkipWhenEmpty() + */ + private $createdAt; + + /** + * @var \DateTime $updatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") + * @SkipWhenEmpty() + */ + private $updatedAt; + + /** + * @var string $name + * + * @Type("string") + * @Accessor(getter="getName",setter="setName") + * @SkipWhenEmpty() + */ + private $name; + + /** + * @var array $events + * + * @Type("array") + * @Accessor(getter="getEvents",setter="setEvents") + * @SkipWhenEmpty() + */ + private $events; + + /** + * @var string $clientId + * + * @Type("string") + * @Accessor(getter="getClientId",setter="setClientId") + * @SkipWhenEmpty() + */ + private $clientId; + + /** + * @var string $avatarUrl + * + * @Type("string") + * @Accessor(getter="getAvatarUrl",setter="setAvatarUrl") + * @SkipWhenEmpty() + */ + private $avatarUrl; + + /** + * @var array $roles + * + * @Type("array") + * @Accessor(getter="getRoles",setter="setRoles") + * @SkipWhenEmpty() + */ + private $roles; + + /** + * @var string $deactivatedAt + * + * @Type("string") + * @Accessor(getter="getDeactivatedAt",setter="setDeactivatedAt") + * @SkipWhenEmpty() + */ + private $deactivatedAt; + + /** + * @var bool $isActive + * + * @Type("bool") + * @Accessor(getter="getIsActive",setter="setIsActive") + * @SkipWhenEmpty() + */ + private $isActive; + + /** + * @var bool $isSelf + * + * @Type("bool") + * @Accessor(getter="getIsSelf",setter="setIsSelf") + * @SkipWhenEmpty() + */ + private $isSelf; + + /** + * @var bool $isSystem + * + * @Type("bool") + * @Accessor(getter="getIsSystem",setter="setIsSystem") + * @SkipWhenEmpty() + */ + private $isSystem; + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return \DateTime + */ + public function getCreatedAt(): \DateTime + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt(): \DateTime + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName(string $name) + { + $this->name = $name; + } + + /** + * @return array + */ + public function getEvents(): array + { + return $this->events; + } + + /** + * @param array $events + */ + public function setEvents(array $events) + { + $this->events = $events; + } + + /** + * @return string + */ + public function getClientId(): string + { + return $this->clientId; + } + + /** + * @param string $clientId + */ + public function setClientId(string $clientId) + { + $this->clientId = $clientId; + } + + /** + * @return string + */ + public function getAvatarUrl(): string + { + return $this->avatarUrl; + } + + /** + * @param string $avatarUrl + */ + public function setAvatarUrl(string $avatarUrl) + { + $this->avatarUrl = $avatarUrl; + } + + /** + * @return array + */ + public function getRoles(): array + { + return $this->roles; + } + + /** + * @param array $roles + */ + public function setRoles(array $roles) + { + $this->roles = $roles; + } + + /** + * @return string + */ + public function getDeactivatedAt(): string + { + return $this->deactivatedAt; + } + + /** + * @param string $deactivatedAt + */ + public function setDeactivatedAt(string $deactivatedAt) + { + $this->deactivatedAt = $deactivatedAt; + } + + /** + * @return bool + */ + public function isActive(): bool + { + return $this->isActive; + } + + /** + * @param bool $isActive + */ + public function setIsActive(bool $isActive) + { + $this->isActive = $isActive; + } + + /** + * @return bool + */ + public function isSelf(): bool + { + return $this->isSelf; + } + + /** + * @param bool $isSelf + */ + public function setIsSelf(bool $isSelf) + { + $this->isSelf = $isSelf; + } + + /** + * @return bool + */ + public function isSystem(): bool + { + return $this->isSystem; + } + + /** + * @param bool $isSystem + */ + public function setIsSystem(bool $isSystem) + { + $this->isSystem = $isSystem; + } +} diff --git a/src/Bot/Model/Entity/Channel/Channel.php b/src/Bot/Model/Entity/Channel/Channel.php new file mode 100644 index 0000000..b08159a --- /dev/null +++ b/src/Bot/Model/Entity/Channel/Channel.php @@ -0,0 +1,247 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity\Channel; + +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * Channel class + * + * @package RetailCrm\Mg\Bot\Model\Entity\Channel + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class Channel +{ + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + */ + private $id; + + /** + * @var \DateTime $createdAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getCreatedAt",setter="setCreatedAt") + */ + private $createdAt; + + /** + * @var \DateTime $updatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") + */ + private $updatedAt; + + /** + * @var \DateTime $activatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getActivatedAt",setter="setActivatedAt") + */ + private $activatedAt; + + /** + * @var \DateTime $deactivatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getDeactivatedAt",setter="setDeactivatedAt") + */ + private $deactivatedAt; + + /** + * @var bool $isActive + * + * @Type("bool") + * @Accessor(getter="getIsActive",setter="setIsActive") + */ + private $isActive; + + /** + * @var ChannelSettings $settings + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelSettings") + * @Accessor(getter="getSettings",setter="setSettings") + */ + private $settings; + + /** + * @var string $type + * + * @Type("string") + * @Accessor(getter="getType",setter="setType") + */ + private $type; + + /** + * @var string $actions + * + * @Type("string") + * @Accessor(getter="getName",setter="setName") + */ + private $name; + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return \DateTime + */ + public function getCreatedAt(): \DateTime + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt(): \DateTime + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + } + + /** + * @return \DateTime + */ + public function getActivatedAt(): \DateTime + { + return $this->activatedAt; + } + + /** + * @param \DateTime $activatedAt + */ + public function setActivatedAt(\DateTime $activatedAt) + { + $this->activatedAt = $activatedAt; + } + + /** + * @return \DateTime + */ + public function getDeactivatedAt(): \DateTime + { + return $this->deactivatedAt; + } + + /** + * @param \DateTime $deactivatedAt + */ + public function setDeactivatedAt(\DateTime $deactivatedAt) + { + $this->deactivatedAt = $deactivatedAt; + } + + /** + * @return bool + */ + public function isActive(): bool + { + return $this->isActive; + } + + /** + * @param bool $isActive + */ + public function setIsActive(bool $isActive) + { + $this->isActive = $isActive; + } + + /** + * @return ChannelSettings + */ + public function getSettings(): ChannelSettings + { + return $this->settings; + } + + /** + * @param ChannelSettings $settings + */ + public function setSettings(ChannelSettings $settings) + { + $this->settings = $settings; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type) + { + $this->type = $type; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName(string $name) + { + $this->name = $name; + } +} diff --git a/src/Bot/Model/Entity/Channel/ChannelSettings.php b/src/Bot/Model/Entity/Channel/ChannelSettings.php new file mode 100644 index 0000000..591fe17 --- /dev/null +++ b/src/Bot/Model/Entity/Channel/ChannelSettings.php @@ -0,0 +1,204 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity\Channel; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * ChannelSettings class + * + * @package RetailCrm\Mg\Bot\Model\Entity\Channel + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class ChannelSettings +{ + /** + * @var ChannelSettingsStatus $status + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelSettingsStatus") + * @Accessor(getter="getStatus",setter="setStatus") + */ + private $status; + + /** + * @var bool $spamAllowed + * + * @Type("bool") + * @Accessor(getter="getStatus",setter="setStatus") + */ + private $spamAllowed; + + /** + * @var ChannelSettingsItem $text + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelSettingsItem") + * @Accessor(getter="getText",setter="setText") + * @SkipWhenEmpty() + */ + private $text; + + /** + * @var ChannelSettingsItem $product + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelSettingsItem") + * @Accessor(getter="getProduct",setter="setProduct") + * @SkipWhenEmpty() + */ + private $product; + + /** + * @var ChannelSettingsItem $order + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelSettingsItem") + * @Accessor(getter="getOrder",setter="setOrder") + * @SkipWhenEmpty() + */ + private $order; + + /** + * @var ChannelSettingsItem $image + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelSettingsItem") + * @Accessor(getter="getImage",setter="setImage") + * @SkipWhenEmpty() + */ + private $image; + + /** + * @var ChannelSettingsItem $file + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelSettingsItem") + * @Accessor(getter="getFile",setter="setFile") + * @SkipWhenEmpty() + */ + private $file; + + /** + * @return ChannelSettingsStatus + */ + public function getStatus(): ChannelSettingsStatus + { + return $this->status; + } + + /** + * @param ChannelSettingsStatus $status + */ + public function setStatus(ChannelSettingsStatus $status) + { + $this->status = $status; + } + + /** + * @return bool + */ + public function isSpamAllowed(): bool + { + return $this->spamAllowed; + } + + /** + * @param bool $spamAllowed + */ + public function setSpamAllowed(bool $spamAllowed) + { + $this->spamAllowed = $spamAllowed; + } + + /** + * @return ChannelSettingsItem + */ + public function getText(): ChannelSettingsItem + { + return $this->text; + } + + /** + * @param ChannelSettingsItem $text + */ + public function setText(ChannelSettingsItem $text) + { + $this->text = $text; + } + + /** + * @return ChannelSettingsItem + */ + public function getProduct(): ChannelSettingsItem + { + return $this->product; + } + + /** + * @param ChannelSettingsItem $product + */ + public function setProduct(ChannelSettingsItem $product) + { + $this->product = $product; + } + + /** + * @return ChannelSettingsItem + */ + public function getOrder(): ChannelSettingsItem + { + return $this->order; + } + + /** + * @param ChannelSettingsItem $order + */ + public function setOrder(ChannelSettingsItem $order) + { + $this->order = $order; + } + + /** + * @return ChannelSettingsItem + */ + public function getImage(): ChannelSettingsItem + { + return $this->image; + } + + /** + * @param ChannelSettingsItem $image + */ + public function setImage(ChannelSettingsItem $image) + { + $this->image = $image; + } + + /** + * @return ChannelSettingsItem + */ + public function getFile(): ChannelSettingsItem + { + return $this->file; + } + + /** + * @param ChannelSettingsItem $file + */ + public function setFile(ChannelSettingsItem $file) + { + $this->file = $file; + } +} diff --git a/src/Bot/Model/Entity/Channel/ChannelSettingsItem.php b/src/Bot/Model/Entity/Channel/ChannelSettingsItem.php new file mode 100644 index 0000000..7176c04 --- /dev/null +++ b/src/Bot/Model/Entity/Channel/ChannelSettingsItem.php @@ -0,0 +1,231 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity\Channel; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * ChannelSettingsItem class + * + * @package RetailCrm\Mg\Bot\Model\Entity\Channel + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class ChannelSettingsItem +{ + /** + * @var string $creating + * + * @Type("string") + * @Accessor(getter="getCreating",setter="setCreating") + * @SkipWhenEmpty() + */ + private $creating; + + /** + * @var string $editing + * + * @Type("string") + * @Accessor(getter="getEditing",setter="setEditing") + * @SkipWhenEmpty() + */ + private $editing; + + /** + * @var string $quoting + * + * @Type("string") + * @Accessor(getter="getQuoting",setter="setQuoting") + * @SkipWhenEmpty() + */ + private $quoting; + + /** + * @var string $deleting + * + * @Type("string") + * @Accessor(getter="getDeleting",setter="setDeleting") + * @SkipWhenEmpty() + */ + private $deleting; + + /** + * @var string $delivered + * + * @Type("string") + * @Accessor(getter="getDelivered",setter="setDelivered") + * @SkipWhenEmpty() + */ + private $delivered; + + /** + * @var int $maxCharsCount + * + * @Type("int") + * @Accessor(getter="getMaxCharsCount",setter="setMaxCharsCount") + * @SkipWhenEmpty() + */ + private $maxCharsCount; + + /** + * @var int $maxItemsCount + * + * @Type("int") + * @Accessor(getter="getMaxItemsCount",setter="setMaxItemsCount") + * @SkipWhenEmpty() + */ + private $maxItemsCount; + + /** + * @var int $noteMaxCharsCount + * + * @Type("int") + * @Accessor(getter="getNoteMaxCharsCount", setter="setNoteMaxCharsCount") + * @SkipWhenEmpty() + */ + private $noteMaxCharsCount; + + /** + * @return string + */ + public function getCreating(): string + { + return $this->creating; + } + + /** + * @param string $creating + */ + public function setCreating(string $creating) + { + $this->creating = $creating; + } + + /** + * @return string + */ + public function getEditing(): string + { + return $this->editing; + } + + /** + * @param string $editing + */ + public function setEditing(string $editing) + { + $this->editing = $editing; + } + + /** + * @return string + */ + public function getQuoting(): string + { + return $this->quoting; + } + + /** + * @param string $quoting + */ + public function setQuoting(string $quoting) + { + $this->quoting = $quoting; + } + + /** + * @return string + */ + public function getDeleting(): string + { + return $this->deleting; + } + + /** + * @param string $deleting + */ + public function setDeleting(string $deleting) + { + $this->deleting = $deleting; + } + + /** + * @return string + */ + public function getDelivered(): string + { + return $this->delivered; + } + + /** + * @param string $delivered + */ + public function setDelivered(string $delivered) + { + $this->delivered = $delivered; + } + + /** + * @return int + */ + public function getMaxCharsCount(): int + { + return $this->maxCharsCount; + } + + /** + * @param int $maxCharsCount + */ + public function setMaxCharsCount(int $maxCharsCount) + { + $this->maxCharsCount = $maxCharsCount; + } + + /** + * @return int + */ + public function getMaxItemsCount(): int + { + return $this->maxItemsCount; + } + + /** + * @param int $maxItemsCount + */ + public function setMaxItemsCount(int $maxItemsCount) + { + $this->maxItemsCount = $maxItemsCount; + } + + /** + * @return int + */ + public function getNoteMaxCharsCount(): int + { + return $this->noteMaxCharsCount; + } + + /** + * @param int $noteMaxCharsCount + */ + public function setNoteMaxCharsCount(int $noteMaxCharsCount) + { + $this->noteMaxCharsCount = $noteMaxCharsCount; + } +} diff --git a/src/Bot/Model/Entity/Channel/ChannelSettingsStatus.php b/src/Bot/Model/Entity/Channel/ChannelSettingsStatus.php new file mode 100644 index 0000000..38f4cff --- /dev/null +++ b/src/Bot/Model/Entity/Channel/ChannelSettingsStatus.php @@ -0,0 +1,81 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity\Channel; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * ChannelSettingsStatus class + * + * @package RetailCrm\Mg\Bot\Model\Entity\Channel + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class ChannelSettingsStatus +{ + /** + * @var string $delivered + * + * @Type("string") + * @Accessor(getter="getDelivered",setter="setDelivered") + * @SkipWhenEmpty() + */ + private $delivered; + + /** + * @var string $read + * + * @Type("string") + * @Accessor(getter="getRead",setter="setRead") + * @SkipWhenEmpty() + */ + private $read; + + /** + * @return string + */ + public function getDelivered(): string + { + return $this->delivered; + } + + /** + * @param string $delivered + */ + public function setDelivered(string $delivered) + { + $this->delivered = $delivered; + } + + /** + * @return string + */ + public function getRead(): string + { + return $this->read; + } + + /** + * @param string $read + */ + public function setRead(string $read) + { + $this->read = $read; + } +} diff --git a/src/Bot/Model/Entity/Chat/Chat.php b/src/Bot/Model/Entity/Chat/Chat.php new file mode 100644 index 0000000..c55469d --- /dev/null +++ b/src/Bot/Model/Entity/Chat/Chat.php @@ -0,0 +1,298 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity\Chat; + +use RetailCrm\Mg\Bot\Model\Entity\Channel\Channel; +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; +use RetailCrm\Mg\Bot\Model\Entity\Customer; + +/** + * PHP version 7.0 + * + * Chat class + * + * @package RetailCrm\Mg\Bot\Model\Entity\Chat + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class Chat +{ + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + */ + private $id; + + /** + * @var \DateTime $createdAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getCreatedAt",setter="setCreatedAt") + */ + private $createdAt; + + /** + * @var \DateTime $updatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") + */ + private $updatedAt; + + /** + * @var string $avatar + * + * @Type("string") + * @Accessor(getter="getAvatar",setter="setAvatar") + */ + private $avatar; + + /** + * @var string $name + * + * @Type("string") + * @Accessor(getter="getName",setter="setName") + */ + private $name; + + /** + * @var Channel $channel + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\Channel") + * @Accessor(getter="getChannel",setter="setChannel") + * @SkipWhenEmpty() + */ + private $channel; + + /** + * @var array $members + * + * @Type("array") + * @Accessor(getter="getMembers",setter="setMembers") + */ + private $members; + + /** + * @var Customer $customer + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Customer") + * @Accessor(getter="getCustomer",setter="setCustomer") + */ + private $customer; + + /** + * @var int $authorId + * + * @Type("int") + * @Accessor(getter="getAuthorId",setter="setAuthorId") + */ + private $authorId; + + /** + * @var ChatLastMessage $lastMessage + * + * @Type("ChatLastMessage") + * @Accessor(getter="getLastMessage",setter="setLastMessage") + */ + private $lastMessage; + + /** + * @var \DateTime $lastActivity + * + * @Type("DateTime<'Y-m-d\TH:i:sP'>") + * @Accessor(getter="getLastActivity",setter="setLastActivity") + */ + private $lastActivity; + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return \DateTime + */ + public function getCreatedAt(): \DateTime + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt(): \DateTime + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + } + + /** + * @return string + */ + public function getAvatar(): string + { + return $this->avatar; + } + + /** + * @param string $avatar + */ + public function setAvatar(string $avatar) + { + $this->avatar = $avatar; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName(string $name) + { + $this->name = $name; + } + + /** + * @return Channel + */ + public function getChannel(): Channel + { + return $this->channel; + } + + /** + * @param Channel $channel + */ + public function setChannel(Channel $channel) + { + $this->channel = $channel; + } + + /** + * @return array + */ + public function getMembers(): array + { + return $this->members; + } + + /** + * @param array $members + */ + public function setMembers(array $members) + { + $this->members = $members; + } + + /** + * @return Customer + */ + public function getCustomer(): Customer + { + return $this->customer; + } + + /** + * @param Customer $customer + */ + public function setCustomer(Customer $customer) + { + $this->customer = $customer; + } + + /** + * @return int + */ + public function getAuthorId(): int + { + return $this->authorId; + } + + /** + * @param int $authorId + */ + public function setAuthorId(int $authorId) + { + $this->authorId = $authorId; + } + + /** + * @return ChatLastMessage + */ + public function getLastMessage(): ChatLastMessage + { + return $this->lastMessage; + } + + /** + * @param ChatLastMessage $lastMessage + */ + public function setLastMessage(ChatLastMessage $lastMessage) + { + $this->lastMessage = $lastMessage; + } + + /** + * @return \DateTime + */ + public function getLastActivity(): \DateTime + { + return $this->lastActivity; + } + + /** + * @param \DateTime $lastActivity + */ + public function setLastActivity(\DateTime $lastActivity) + { + $this->lastActivity = $lastActivity; + } +} diff --git a/src/Bot/Model/Entity/Chat/ChatLastMessage.php b/src/Bot/Model/Entity/Chat/ChatLastMessage.php new file mode 100644 index 0000000..0026569 --- /dev/null +++ b/src/Bot/Model/Entity/Chat/ChatLastMessage.php @@ -0,0 +1,106 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity\Chat; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * ChatLastMessage class + * + * @package RetailCrm\Mg\Bot\Model\Entity\Chat + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class ChatLastMessage +{ + /** + * @var int $creating + * + * @Type("int") + * @Accessor(getter="getId",setter="setId") + * @SkipWhenEmpty() + */ + private $id; + + /** + * @var \DateTime $time + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getTime",setter="setTime") + * @SkipWhenEmpty() + */ + private $time; + + /** + * @var string $type + * + * @Type("string") + * @Accessor(getter="getType",setter="setType") + * @SkipWhenEmpty() + */ + private $type; + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $id + */ + public function setId(int $id) + { + $this->id = $id; + } + + /** + * @return \DateTime + */ + public function getTime(): \DateTime + { + return $this->time; + } + + /** + * @param \DateTime $time + */ + public function setTime(\DateTime $time) + { + $this->time = $time; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type) + { + $this->type = $type; + } +} diff --git a/src/Bot/Model/Entity/Chat/ChatMember.php b/src/Bot/Model/Entity/Chat/ChatMember.php new file mode 100644 index 0000000..36509f3 --- /dev/null +++ b/src/Bot/Model/Entity/Chat/ChatMember.php @@ -0,0 +1,204 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity\Chat; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * ChatMember class + * + * @package RetailCrm\Mg\Bot\Model\Entity\Chat + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class ChatMember +{ + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + */ + private $id; + + /** + * @var \DateTime $createdAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getCreatedAt",setter="setCreatedAt") + */ + private $createdAt; + + /** + * @var \DateTime $updatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") + * @SkipWhenEmpty() + */ + private $updatedAt; + + /** + * @var int $chatId + * + * @Type("int") + * @Accessor(getter="getChatId",setter="setChatId") + * @SkipWhenEmpty() + */ + private $chatId; + + /** + * @var int $userId + * + * @Type("int") + * @Accessor(getter="getUserId",setter="setUserId") + * @SkipWhenEmpty() + */ + private $userId; + + /** + * @var bool $isAuthor + * + * @Type("bool") + * @Accessor(getter="getIsAuthor",setter="setIsAuthor") + * @SkipWhenEmpty() + */ + private $isAuthor; + + /** + * @var string $creating + * + * @Type("string") + * @Accessor(getter="getState",setter="setState") + * @SkipWhenEmpty() + */ + private $state; + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return \DateTime + */ + public function getCreatedAt(): \DateTime + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt(): \DateTime + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + } + + /** + * @return int + */ + public function getChatId(): int + { + return $this->chatId; + } + + /** + * @param int $chatId + */ + public function setChatId(int $chatId) + { + $this->chatId = $chatId; + } + + /** + * @return int + */ + public function getUserId(): int + { + return $this->userId; + } + + /** + * @param int $userId + */ + public function setUserId(int $userId) + { + $this->userId = $userId; + } + + /** + * @return bool + */ + public function isAuthor(): bool + { + return $this->isAuthor; + } + + /** + * @param bool $isAuthor + */ + public function setIsAuthor(bool $isAuthor) + { + $this->isAuthor = $isAuthor; + } + + /** + * @return string + */ + public function getState(): string + { + return $this->state; + } + + /** + * @param string $state + */ + public function setState(string $state) + { + $this->state = $state; + } +} diff --git a/src/Bot/Model/Entity/Command.php b/src/Bot/Model/Entity/Command.php new file mode 100644 index 0000000..da08a77 --- /dev/null +++ b/src/Bot/Model/Entity/Command.php @@ -0,0 +1,154 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * Command class + * + * @package RetailCrm\Mg\Bot\Model\Entity + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class Command +{ + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + */ + private $id; + + /** + * @var \DateTime $createdAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getCreatedAt",setter="setCreatedAt") + */ + private $createdAt; + + /** + * @var \DateTime $updatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") + * @SkipWhenEmpty() + */ + private $updatedAt; + + /** + * @var string $name + * + * @Type("string") + * @Accessor(getter="getName",setter="setName") + * @SkipWhenEmpty() + */ + private $name; + + /** + * @var string $description + * + * @Type("string") + * @Accessor(getter="getDescrtiption",setter="setDescription") + * @SkipWhenEmpty() + */ + private $description; + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return \DateTime + */ + public function getCreatedAt(): \DateTime + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt(): \DateTime + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName(string $name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getDescription(): string + { + return $this->description; + } + + /** + * @param string $description + */ + public function setDescription(string $description) + { + $this->description = $description; + } +} diff --git a/src/Bot/Model/Entity/Customer.php b/src/Bot/Model/Entity/Customer.php new file mode 100644 index 0000000..66d72bb --- /dev/null +++ b/src/Bot/Model/Entity/Customer.php @@ -0,0 +1,417 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity; + +use Symfony\Component\Validator\Constraints as Assert; +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * Customer class + * | email | string | + * + * @package RetailCrm\Mg\Bot\Model\Entity + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class Customer +{ + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + */ + private $id; + + /** + * @var \DateTime $createdAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getCreatedAt",setter="setCreatedAt") + */ + private $createdAt; + + /** + * @var \DateTime $updatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") + * @SkipWhenEmpty() + */ + private $updatedAt; + + /** + * @var string $externalId + * + * @Type("string") + * @Accessor(getter="getExternalId",setter="setExternalId") + * @SkipWhenEmpty() + * @Assert\Length(max="64") + * @Assert\NotNull() + */ + private $externalId; + + /** + * @var int $channelId + * + * @Type("int") + * @Accessor(getter="getChannelId",setter="setChannelId") + * @SkipWhenEmpty() + */ + private $channelId; + + /** + * @var string $username + * + * @Type("string") + * @Accessor(getter="getUsername",setter="setUsername") + * @SkipWhenEmpty() + * @Assert\Length(max="255") + */ + private $username; + + /** + * @var string $firstName + * + * @Type("string") + * @Accessor(getter="getFirstName",setter="setFirstName") + * @SkipWhenEmpty() + * @Assert\Length(max="255") + */ + private $firstName; + + /** + * @var string $lastName + * + * @Type("string") + * @Accessor(getter="getLastName",setter="setLastName") + * @SkipWhenEmpty() + * @Assert\Length(max="255") + */ + private $lastName; + + /** + * @var string $avatarUrl + * + * @Type("string") + * @Accessor(getter="getAvatarUrl",setter="setAvatarUrl") + * @SkipWhenEmpty() + * @Assert\Length(max="255") + */ + private $avatarUrl; + + /** + * @var string $profileUrl + * + * @Type("string") + * @Accessor(getter="getProfileUrl",setter="setProfileUrl") + * @SkipWhenEmpty() + * @Assert\Length(max="255") + */ + private $profileUrl; + + /** + * @var string $revokedAt + * + * @Type("string") + * @Accessor(getter="getRevokedAt",setter="setRevokedAt") + * @SkipWhenEmpty() + */ + private $revokedAt; + + /** + * @var string $country + * + * @Type("string") + * @Accessor(getter="getCountry",setter="setCountry") + * @SkipWhenEmpty() + * @Assert\Length(max="2") + */ + private $country; + + /** + * @var string $language + * + * @Type("string") + * @Accessor(getter="getLanguage",setter="setLanguage") + * @SkipWhenEmpty() + * @Assert\Length(max="20") + */ + private $language; + + /** + * @var string $phone + * + * @Type("string") + * @Accessor(getter="getPhone",setter="setPhone") + * @SkipWhenEmpty() + * @Assert\Length(max="16") + */ + private $phone; + + /** + * @var string $email + * + * @Type("string") + * @Accessor(getter="getEmail",setter="setEmail") + * @SkipWhenEmpty() + * @Assert\Length(max="16") + */ + private $email; + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return \DateTime + */ + public function getCreatedAt(): \DateTime + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt(): \DateTime + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $externalId + */ + public function setExternalId(string $externalId) + { + $this->externalId = $externalId; + } + + /** + * @return int + */ + public function getChannelId(): int + { + return $this->channelId; + } + + /** + * @param int $channelId + */ + public function setChannelId(int $channelId) + { + $this->channelId = $channelId; + } + + /** + * @return string + */ + public function getUsername(): string + { + return $this->username; + } + + /** + * @param string $username + */ + public function setUsername(string $username) + { + $this->username = $username; + } + + /** + * @return string + */ + public function getFirstName(): string + { + return $this->firstName; + } + + /** + * @param string $firstName + */ + public function setFirstName(string $firstName) + { + $this->firstName = $firstName; + } + + /** + * @return string + */ + public function getLastName(): string + { + return $this->lastName; + } + + /** + * @param string $lastName + */ + public function setLastName(string $lastName) + { + $this->lastName = $lastName; + } + + /** + * @return string + */ + public function getAvatarUrl(): string + { + return $this->avatarUrl; + } + + /** + * @param string $avatarUrl + */ + public function setAvatarUrl(string $avatarUrl) + { + $this->avatarUrl = $avatarUrl; + } + + /** + * @return string + */ + public function getProfileUrl(): string + { + return $this->profileUrl; + } + + /** + * @param string $profileUrl + */ + public function setProfileUrl(string $profileUrl) + { + $this->profileUrl = $profileUrl; + } + + /** + * @return string + */ + public function getRevokedAt(): string + { + return $this->revokedAt; + } + + /** + * @param string $revokedAt + */ + public function setRevokedAt(string $revokedAt) + { + $this->revokedAt = $revokedAt; + } + + /** + * @return string + */ + public function getCountry(): string + { + return $this->country; + } + + /** + * @param string $country + */ + public function setCountry(string $country) + { + $this->country = $country; + } + + /** + * @return string + */ + public function getLanguage(): string + { + return $this->language; + } + + /** + * @param string $language + */ + public function setLanguage(string $language) + { + $this->language = $language; + } + + /** + * @return string + */ + public function getPhone(): string + { + return $this->phone; + } + + /** + * @param string $phone + */ + public function setPhone(string $phone) + { + $this->phone = $phone; + } + + /** + * @return string + */ + public function getEmail(): string + { + return $this->email; + } + + /** + * @param string $email + */ + public function setEmail(string $email) + { + $this->email = $email; + } +} diff --git a/src/Bot/Model/Entity/Dialog.php b/src/Bot/Model/Entity/Dialog.php new file mode 100644 index 0000000..b155404 --- /dev/null +++ b/src/Bot/Model/Entity/Dialog.php @@ -0,0 +1,304 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * Dialog class + * + * @package RetailCrm\Mg\Bot\Model\Entity + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class Dialog +{ + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + */ + private $id; + + /** + * @var \DateTime $createdAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getCreatedAt",setter="setCreatedAt") + */ + private $createdAt; + + /** + * @var \DateTime $updatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") + * @SkipWhenEmpty() + */ + private $updatedAt; + + /** + * @var int $botId + * + * @Type("int") + * @Accessor(getter="getBotId",setter="setBotId") + * @SkipWhenEmpty() + */ + private $botId; + + /** + * @var int $chatId + * + * @Type("int") + * @Accessor(getter="getChatId",setter="setChatId") + * @SkipWhenEmpty() + */ + private $chatId; + + /** + * @var int $beginMessageId + * + * @Type("int") + * @Accessor(getter="getBeginMessageId",setter="setBeginMessageId") + * @SkipWhenEmpty() + */ + private $beginMessageId; + + /** + * @var int $endingMessageId + * + * @Type("int") + * @Accessor(getter="getEndingMessageId",setter="setEndingMessageId") + * @SkipWhenEmpty() + */ + private $endingMessageId; + + /** + * @var \DateTime $closedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getClosedAt",setter="setClosedAt") + * @SkipWhenEmpty() + */ + private $closedAt; + + /** + * @var bool $isAssigned + * + * @Type("bool") + * @Accessor(getter="getIsAssigned",setter="setIsAssigned") + * @SkipWhenEmpty() + */ + private $isAssigned; + + /** + * @var Responsible $responsible + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Responsible") + * @Accessor(getter="getResponsible",setter="setResponsible") + * @SkipWhenEmpty() + */ + private $responsible; + + /** + * @var bool $isActive + * + * @Type("bool") + * @Accessor(getter="getIsActive",setter="setIsActive") + * @SkipWhenEmpty() + */ + private $isActive; + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return \DateTime + */ + public function getCreatedAt(): \DateTime + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt(): \DateTime + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + } + + /** + * @return int + */ + public function getBotId(): int + { + return $this->botId; + } + + /** + * @param int $botId + */ + public function setBotId(int $botId) + { + $this->botId = $botId; + } + + /** + * @return int + */ + public function getChatId(): int + { + return $this->chatId; + } + + /** + * @param int $chatId + */ + public function setChatId(int $chatId) + { + $this->chatId = $chatId; + } + + /** + * @return int + */ + public function getBeginMessageId(): int + { + return $this->beginMessageId; + } + + /** + * @param int $beginMessageId + */ + public function setBeginMessageId(int $beginMessageId) + { + $this->beginMessageId = $beginMessageId; + } + + /** + * @return int + */ + public function getEndingMessageId(): int + { + return $this->endingMessageId; + } + + /** + * @param int $endingMessageId + */ + public function setEndingMessageId(int $endingMessageId) + { + $this->endingMessageId = $endingMessageId; + } + + /** + * @return \DateTime + */ + public function getClosedAt(): \DateTime + { + return $this->closedAt; + } + + /** + * @param \DateTime $closedAt + */ + public function setClosedAt(\DateTime $closedAt) + { + $this->closedAt = $closedAt; + } + + /** + * @return bool + */ + public function isAssigned(): bool + { + return $this->isAssigned; + } + + /** + * @param bool $isAssigned + */ + public function setIsAssigned(bool $isAssigned) + { + $this->isAssigned = $isAssigned; + } + + /** + * @return Responsible + */ + public function getResponsible(): Responsible + { + return $this->responsible; + } + + /** + * @param Responsible $responsible + */ + public function setResponsible(Responsible $responsible) + { + $this->responsible = $responsible; + } + + /** + * @return bool + */ + public function isActive(): bool + { + return $this->isActive; + } + + /** + * @param bool $isActive + */ + public function setIsActive(bool $isActive) + { + $this->isActive = $isActive; + } +} diff --git a/src/Bot/Model/Entity/FileMeta.php b/src/Bot/Model/Entity/FileMeta.php new file mode 100644 index 0000000..56b0b24 --- /dev/null +++ b/src/Bot/Model/Entity/FileMeta.php @@ -0,0 +1,81 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * FileMeta class + * + * @package RetailCrm\Mg\Bot\Model\Entity + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class FileMeta +{ + /** + * @var int $height + * + * @Type("int") + * @Accessor(getter="getHeight",setter="setHeight") + * @SkipWhenEmpty() + */ + private $height; + + /** + * @var int $width + * + * @Type("int") + * @Accessor(getter="getWidth",setter="setWidth") + * @SkipWhenEmpty() + */ + private $width; + + /** + * @return int + */ + public function getHeight(): int + { + return $this->height; + } + + /** + * @param int $height + */ + public function setHeight(int $height) + { + $this->height = $height; + } + + /** + * @return int + */ + public function getWidth(): int + { + return $this->width; + } + + /** + * @param int $width + */ + public function setWidth(int $width) + { + $this->width = $width; + } +} diff --git a/src/Bot/Model/Entity/Item.php b/src/Bot/Model/Entity/Message/Item.php similarity index 71% rename from src/Bot/Model/Entity/Item.php rename to src/Bot/Model/Entity/Message/Item.php index 9e6ad82..65fc1cb 100644 --- a/src/Bot/Model/Entity/Item.php +++ b/src/Bot/Model/Entity/Message/Item.php @@ -5,13 +5,13 @@ * * Item entity * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Mg\Bot\Model\Entity; +namespace RetailCrm\Mg\Bot\Model\Entity\Message; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; @@ -22,7 +22,7 @@ use JMS\Serializer\Annotation\Type; * * Item class * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers @@ -38,6 +38,15 @@ class Item */ private $id; + /** + * @var int $size + * + * @Type("int") + * @Accessor(getter="getSize",setter="setSize") + * @SkipWhenEmpty() + */ + private $size; + /** * @var string $caption * @@ -63,6 +72,22 @@ class Item $this->id = $id; } + /** + * @return int + */ + public function getSize(): int + { + return $this->size; + } + + /** + * @param int $size + */ + public function setSize(int $size) + { + $this->size = $size; + } + /** * @return string */ diff --git a/src/Bot/Model/Entity/Message/Message.php b/src/Bot/Model/Entity/Message/Message.php new file mode 100644 index 0000000..8776d69 --- /dev/null +++ b/src/Bot/Model/Entity/Message/Message.php @@ -0,0 +1,531 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity\Message; + +use RetailCrm\Mg\Bot\Model\Entity\Dialog; +use RetailCrm\Mg\Bot\Model\Entity\User; +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * Message class + * + * @package RetailCrm\Mg\Bot\Model\Entity\Message + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class Message +{ + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + */ + private $id; + + /** + * @var \DateTime $createdAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getCreatedAt",setter="setCreatedAt") + */ + private $createdAt; + + /** + * @var \DateTime $updatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") + * @SkipWhenEmpty() + */ + private $updatedAt; + + /** + * @var string $actions + * + * @Type("string") + * @Accessor(getter="getActions",setter="setActions") + * @SkipWhenEmpty() + */ + private $actions; + + /** + * @var array $items + * + * @Type("array") + * @Accessor(getter="getItems",setter="setItems") + * @SkipWhenEmpty() + */ + private $items; + + /** + * @var User $from + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\User") + * @Accessor(getter="getFrom",setter="setFrom") + * @SkipWhenEmpty() + */ + private $from; + + /** + * @var \DateTime $time + * + * @Type("DateTime<'Y-m-d\TH:i:sP'>") + * @Accessor(getter="getTime",setter="setTime") + * @SkipWhenEmpty() + */ + private $time; + + /** + * @var string $type + * + * @Type("string") + * @Accessor(getter="getType",setter="setType") + * @SkipWhenEmpty() + */ + private $type; + + /** + * @var string $scope + * + * @Type("string") + * @Accessor(getter="getScope",setter="setScope") + * @SkipWhenEmpty() + */ + private $scope; + + /** + * @var int $chatId + * + * @Type("int") + * @Accessor(getter="getChatId",setter="setChatId") + * @SkipWhenEmpty() + */ + private $chatId; + + /** + * @var string $content + * + * @Type("string") + * @Accessor(getter="getContent",setter="setContent") + * @SkipWhenEmpty() + */ + private $content; + + /** + * @var bool $isRead + * + * @Type("bool") + * @Accessor(getter="getIsRead",setter="setIsRead") + * @SkipWhenEmpty() + */ + private $isRead; + + /** + * @var bool $isEdit + * + * @Type("bool") + * @Accessor(getter="getIsEdit",setter="setIsEdit") + * @SkipWhenEmpty() + */ + private $isEdit; + + /** + * @var string $status + * + * @Type("string") + * @Accessor(getter="getStatus",setter="setStatus") + * @SkipWhenEmpty() + */ + private $status; + + /** + * @var string $action + * + * @Type("string") + * @Accessor(getter="getAction",setter="setAction") + * @SkipWhenEmpty() + */ + private $action; + + /** + * @var Dialog $dialog + * + * @Type("Dialog") + * @Accessor(getter="getDialog",setter="setDialog") + * @SkipWhenEmpty() + */ + private $dialog; + + /** + * @var int $channelId + * + * @Type("int") + * @Accessor(getter="getChannelId",setter="setChannelId") + * @SkipWhenEmpty() + */ + private $channelId; + + /** + * @var \DateTime $channelSentAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getChannelSentAt",setter="setChannelSentAt") + * @SkipWhenEmpty() + */ + private $channelSentAt; + + /** + * @var MessageOrder $order + * + * @Type("MessageOrder") + * @Accessor(getter="getOrder",setter="setOrder") + * @SkipWhenEmpty() + */ + private $order; + + /** + * @var MessageProduct $product + * + * @Type("MessageProduct") + * @Accessor(getter="getProduct",setter="setProduct") + * @SkipWhenEmpty() + */ + private $product; + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return \DateTime + */ + public function getCreatedAt(): \DateTime + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt(): \DateTime + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + } + + /** + * @return string + */ + public function getActions(): string + { + return $this->actions; + } + + /** + * @param string $actions + */ + public function setActions(string $actions) + { + $this->actions = $actions; + } + + /** + * @return array + */ + public function getItems(): array + { + return $this->items; + } + + /** + * @param array $items + */ + public function setItems(array $items) + { + $this->items = $items; + } + + /** + * @return User + */ + public function getFrom(): User + { + return $this->from; + } + + /** + * @param User $from + */ + public function setFrom(User $from) + { + $this->from = $from; + } + + /** + * @return \DateTime + */ + public function getTime(): \DateTime + { + return $this->time; + } + + /** + * @param \DateTime $time + */ + public function setTime(\DateTime $time) + { + $this->time = $time; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type) + { + $this->type = $type; + } + + /** + * @return string + */ + public function getScope(): string + { + return $this->scope; + } + + /** + * @param string $scope + */ + public function setScope(string $scope) + { + $this->scope = $scope; + } + + /** + * @return int + */ + public function getChatId(): int + { + return $this->chatId; + } + + /** + * @param int $chatId + */ + public function setChatId(int $chatId) + { + $this->chatId = $chatId; + } + + /** + * @return string + */ + public function getContent(): string + { + return $this->content; + } + + /** + * @param string $content + */ + public function setContent(string $content) + { + $this->content = $content; + } + + /** + * @return bool + */ + public function isRead(): bool + { + return $this->isRead; + } + + /** + * @param bool $isRead + */ + public function setIsRead(bool $isRead) + { + $this->isRead = $isRead; + } + + /** + * @return bool + */ + public function isEdit(): bool + { + return $this->isEdit; + } + + /** + * @param bool $isEdit + */ + public function setIsEdit(bool $isEdit) + { + $this->isEdit = $isEdit; + } + + /** + * @return string + */ + public function getStatus(): string + { + return $this->status; + } + + /** + * @param string $status + */ + public function setStatus(string $status) + { + $this->status = $status; + } + + /** + * @return string + */ + public function getAction(): string + { + return $this->action; + } + + /** + * @param string $action + */ + public function setAction(string $action) + { + $this->action = $action; + } + + /** + * @return Dialog + */ + public function getDialog(): Dialog + { + return $this->dialog; + } + + /** + * @param Dialog $dialog + */ + public function setDialog(Dialog $dialog) + { + $this->dialog = $dialog; + } + + /** + * @return int + */ + public function getChannelId(): int + { + return $this->channelId; + } + + /** + * @param int $channelId + */ + public function setChannelId(int $channelId) + { + $this->channelId = $channelId; + } + + /** + * @return \DateTime + */ + public function getChannelSentAt(): \DateTime + { + return $this->channelSentAt; + } + + /** + * @param \DateTime $channelSentAt + */ + public function setChannelSentAt(\DateTime $channelSentAt) + { + $this->channelSentAt = $channelSentAt; + } + + /** + * @return MessageOrder + */ + public function getOrder(): MessageOrder + { + return $this->order; + } + + /** + * @param MessageOrder $order + */ + public function setOrder(MessageOrder $order) + { + $this->order = $order; + } + + /** + * @return MessageProduct + */ + public function getProduct(): MessageProduct + { + return $this->product; + } + + /** + * @param MessageProduct $product + */ + public function setProduct(MessageProduct $product) + { + $this->product = $product; + } +} diff --git a/src/Bot/Model/Entity/Cost.php b/src/Bot/Model/Entity/Message/MessageCost.php similarity index 86% rename from src/Bot/Model/Entity/Cost.php rename to src/Bot/Model/Entity/Message/MessageCost.php index 2727732..721b3b4 100644 --- a/src/Bot/Model/Entity/Cost.php +++ b/src/Bot/Model/Entity/Message/MessageCost.php @@ -3,15 +3,15 @@ /** * PHP version 7.0 * - * Cost entity + * MessageCost entity * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Mg\Bot\Model\Entity; +namespace RetailCrm\Mg\Bot\Model\Entity\Message; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; @@ -20,14 +20,14 @@ use JMS\Serializer\Annotation\Type; /** * PHP version 7.0 * - * Cost class + * MessageCost class * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -class Cost +class MessageCost { /** * @var float $value diff --git a/src/Bot/Model/Entity/Delivery.php b/src/Bot/Model/Entity/Message/MessageDelivery.php similarity index 83% rename from src/Bot/Model/Entity/Delivery.php rename to src/Bot/Model/Entity/Message/MessageDelivery.php index 2de1bbc..ccc6a46 100644 --- a/src/Bot/Model/Entity/Delivery.php +++ b/src/Bot/Model/Entity/Message/MessageDelivery.php @@ -3,31 +3,32 @@ /** * PHP version 7.0 * - * Delivery entity + * MessageDelivery entity * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Mg\Bot\Model\Entity; +namespace RetailCrm\Mg\Bot\Model\Entity\Message; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost; /** * PHP version 7.0 * - * Delivery class + * MessageDelivery class * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -class Delivery +class MessageDelivery { /** * @var string $name @@ -40,7 +41,7 @@ class Delivery private $name; /** - * @var Cost $price + * @var MessageCost $price * * @Type("Cost") * @Accessor(getter="getPrice",setter="setPrice") @@ -84,7 +85,7 @@ class Delivery } /** - * @return Cost + * @return MessageCost */ public function getPrice() { @@ -92,9 +93,9 @@ class Delivery } /** - * @param Cost $price + * @param MessageCost $price */ - public function setPrice(Cost $price) + public function setPrice(MessageCost $price) { $this->price = $price; } diff --git a/src/Bot/Model/Entity/Order.php b/src/Bot/Model/Entity/Message/MessageOrder.php similarity index 81% rename from src/Bot/Model/Entity/Order.php rename to src/Bot/Model/Entity/Message/MessageOrder.php index ffa27de..92badd0 100644 --- a/src/Bot/Model/Entity/Order.php +++ b/src/Bot/Model/Entity/Message/MessageOrder.php @@ -3,15 +3,15 @@ /** * PHP version 7.0 * - * Order entity + * MessageOrder entity * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Mg\Bot\Model\Entity; +namespace RetailCrm\Mg\Bot\Model\Entity\Message; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; @@ -20,14 +20,14 @@ use JMS\Serializer\Annotation\Type; /** * PHP version 7.0 * - * Order class + * MessageOrder class * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -class Order +class MessageOrder { /** * @var string $number @@ -57,27 +57,27 @@ class Order private $date; /** - * @var Cost $cost + * @var MessageCost $cost * - * @Type("Cost") + * @Type("MessageCost") * @Accessor(getter="getCost",setter="setCost") * @SkipWhenEmpty() */ private $cost; /** - * @var Status $status + * @var MessageStatus $status * - * @Type("Status") + * @Type("MessageStatus") * @Accessor(getter="getStatus",setter="setStatus") * @SkipWhenEmpty() */ private $status; /** - * @var Delivery $delivery + * @var MessageDelivery $delivery * - * @Type("Delivery") + * @Type("MessageDelivery") * @Accessor(getter="getDelivery",setter="setDelivery") * @SkipWhenEmpty() */ @@ -150,7 +150,7 @@ class Order } /** - * @return Cost + * @return MessageCost */ public function getCost() { @@ -158,15 +158,15 @@ class Order } /** - * @param Cost $cost + * @param MessageCost $cost */ - public function setCost(Cost $cost) + public function setCost(MessageCost $cost) { $this->cost = $cost; } /** - * @return Status + * @return MessageStatus */ public function getStatus() { @@ -174,15 +174,15 @@ class Order } /** - * @param Status $status + * @param MessageStatus $status */ - public function setStatus(Status $status) + public function setStatus(MessageStatus $status) { $this->status = $status; } /** - * @return Delivery + * @return MessageDelivery */ public function getDelivery() { @@ -190,9 +190,9 @@ class Order } /** - * @param Delivery $delivery + * @param MessageDelivery $delivery */ - public function setDelivery(Delivery $delivery) + public function setDelivery(MessageDelivery $delivery) { $this->delivery = $delivery; } diff --git a/src/Bot/Model/Entity/OrderItem.php b/src/Bot/Model/Entity/Message/MessageOrderItem.php similarity index 74% rename from src/Bot/Model/Entity/OrderItem.php rename to src/Bot/Model/Entity/Message/MessageOrderItem.php index dba54ce..5a01d9c 100644 --- a/src/Bot/Model/Entity/OrderItem.php +++ b/src/Bot/Model/Entity/Message/MessageOrderItem.php @@ -1,36 +1,36 @@ * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers + * + * @see http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Mg\Bot\Model\Entity; +namespace RetailCrm\Mg\Bot\Model\Entity\Message; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; /** - * PHP version 7.0 + * PHP version 7.0. * - * OrderItem class + * MessageOrderItem class * - * @package RetailCrm\Mg\Bot\Model\Entity * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers + * + * @see http://help.retailcrm.pro/docs/Developers */ -class OrderItem +class MessageOrderItem { /** - * @var string $name + * @var string * * @Type("string") * @Accessor(getter="getName",setter="setName") @@ -39,7 +39,7 @@ class OrderItem private $name; /** - * @var string $url + * @var string * * @Type("string") * @Accessor(getter="getUrl",setter="setUrl") @@ -48,7 +48,7 @@ class OrderItem private $url; /** - * @var string $img + * @var string * * @Type("string") * @Accessor(getter="getImg",setter="setImg") @@ -57,18 +57,18 @@ class OrderItem private $img; /** - * @var Cost $price + * @var MessageCost * - * @Type("Cost") + * @Type("MessageCost") * @Accessor(getter="getPrice",setter="setPrice") * @SkipWhenEmpty() */ private $price; /** - * @var Quantity $quantity + * @var MessageQuantity * - * @Type("Quantity") + * @Type("MessageQuantity") * @Accessor(getter="getQuantity",setter="setQuantity) * @SkipWhenEmpty() */ @@ -123,7 +123,7 @@ class OrderItem } /** - * @return Cost + * @return MessageCost */ public function getPrice() { @@ -131,15 +131,15 @@ class OrderItem } /** - * @param Cost $price + * @param MessageCost $price */ - public function setPrice(Cost $price) + public function setPrice(MessageCost $price) { $this->price = $price; } /** - * @return Quantity + * @return MessageQuantity */ public function getQuantity() { @@ -147,9 +147,9 @@ class OrderItem } /** - * @param Quantity $quantity + * @param MessageQuantity $quantity */ - public function setQuantity(Quantity $quantity) + public function setQuantity(MessageQuantity $quantity) { $this->quantity = $quantity; } diff --git a/src/Bot/Model/Entity/PaymentStatus.php b/src/Bot/Model/Entity/Message/MessageOrderPaymentStatus.php similarity index 78% rename from src/Bot/Model/Entity/PaymentStatus.php rename to src/Bot/Model/Entity/Message/MessageOrderPaymentStatus.php index 7a20f46..9316da6 100644 --- a/src/Bot/Model/Entity/PaymentStatus.php +++ b/src/Bot/Model/Entity/Message/MessageOrderPaymentStatus.php @@ -3,15 +3,15 @@ /** * PHP version 7.0 * - * Payment status entity + * MessageOrderPaymentStatus entity * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Mg\Bot\Model\Entity; +namespace RetailCrm\Mg\Bot\Model\Entity\Message; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; @@ -20,14 +20,14 @@ use JMS\Serializer\Annotation\Type; /** * PHP version 7.0 * - * PaymentStatus class + * MessageOrderPaymentStatus class * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -class PaymentStatus +class MessageOrderPaymentStatus { /** * @var string $name @@ -39,7 +39,7 @@ class PaymentStatus private $name; /** - * @var bool $payed + * @var bool $name * * @Type("bool") * @Accessor(getter="getPayed",setter="setPayed") @@ -50,7 +50,7 @@ class PaymentStatus /** * @return string */ - public function getName() + public function getName(): string { return $this->name; } @@ -66,7 +66,7 @@ class PaymentStatus /** * @return bool */ - public function isPayed() + public function getPayed(): bool { return $this->payed; } diff --git a/src/Bot/Model/Entity/Payment.php b/src/Bot/Model/Entity/Message/MessagePayment.php similarity index 70% rename from src/Bot/Model/Entity/Payment.php rename to src/Bot/Model/Entity/Message/MessagePayment.php index b5709c9..eae13f1 100644 --- a/src/Bot/Model/Entity/Payment.php +++ b/src/Bot/Model/Entity/Message/MessagePayment.php @@ -3,15 +3,15 @@ /** * PHP version 7.0 * - * Payment entity + * MessagePayment entity * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Mg\Bot\Model\Entity; +namespace RetailCrm\Mg\Bot\Model\Entity\Message; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; @@ -20,14 +20,14 @@ use JMS\Serializer\Annotation\Type; /** * PHP version 7.0 * - * Payment class + * MessagePayment class * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -class Payment +class MessagePayment { /** * @var string $name @@ -39,18 +39,18 @@ class Payment private $name; /** - * @var PaymentStatus $status + * @var MessageOrderPaymentStatus $status * - * @Type("PaymentStatus") + * @Type("MessageOrderPaymentStatus") * @Accessor(getter="getStatus",setter="setStatus") * @SkipWhenEmpty() */ private $status; /** - * @var Cost $amount + * @var MessageCost $amount * - * @Type("Cost") + * @Type("MessageCost") * @Accessor(getter="getAmount",setter="setAmount") * @SkipWhenEmpty() */ @@ -73,7 +73,7 @@ class Payment } /** - * @return PaymentStatus + * @return MessageOrderPaymentStatus */ public function getStatus() { @@ -81,15 +81,15 @@ class Payment } /** - * @param PaymentStatus $status + * @param MessageOrderPaymentStatus $status */ - public function setStatus(PaymentStatus $status) + public function setStatus(MessageOrderPaymentStatus $status) { $this->status = $status; } /** - * @return Cost + * @return MessageCost */ public function getAmount() { @@ -97,9 +97,9 @@ class Payment } /** - * @param Cost $amount + * @param MessageCost $amount */ - public function setAmount(Cost $amount) + public function setAmount(MessageCost $amount) { $this->amount = $amount; } diff --git a/src/Bot/Model/Entity/Product.php b/src/Bot/Model/Entity/Message/MessageProduct.php similarity index 78% rename from src/Bot/Model/Entity/Product.php rename to src/Bot/Model/Entity/Message/MessageProduct.php index 5c9c9f4..490d6e6 100644 --- a/src/Bot/Model/Entity/Product.php +++ b/src/Bot/Model/Entity/Message/MessageProduct.php @@ -3,15 +3,15 @@ /** * PHP version 7.0 * - * Product entity + * MessageProduct entity * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Mg\Bot\Model\Entity; +namespace RetailCrm\Mg\Bot\Model\Entity\Message; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; @@ -20,14 +20,14 @@ use JMS\Serializer\Annotation\Type; /** * PHP version 7.0 * - * Product class + * MessageProduct class * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -class Product +class MessageProduct { /** * @var int $id @@ -75,7 +75,7 @@ class Product private $img; /** - * @var Cost $cost + * @var MessageCost $cost * * @Type("Cost") * @Accessor(getter="getCost",setter="setCost") @@ -84,9 +84,9 @@ class Product private $cost; /** - * @var Quantity $quantity + * @var MessageQuantity $quantity * - * @Type("Quantity") + * @Type("MessageQuantity") * @Accessor(getter="getQuantity",setter="setQuantity) * @SkipWhenEmpty() */ @@ -111,7 +111,7 @@ class Product /** * @return string */ - public function getName() + public function getName(): string { return $this->name; } @@ -127,7 +127,7 @@ class Product /** * @return string */ - public function getArticle() + public function getArticle(): string { return $this->article; } @@ -143,7 +143,7 @@ class Product /** * @return string */ - public function getUrl() + public function getUrl(): string { return $this->url; } @@ -159,7 +159,7 @@ class Product /** * @return string */ - public function getImg() + public function getImg(): string { return $this->img; } @@ -173,33 +173,33 @@ class Product } /** - * @return Cost + * @return MessageCost */ - public function getCost() + public function getCost(): MessageCost { return $this->cost; } /** - * @param Cost $cost + * @param MessageCost $cost */ - public function setCost(Cost $cost) + public function setCost(MessageCost $cost) { $this->cost = $cost; } /** - * @return Quantity + * @return MessageQuantity */ - public function getQuantity() + public function getQuantity(): MessageQuantity { return $this->quantity; } /** - * @param Quantity $quantity + * @param MessageQuantity $quantity */ - public function setQuantity(Quantity $quantity) + public function setQuantity(MessageQuantity $quantity) { $this->quantity = $quantity; } diff --git a/src/Bot/Model/Entity/Quantity.php b/src/Bot/Model/Entity/Message/MessageQuantity.php similarity index 85% rename from src/Bot/Model/Entity/Quantity.php rename to src/Bot/Model/Entity/Message/MessageQuantity.php index d74d4c4..1449e57 100644 --- a/src/Bot/Model/Entity/Quantity.php +++ b/src/Bot/Model/Entity/Message/MessageQuantity.php @@ -3,15 +3,15 @@ /** * PHP version 7.0 * - * Quantity entity + * MessageQuantity entity * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Mg\Bot\Model\Entity; +namespace RetailCrm\Mg\Bot\Model\Entity\Message; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; @@ -20,14 +20,14 @@ use JMS\Serializer\Annotation\Type; /** * PHP version 7.0 * - * Quantity class + * MessageQuantity class * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -class Quantity +class MessageQuantity { /** * @var float $value diff --git a/src/Bot/Model/Entity/Status.php b/src/Bot/Model/Entity/Message/MessageStatus.php similarity index 81% rename from src/Bot/Model/Entity/Status.php rename to src/Bot/Model/Entity/Message/MessageStatus.php index 4564290..27f4c0c 100644 --- a/src/Bot/Model/Entity/Status.php +++ b/src/Bot/Model/Entity/Message/MessageStatus.php @@ -3,15 +3,15 @@ /** * PHP version 7.0 * - * Status entity + * MessageStatus entity * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Mg\Bot\Model\Entity; +namespace RetailCrm\Mg\Bot\Model\Entity\Message; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; @@ -20,14 +20,14 @@ use JMS\Serializer\Annotation\Type; /** * PHP version 7.0 * - * Status class + * MessageStatus class * - * @package RetailCrm\Mg\Bot\Model\Entity + * @package RetailCrm\Mg\Bot\Model\Entity\Message * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -class Status +class MessageStatus { /** * @var string $code @@ -50,7 +50,7 @@ class Status /** * @return string */ - public function getCode() + public function getCode(): string { return $this->code; } @@ -66,7 +66,7 @@ class Status /** * @return string */ - public function getName() + public function getName(): string { return $this->name; } diff --git a/src/Bot/Model/Entity/Responsible.php b/src/Bot/Model/Entity/Responsible.php new file mode 100644 index 0000000..c39a189 --- /dev/null +++ b/src/Bot/Model/Entity/Responsible.php @@ -0,0 +1,106 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * Responsible class + * + * @package RetailCrm\Mg\Bot\Model\Entity + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class Responsible +{ + /** + * @var string $assignedAt + * + * @Type("string") + * @Accessor(getter="getAssignedAt",setter="setAssignedAt") + * @SkipWhenEmpty() + */ + private $assignedAt; + + /** + * @var int $id + * + * @Type("int") + * @Accessor(getter="getId",setter="setId") + * @SkipWhenEmpty() + */ + private $id; + + /** + * @var string $type + * + * @Type("string") + * @Accessor(getter="getType",setter="setType") + * @SkipWhenEmpty() + */ + private $type; + + /** + * @return string + */ + public function getAssignedAt(): string + { + return $this->assignedAt; + } + + /** + * @param string $assignedAt + */ + public function setAssignedAt(string $assignedAt) + { + $this->assignedAt = $assignedAt; + } + + /** + * @return int + */ + public function getId(): int + { + return $this->id; + } + + /** + * @param int $id + */ + public function setId(int $id) + { + $this->id = $id; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type) + { + $this->type = $type; + } +} diff --git a/src/Bot/Model/Entity/User.php b/src/Bot/Model/Entity/User.php new file mode 100644 index 0000000..af8809c --- /dev/null +++ b/src/Bot/Model/Entity/User.php @@ -0,0 +1,359 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Entity; + +use Symfony\Component\Validator\Constraints as Assert; +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * User class + * + * @package RetailCrm\Mg\Bot\Model\Entity + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class User +{ + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + */ + private $id; + + /** + * @var \DateTime $createdAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getCreatedAt",setter="setCreatedAt") + */ + private $createdAt; + + /** + * @var \DateTime $updatedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") + * @SkipWhenEmpty() + */ + private $updatedAt; + + /** + * @var string $externalId + * + * @Type("string") + * @Accessor(getter="getExternalId",setter="setExternalId") + * @SkipWhenEmpty() + * @Assert\Length(max="64") + */ + private $externalId; + + /** + * @var string $type + * + * @Type("string") + * @Accessor(getter="getType",setter="setType") + * @SkipWhenEmpty() + */ + private $type; + + /** + * @var string $avatar + * + * @Type("string") + * @Accessor(getter="getAvatar",setter="setAvatar") + * @SkipWhenEmpty() + */ + private $avatar; + + /** + * @var string $name + * + * @Type("string") + * @Accessor(getter="getName",setter="setName") + * @SkipWhenEmpty() + */ + private $name; + + /** + * @var string $username + * + * @Type("string") + * @Accessor(getter="getUsername",setter="setUsername") + * @SkipWhenEmpty() + * @Assert\Length(max="255") + */ + private $username; + + /** + * @var string $firstName + * + * @Type("string") + * @Accessor(getter="getFirstName",setter="setFirstName") + * @SkipWhenEmpty() + * @Assert\Length(max="255") + */ + private $firstName; + + /** + * @var string $lastName + * + * @Type("string") + * @Accessor(getter="getLastName",setter="setLastName") + * @SkipWhenEmpty() + * @Assert\Length(max="255") + */ + private $lastName; + + /** + * @var bool $isActive + * + * @Type("bool") + * @Accessor(getter="getIsActive",setter="setIsActive") + * @SkipWhenEmpty() + */ + private $isActive; + + /** + * @var bool $isOnline + * + * @Type("bool") + * @Accessor(getter="getIsOnline",setter="setIsOnline") + * @SkipWhenEmpty() + */ + private $isOnline; + + /** + * @var \DateTime $revokedAt + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Accessor(getter="getRevokedAt",setter="setRevokedAt") + * @SkipWhenEmpty() + */ + private $revokedAt; + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return \DateTime + */ + public function getCreatedAt(): \DateTime + { + return $this->createdAt; + } + + /** + * @param \DateTime $createdAt + */ + public function setCreatedAt(\DateTime $createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * @return \DateTime + */ + public function getUpdatedAt(): \DateTime + { + return $this->updatedAt; + } + + /** + * @param \DateTime $updatedAt + */ + public function setUpdatedAt(\DateTime $updatedAt) + { + $this->updatedAt = $updatedAt; + } + + /** + * @return string + */ + public function getExternalId(): string + { + return $this->externalId; + } + + /** + * @param string $externalId + */ + public function setExternalId(string $externalId) + { + $this->externalId = $externalId; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type) + { + $this->type = $type; + } + + /** + * @return string + */ + public function getAvatar(): string + { + return $this->avatar; + } + + /** + * @param string $avatar + */ + public function setAvatar(string $avatar) + { + $this->avatar = $avatar; + } + + /** + * @return string + */ + public function getName(): string + { + return $this->name; + } + + /** + * @param string $name + */ + public function setName(string $name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getUsername(): string + { + return $this->username; + } + + /** + * @param string $username + */ + public function setUsername(string $username) + { + $this->username = $username; + } + + /** + * @return string + */ + public function getFirstName(): string + { + return $this->firstName; + } + + /** + * @param string $firstName + */ + public function setFirstName(string $firstName) + { + $this->firstName = $firstName; + } + + /** + * @return string + */ + public function getLastName(): string + { + return $this->lastName; + } + + /** + * @param string $lastName + */ + public function setLastName(string $lastName) + { + $this->lastName = $lastName; + } + + /** + * @return bool + */ + public function isActive(): bool + { + return $this->isActive; + } + + /** + * @param bool $isActive + */ + public function setIsActive(bool $isActive) + { + $this->isActive = $isActive; + } + + /** + * @return bool + */ + public function isOnline(): bool + { + return $this->isOnline; + } + + /** + * @param bool $isOnline + */ + public function setIsOnline(bool $isOnline) + { + $this->isOnline = $isOnline; + } + + /** + * @return \DateTime + */ + public function getRevokedAt(): \DateTime + { + return $this->revokedAt; + } + + /** + * @param \DateTime $revokedAt + */ + public function setRevokedAt(\DateTime $revokedAt) + { + $this->revokedAt = $revokedAt; + } +} diff --git a/src/Bot/Model/Request/CommandEditRequest.php b/src/Bot/Model/Request/CommandEditRequest.php index e95161d..cdf6033 100644 --- a/src/Bot/Model/Request/CommandEditRequest.php +++ b/src/Bot/Model/Request/CommandEditRequest.php @@ -13,6 +13,7 @@ namespace RetailCrm\Mg\Bot\Model\Request; +use JMS\Serializer\Annotation as Serializer; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; @@ -35,8 +36,7 @@ class CommandEditRequest * * @Type("int") * @Accessor(getter="getBotId",setter="setBotId") - * - * @Assert\NotBlank + * @SkipWhenEmpty() */ private $botId; @@ -45,8 +45,7 @@ class CommandEditRequest * * @Type("string") * @Accessor(getter="getName",setter="setName") - * - * @Assert\NotBlank + * @SkipWhenEmpty() */ private $name; diff --git a/src/Bot/Model/Request/CommonFields.php b/src/Bot/Model/Request/CommonFields.php index 5ade7d0..6e64c6c 100644 --- a/src/Bot/Model/Request/CommonFields.php +++ b/src/Bot/Model/Request/CommonFields.php @@ -30,6 +30,8 @@ use JMS\Serializer\Annotation\Type; trait CommonFields { /** + * @var int + * * @Type("int") * @Accessor(getter="getId",setter="setId") * @SkipWhenEmpty @@ -37,14 +39,18 @@ trait CommonFields private $id; /** - * @Type("string") + * @var \DateTime + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") * @Accessor(getter="getSince",setter="setSince") * @SkipWhenEmpty */ private $since; /** - * @Type("string") + * @var \DateTime + * + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") * @Accessor(getter="getUntil",setter="setUntil") * @SkipWhenEmpty */ @@ -67,7 +73,7 @@ trait CommonFields } /** - * @return string + * @return \DateTime */ public function getSince() { @@ -75,15 +81,15 @@ trait CommonFields } /** - * @param string $since + * @param \DateTime $since */ - public function setSince($since) + public function setSince(\DateTime $since) { $this->since = $since; } /** - * @return string + * @return \DateTime */ public function getUntil() { @@ -91,9 +97,9 @@ trait CommonFields } /** - * @param string $until + * @param \DateTime $until */ - public function setUntil($until) + public function setUntil(\DateTime $until) { $this->until = $until; } diff --git a/src/Bot/Model/Request/CustomersRequest.php b/src/Bot/Model/Request/CustomersRequest.php index d15604d..5913b77 100644 --- a/src/Bot/Model/Request/CustomersRequest.php +++ b/src/Bot/Model/Request/CustomersRequest.php @@ -16,6 +16,7 @@ namespace RetailCrm\Mg\Bot\Model\Request; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; +use RetailCrm\Mg\Bot\Model\Request\CommonFields; /** * PHP version 7.0 diff --git a/src/Bot/Model/Request/DialogAssignRequest.php b/src/Bot/Model/Request/DialogAssignRequest.php index 3837ee1..e5aabf6 100644 --- a/src/Bot/Model/Request/DialogAssignRequest.php +++ b/src/Bot/Model/Request/DialogAssignRequest.php @@ -13,6 +13,7 @@ namespace RetailCrm\Mg\Bot\Model\Request; +use JMS\Serializer\Annotation as Serializer; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; @@ -33,8 +34,8 @@ class DialogAssignRequest * @var int $dialogId * * @Type("int") - * @Accessor(getter="getDialogId,setter="setDialogId") - * @SkipWhenEmpty + * @Accessor(getter="getDialogId", setter="setDialogId") + * @SkipWhenEmpty() */ private $dialogId; @@ -42,8 +43,8 @@ class DialogAssignRequest * @var int $userId * * @Type("int") - * @Accessor(getter="getUserId",setter="setUserId") - * @SkipWhenEmpty + * @Accessor(getter="getUserId", setter="setUserId") + * @SkipWhenEmpty() */ private $userId; @@ -51,7 +52,7 @@ class DialogAssignRequest * @var int $botId * * @Type("int") - * @Accessor(getter="getBotId",setter="setBotId") + * @Accessor(getter="getBotId", setter="setBotId") * @SkipWhenEmpty() */ private $botId; @@ -67,7 +68,7 @@ class DialogAssignRequest /** * @param int $dialogId */ - public function setDialogId(int $dialogId) + public function setDialogId($dialogId) { $this->dialogId = $dialogId; } diff --git a/src/Bot/Model/Request/MessageSendRequest.php b/src/Bot/Model/Request/MessageSendRequest.php index 254134f..f89550f 100644 --- a/src/Bot/Model/Request/MessageSendRequest.php +++ b/src/Bot/Model/Request/MessageSendRequest.php @@ -16,6 +16,8 @@ namespace RetailCrm\Mg\Bot\Model\Request; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder; +use RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct; use Symfony\Component\Validator\Constraints as Assert; use RetailCrm\Mg\Bot\Model\Entity\Order; use RetailCrm\Mg\Bot\Model\Entity\Product; @@ -52,7 +54,7 @@ class MessageSendRequest private $content; /** - * @var Product $product + * @var MessageProduct $product * * @Type("Product") * @Accessor(getter="getProduct",setter="setProduct") @@ -61,7 +63,7 @@ class MessageSendRequest private $product; /** - * @var Order $order + * @var MessageOrder $order * * @Type("Order") * @Accessor(getter="getOrder",setter="setOrder") @@ -174,7 +176,7 @@ class MessageSendRequest } /** - * @return Product + * @return MessageProduct */ public function getProduct() { @@ -182,15 +184,15 @@ class MessageSendRequest } /** - * @param Product $product + * @param MessageProduct $product */ - public function setProduct(Product $product) + public function setProduct(MessageProduct $product) { $this->product = $product; } /** - * @return Order + * @return MessageOrder */ public function getOrder() { @@ -198,9 +200,9 @@ class MessageSendRequest } /** - * @param Order $order + * @param MessageOrder $order */ - public function setOrder(Order $order) + public function setOrder(MessageOrder $order) { $this->order = $order; } diff --git a/src/Bot/Model/Request/UploadFileByUrlRequest.php b/src/Bot/Model/Request/UploadFileByUrlRequest.php new file mode 100644 index 0000000..1478b7f --- /dev/null +++ b/src/Bot/Model/Request/UploadFileByUrlRequest.php @@ -0,0 +1,57 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Request; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\Type; +use Symfony\Component\Validator\Constraints as Assert; + +/** + * PHP version 7.0 + * + * UploadFileByUrlRequest class + * + * @package RetailCrm\Mg\Bot\Model\Request + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class UploadFileByUrlRequest +{ + /** + * @var string $url + * + * @Type("string") + * @Accessor(getter="getUrl",setter="setUrl") + * @Assert\NotBlank() + * @Assert\Url() + */ + private $url; + + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @param string $url + */ + public function setUrl(string $url) + { + $this->url = $url; + } +} diff --git a/src/Bot/Model/Response/AssignResponse.php b/src/Bot/Model/Response/AssignResponse.php new file mode 100644 index 0000000..73ac86f --- /dev/null +++ b/src/Bot/Model/Response/AssignResponse.php @@ -0,0 +1,134 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Response; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; +use RetailCrm\Mg\Bot\Model\Entity\Responsible; + +/** + * PHP version 7.0 + * + * AssignResponse class + * + * @package RetailCrm\Mg\Bot\Model\Response + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class AssignResponse +{ + use CommonFields; + + /** + * @var bool $isReassign + * + * @Type("bool") + * @Accessor(getter="getIsReassign",setter="setIsReassign") + * @SkipWhenEmpty() + */ + private $isReassign; + + /** + * @var int $leftManagerId + * + * @Type("int") + * @Accessor(getter="getLeftManagerId",setter="setLeftManagerId") + * @SkipWhenEmpty() + */ + private $leftManagerId; + + /** + * @var Responsible $previousResponsible + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Responsible") + * @Accessor(getter="getPreviousResponsible",setter="setPreviousResponsible") + * @SkipWhenEmpty() + */ + private $previousResponsible; + + /** + * @var Responsible $responsible + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Responsible") + * @Accessor(getter="getResponsible",setter="setResponsible") + * @SkipWhenEmpty() + */ + private $responsible; + + /** + * @return bool + */ + public function getIsReassign(): bool + { + return $this->isReassign; + } + + /** + * @param bool $isReassign + */ + public function setIsReassign(bool $isReassign) + { + $this->isReassign = $isReassign; + } + + /** + * @return int + */ + public function getLeftManagerId(): int + { + return $this->leftManagerId; + } + + /** + * @param int $leftManagerId + */ + public function setLeftManagerId(int $leftManagerId) + { + $this->leftManagerId = $leftManagerId; + } + + /** + * @return Responsible + */ + public function getPreviousResponsible(): Responsible + { + return $this->previousResponsible; + } + + /** + * @param Responsible $previousResponsible + */ + public function setPreviousResponsible(Responsible $previousResponsible) + { + $this->previousResponsible = $previousResponsible; + } + + /** + * @return Responsible + */ + public function getResponsible(): Responsible + { + return $this->responsible; + } + + /** + * @param Responsible $responsible + */ + public function setResponsible(Responsible $responsible) + { + $this->responsible = $responsible; + } +} diff --git a/src/Bot/Model/Response/CommonFields.php b/src/Bot/Model/Response/CommonFields.php new file mode 100644 index 0000000..4959c57 --- /dev/null +++ b/src/Bot/Model/Response/CommonFields.php @@ -0,0 +1,87 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Response; + +use JMS\Serializer\Annotation\Exclude; +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * CommonFields trait + * + * @package RetailCrm\Mg\Bot\Model\Response + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +trait CommonFields +{ + /** + * @var array $errors + * + * @Type("array") + * @Accessor(getter="getErrors",setter="setErrors") + * @SkipWhenEmpty() + */ + private $errors; + + /** + * @var int $statusCode + * @Exclude() + */ + private $statusCode; + + /** + * @return array + */ + public function getErrors(): array + { + return is_null($this->errors) ? [] : $this->errors; + } + + /** + * @param array $errors + */ + public function setErrors(array $errors) + { + $this->errors = $errors; + } + + /** + * @return int + */ + public function getStatusCode(): int + { + return $this->statusCode; + } + + /** + * @param int $statusCode + */ + public function setStatusCode(int $statusCode) + { + $this->statusCode = $statusCode; + } + + /** + * @return bool + */ + public function isSuccessful() + { + return empty($this->errors); + } +} diff --git a/src/Exception/CurlException.php b/src/Bot/Model/Response/ErrorOnlyResponse.php similarity index 64% rename from src/Exception/CurlException.php rename to src/Bot/Model/Response/ErrorOnlyResponse.php index 8412b22..dfe5a38 100644 --- a/src/Exception/CurlException.php +++ b/src/Bot/Model/Response/ErrorOnlyResponse.php @@ -3,28 +3,27 @@ /** * PHP version 7.0 * - * CurlException + * ErrorOnlyResponse * - * @package RetailCrm\Common\Exception + * @package RetailCrm\Mg\Bot\Model\Response * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -namespace RetailCrm\Common\Exception; - -use RuntimeException; +namespace RetailCrm\Mg\Bot\Model\Response; /** * PHP version 7.0 * - * Class CurlException + * ErrorOnlyResponse class * - * @package RetailCrm\Common\Exception + * @package RetailCrm\Mg\Bot\Model\Response * @author retailCRM * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -class CurlException extends RuntimeException +class ErrorOnlyResponse { + use CommonFields; } diff --git a/src/Bot/Model/Response/FullFileResponse.php b/src/Bot/Model/Response/FullFileResponse.php new file mode 100644 index 0000000..bc876a6 --- /dev/null +++ b/src/Bot/Model/Response/FullFileResponse.php @@ -0,0 +1,133 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Response; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * FullFileResponse class + * + * @package RetailCrm\Mg\Bot\Model\Response + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class FullFileResponse +{ + use CommonFields; + + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + * @SkipWhenEmpty() + */ + private $id; + + /** + * @var int $size + * + * @Type("int") + * @Accessor(getter="getSize",setter="setSize") + * @SkipWhenEmpty() + */ + private $size; + + /** + * @var string $type + * + * @Type("string") + * @Accessor(getter="getType",setter="setType") + * @SkipWhenEmpty() + */ + private $type; + + /** + * @var string $url + * + * @Type("string") + * @Accessor(getter="getUrl",setter="setUrl") + * @SkipWhenEmpty() + */ + private $url; + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return int + */ + public function getSize(): int + { + return $this->size; + } + + /** + * @param int $size + */ + public function setSize(int $size) + { + $this->size = $size; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type) + { + $this->type = $type; + } + + /** + * @return string + */ + public function getUrl(): string + { + return $this->url; + } + + /** + * @param string $url + */ + public function setUrl(string $url) + { + $this->url = $url; + } +} diff --git a/src/Bot/Model/Response/ListResponse.php b/src/Bot/Model/Response/ListResponse.php new file mode 100644 index 0000000..5d7d88f --- /dev/null +++ b/src/Bot/Model/Response/ListResponse.php @@ -0,0 +1,202 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Response; + +use RetailCrm\Common\Serializer; + +/** + * PHP version 7.0 + * + * ListResponse class. Used to store multiple objects at once. + * Implements `Iterator`, `ArrayAccess` and `Countable`. + * + * @package RetailCrm\Mg\Bot\Model\Response + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class ListResponse implements \Iterator, \ArrayAccess, \Countable +{ + use CommonFields; + + /** + * @var array + */ + private $items = []; + + /** + * @var int + */ + private $position = 0; + + /** + * ListResponse constructor. + * + * @param string $responseType + * @param array $data + * @param int $statusCode + */ + public function __construct($responseType, $data, $statusCode) + { + $this->setStatusCode($statusCode); + + if (isset($data['errors'])) { + $this->setErrors($data['errors']); + } else { + foreach ($data as $item) { + $this->items[] = + Serializer::deserialize($item, $responseType, Serializer::S_ARRAY); + } + } + } + + /** + * @return bool + */ + public function isSuccessful() + { + return empty($this->errors); + } + + /** + * \Countable implementation + * + * @return int + */ + public function count(): int + { + return count($this->items ?: []); + } + + /** + * Set offset + * + * @param mixed $offset offset value + * @param mixed $value value + * + * @return void + * @internal + */ + public function offsetSet($offset, $value) + { + throw new \BadMethodCallException( + "This call not allowed: offsetSet [$offset] [$value]" + ); + } + + /** + * Unset offset + * + * @param mixed $offset offset value + * + * @return void + * @internal + */ + public function offsetUnset($offset) + { + throw new \BadMethodCallException( + "This call not allowed: offsetSet [$offset]" + ); + } + /** + * Check offset + * + * @param mixed $offset offset value + * + * @return bool + * @internal + */ + public function offsetExists($offset) + { + return isset($this->items[$offset]); + } + /** + * Get offset + * + * @param mixed $offset offset value + * + * @return mixed + * @internal + */ + public function offsetGet($offset) + { + if (!isset($this->items[$offset])) { + throw new \InvalidArgumentException("Item \"$offset\" not found"); + } + + return $this->items[$offset]; + } + + /** + * @param mixed $name + * + * @return mixed + * @internal + */ + public function __get($name) + { + return $this->items[$name]; + } + + /** + * Implements rewind() for Iterable + * @internal + */ + public function rewind() + { + $this->position = 0; + } + + /** + * Implements current() for Iterable + * + * @internal + * @return mixed + */ + public function current() + { + return $this->items[$this->position]; + } + + /** + * Implements key() for Iterable + * + * @internal + * @return int|mixed + */ + public function key() + { + return $this->position; + } + + /** + * Implements next() for Iterable + * @internal + */ + public function next() + { + ++$this->position; + } + + /** + * Implements valid() for Iterable + * + * @internal + * @return bool + */ + public function valid() + { + return isset($this->items[$this->position]); + } +} diff --git a/src/Bot/Model/Response/MessageSendResponse.php b/src/Bot/Model/Response/MessageSendResponse.php new file mode 100644 index 0000000..ea8c5e0 --- /dev/null +++ b/src/Bot/Model/Response/MessageSendResponse.php @@ -0,0 +1,83 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Response; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; + +/** + * PHP version 7.0 + * + * MessageSendResponse class + * + * @package RetailCrm\Mg\Bot\Model\Response + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class MessageSendResponse +{ + use CommonFields; + + /** + * @var int $messageId + * + * @Type("int") + * @Accessor(getter="getMessageId",setter="setMessageId") + * @SkipWhenEmpty() + */ + private $messageId; + + /** + * @var string $time + * + * @Type("string") + * @Accessor(getter="getTime",setter="setTime") + * @SkipWhenEmpty() + */ + private $time; + + /** + * @return int + */ + public function getMessageId(): int + { + return $this->messageId; + } + + /** + * @param int $messageId + */ + public function setMessageId(int $messageId) + { + $this->messageId = $messageId; + } + + /** + * @return string + */ + public function getTime(): string + { + return $this->time; + } + + /** + * @param string $time + */ + public function setTime(string $time) + { + $this->time = $time; + } +} diff --git a/src/Bot/Model/Response/UploadFileResponse.php b/src/Bot/Model/Response/UploadFileResponse.php new file mode 100644 index 0000000..75cda42 --- /dev/null +++ b/src/Bot/Model/Response/UploadFileResponse.php @@ -0,0 +1,234 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Model\Response; + +use JMS\Serializer\Annotation\Accessor; +use JMS\Serializer\Annotation\SkipWhenEmpty; +use JMS\Serializer\Annotation\Type; +use RetailCrm\Mg\Bot\Model\Entity\FileMeta; + +/** + * PHP version 7.0 + * + * UploadFileResponse class + * + * @package RetailCrm\Mg\Bot\Model\Response + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class UploadFileResponse +{ + use CommonFields; + + /** + * @var string $createdAt + * + * @Type("string") + * @Accessor(getter="getCreatedAt",setter="setCreatedAt") + * @SkipWhenEmpty() + */ + private $createdAt; + + /** + * @var string $hash + * + * @Type("string") + * @Accessor(getter="getHash",setter="setHash") + * @SkipWhenEmpty() + */ + private $hash; + + /** + * @var string $id + * + * @Type("string") + * @Accessor(getter="getId",setter="setId") + * @SkipWhenEmpty() + */ + private $id; + + /** + * @var FileMeta $meta + * + * @Type("FileMeta") + * @Accessor(getter="getMeta",setter="setMeta") + * @SkipWhenEmpty() + */ + private $meta; + + /** + * @var string $mimeType + * + * @Type("string") + * @Accessor(getter="getMimeType",setter="setMimeType") + * @SkipWhenEmpty() + */ + private $mimeType; + + /** + * @var int $size + * + * @Type("int") + * @Accessor(getter="getSize",setter="setSize") + * @SkipWhenEmpty() + */ + private $size; + + /** + * @var string $time + * + * @Type("string") + * @Accessor(getter="getSourceUrl",setter="setSourceUrl") + * @SkipWhenEmpty() + */ + private $sourceUrl; + + /** + * @var string $type + * + * @Type("string") + * @Accessor(getter="getType",setter="setType") + * @SkipWhenEmpty() + */ + private $type; + + /** + * @return string + */ + public function getCreatedAt(): string + { + return $this->createdAt; + } + + /** + * @param string $createdAt + */ + public function setCreatedAt(string $createdAt) + { + $this->createdAt = $createdAt; + } + + /** + * @return string + */ + public function getHash(): string + { + return $this->hash; + } + + /** + * @param string $hash + */ + public function setHash(string $hash) + { + $this->hash = $hash; + } + + /** + * @return string + */ + public function getId(): string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return FileMeta + */ + public function getMeta(): FileMeta + { + return $this->meta; + } + + /** + * @param FileMeta $meta + */ + public function setMeta(FileMeta $meta) + { + $this->meta = $meta; + } + + /** + * @return string + */ + public function getMimeType(): string + { + return $this->mimeType; + } + + /** + * @param string $mimeType + */ + public function setMimeType(string $mimeType) + { + $this->mimeType = $mimeType; + } + + /** + * @return int + */ + public function getSize(): int + { + return $this->size; + } + + /** + * @param int $size + */ + public function setSize(int $size) + { + $this->size = $size; + } + + /** + * @return string + */ + public function getSourceUrl(): string + { + return $this->sourceUrl; + } + + /** + * @param string $sourceUrl + */ + public function setSourceUrl(string $sourceUrl) + { + $this->sourceUrl = $sourceUrl; + } + + /** + * @return string + */ + public function getType(): string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type) + { + $this->type = $type; + } +} diff --git a/src/Bot/Request.php b/src/Bot/Request.php deleted file mode 100644 index ea0b340..0000000 --- a/src/Bot/Request.php +++ /dev/null @@ -1,205 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot; - -use RetailCrm\Common\Exception\CurlException; -use RetailCrm\Common\Exception\LimitException; -use Exception; -use InvalidArgumentException; -use RetailCrm\Common\Serializer; -use RetailCrm\Common\Url; -use Symfony\Component\Validator\Validation; - -/** - * PHP version 7.0 - * - * Request class - * - * @package RetailCrm\Mg\Bot - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class Request -{ - const METHOD_GET = 'GET'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_PATCH = 'PATCH'; - const METHOD_DELETE = 'DELETE'; - - protected $url; - protected $token; - private $debug; - private $allowedMethods; - private $stdout; - - /** - * Client constructor. - * - * @param string $url api url - * @param string $token api token - * @param bool $debug make request verbose - * @param bool|resource $stdout default output for debug - */ - public function __construct($url, $token, $debug, $stdout = STDOUT) - { - if (false === stripos($url, 'https://')) { - throw new InvalidArgumentException('API schema requires HTTPS protocol'); - } - - $this->url = $url; - $this->token = $token; - $this->debug = $debug; - $this->stdout = $stdout; - $this->allowedMethods = [ - self::METHOD_GET, - self::METHOD_POST, - self::METHOD_PUT, - self::METHOD_PATCH, - self::METHOD_DELETE - ]; - } - - /** - * Make HTTP request - * - * @param string $path request url - * @param string $method (default: 'GET') - * @param mixed $request (default: null) - * @param int $serializeTo - * - * @return Response - * @throws \Exception - */ - public function makeRequest($path, $method, $request = null, $serializeTo = Serializer::S_JSON) - { - $this->validateMethod($method); - - if (!is_null($request)) { - $this->validateRequest($request); - } - - $urlBuilder = new Url(); - - $parameters = is_null($request) ? null : Serializer::serialize($request, $serializeTo); - $url = $method == self::METHOD_GET - ? $this->url . $urlBuilder->buildUrl($path, $parameters, Url::RFC_CUSTOM) - : $this->url . $path - ; - - $curlHandler = curl_init(); - curl_setopt($curlHandler, CURLOPT_URL, $url); - curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($curlHandler, CURLOPT_FOLLOWLOCATION, 1); - curl_setopt($curlHandler, CURLOPT_FAILONERROR, false); - curl_setopt($curlHandler, CURLOPT_SSL_VERIFYPEER, false); - curl_setopt($curlHandler, CURLOPT_SSL_VERIFYHOST, false); - curl_setopt($curlHandler, CURLOPT_TIMEOUT, 60); - curl_setopt($curlHandler, CURLOPT_CONNECTTIMEOUT, 60); - curl_setopt($curlHandler, CURLOPT_VERBOSE, $this->debug); - curl_setopt($curlHandler, CURLOPT_STDERR, $this->stdout); - - curl_setopt($curlHandler, CURLOPT_HTTPHEADER, [ - 'Content-Type: application/json', - sprintf("X-Bot-Token: %s", $this->token) - ]); - - if (in_array($method, [self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_DELETE])) { - curl_setopt($curlHandler, CURLOPT_CUSTOMREQUEST, $method); - curl_setopt($curlHandler, CURLOPT_POSTFIELDS, $parameters); - } - - $responseBody = curl_exec($curlHandler); - $statusCode = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE); - - $response = Response::parseJSON($responseBody); - $errorMessage = !empty($response['errorMsg']) ? $response['errorMsg'] : ''; - $errorMessage = !empty($response['errors']) ? $this->getErrors($response['errors']) : $errorMessage; - - /** - * responses with 400 & 460 http codes contains extended error data - * therefore they are not handled as exceptions - */ - - if (in_array($statusCode, [403, 404, 500])) { - throw new Exception($errorMessage); - } - - if ($statusCode == 503) { - throw new LimitException($errorMessage); - } - - $errno = curl_errno($curlHandler); - $error = curl_error($curlHandler); - - curl_close($curlHandler); - - if ($errno) { - throw new CurlException($error, $errno); - } - - return new Response($statusCode, $responseBody); - } - - /** - * Validate HTTP method - * - * @param string $method - */ - private function validateMethod($method) - { - if (!in_array($method, $this->allowedMethods, false)) { - throw new InvalidArgumentException( - sprintf( - 'Method "%s" is not valid. Allowed methods are %s', - $method, - implode(', ', $this->allowedMethods) - ) - ); - } - } - - /** - * Validate given class - * - * @param string $class - * - * @return void - */ - private function validateRequest($class) - { - $validator = Validation::createValidatorBuilder() - ->enableAnnotationMapping() - ->getValidator(); - - $errors = $validator->validate($class); - - if ($errors->count() > 0) { - $message = (string) $errors; - throw new InvalidArgumentException($message); - } - } - - private function getErrors(array $errors) - { - $errorString = ''; - - foreach ($errors as $error) { - $errorString .= $error . " "; - } - - return $errorString; - } -} diff --git a/src/Bot/Response.php b/src/Bot/Response.php deleted file mode 100644 index daf4088..0000000 --- a/src/Bot/Response.php +++ /dev/null @@ -1,229 +0,0 @@ - - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ - -namespace RetailCrm\Mg\Bot; - -use ArrayAccess; -use BadMethodCallException; -use InvalidArgumentException; -use RetailCrm\Common\Exception\InvalidJsonException; - -/** - * PHP version 7.0 - * - * Request class - * - * @package RetailCrm\Mg\Bot - * @author retailCRM - * @license https://opensource.org/licenses/MIT MIT License - * @link http://help.retailcrm.pro/docs/Developers - */ -class Response implements ArrayAccess -{ - // HTTP response status code - protected $statusCode; - - // response assoc array - protected $response; - - // response body - protected $raw; - - /** - * ApiResponse constructor. - * - * @param int $statusCode HTTP status code - * @param mixed $responseBody HTTP body - * - * @throws InvalidJsonException - */ - public function __construct($statusCode, $responseBody = null) - { - $this->statusCode = $statusCode; - $this->raw = $responseBody; - $this->response = self::parseJSON($responseBody); - } - - /** - * Return raw HTTP response - * - * @return string|null - */ - public function getRawResponse() - { - return $this->raw; - } - - /** - * Return HTTP response - * - * @return array - */ - public function getResponse() - { - return $this->response; - } - - /** - * Return HTTP response status code - * - * @return int - */ - public function getStatusCode() - { - return $this->statusCode; - } - - /** - * HTTP request was successful - * - * @return bool - */ - public function isSuccessful() - { - return $this->statusCode < 400; - } - - /** - * Allow to access for the property throw class method - * - * @param string $name method name - * @param mixed $arguments method parameters - * - * @throws \InvalidArgumentException - * - * @return mixed - */ - public function __call($name, $arguments) - { - // convert getSomeProperty to someProperty - $propertyName = strtolower(substr($name, 3, 1)) . substr($name, 4); - - if (!isset($this->response[$propertyName])) { - throw new InvalidArgumentException("Method \"$name\" not found"); - } - - return $this->response[$propertyName]; - } - - /** - * Allow to access for the property throw object property - * - * @param string $name property name - * - * @throws \InvalidArgumentException - * - * @return mixed - */ - public function __get($name) - { - if (!isset($this->response[$name])) { - throw new InvalidArgumentException("Property \"$name\" not found"); - } - - return $this->response[$name]; - } - - /** - * Allow to check if the property exists through object property - * - * @param string $name property name - * - * @return bool - */ - public function __isset($name) - { - return isset($this->response[$name]); - } - - /** - * Offset set - * - * @param mixed $offset offset - * @param mixed $value value - * - * @throws BadMethodCallException - * @return void - */ - public function offsetSet($offset, $value) - { - $message = sprintf("This call not allowed. Offset given: %s. Value given: %s", $offset, $value); - throw new BadMethodCallException($message); - } - - /** - * Offset unset - * - * @param mixed $offset offset - * - * @throws BadMethodCallException - * @return void - */ - public function offsetUnset($offset) - { - $message = sprintf("This call not allowed. Offset given: %s", $offset); - throw new BadMethodCallException($message); - } - - /** - * Check offset - * - * @param mixed $offset offset - * - * @return bool - */ - public function offsetExists($offset) - { - return isset($this->response[$offset]); - } - - /** - * Get offset - * - * @param mixed $offset offset - * - * @throws \InvalidArgumentException - * - * @return mixed - */ - public function offsetGet($offset) - { - if (!isset($this->response[$offset])) { - throw new InvalidArgumentException("Property \"$offset\" not found"); - } - - return $this->response[$offset]; - } - - /** - * @param string $responseBody - * - * @return array - */ - public static function parseJSON($responseBody): array - { - $result = []; - - if (!empty($responseBody)) { - $response = json_decode($responseBody, true); - - if (!$response && JSON_ERROR_NONE !== ($error = json_last_error())) { - throw new InvalidJsonException("Invalid JSON in the API response body. Error code #$error", $error); - } - - $result = $response; - } - - return $result; - } -} diff --git a/src/Exception/LimitException.php b/src/Exception/LimitException.php index f79084c..9e65c70 100644 --- a/src/Exception/LimitException.php +++ b/src/Exception/LimitException.php @@ -18,7 +18,7 @@ use DomainException; /** * PHP version 7.0 * - * Class CurlException + * Class LimitException * * @package RetailCrm\Common\Exception * @author retailCRM diff --git a/src/Serializer.php b/src/Serializer.php index 85f46fb..190fac3 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -13,6 +13,8 @@ namespace RetailCrm\Common; +use JMS\Serializer\DeserializationContext; +use JMS\Serializer\SerializationContext; use JMS\Serializer\SerializerBuilder; /** @@ -27,14 +29,14 @@ use JMS\Serializer\SerializerBuilder; */ class Serializer { - const S_ARRAY = 0; - const S_JSON = 1; + const S_ARRAY = 'array'; + const S_JSON = 'json'; /** * Serialize given object to JSON or Array * * @param object $request - * @param int $serialize + * @param string $serialize * * @return array|string */ @@ -42,17 +44,79 @@ class Serializer { $serialized = null; $serializer = SerializerBuilder::create()->build(); + $context = self::getContext(); switch ($serialize) { case self::S_ARRAY: - $serialized = $serializer->toArray($request); + $serialized = $serializer->toArray($request, $context); break; case self::S_JSON: default: - $serialized = $serializer->serialize($request, 'json'); + $serialized = $serializer->serialize($request, $serialize, $context); break; } return $serialized; } + + /** + * Deserialize given array or JSON to object + * + * @param mixed $data + * @param string $entityType + * @param string $from + * + * @return object|null + */ + public static function deserialize($data, $entityType, $from = self::S_JSON) + { + $deserialized = null; + $serializer = SerializerBuilder::create()->build(); + $context = self::getContext(true); + + switch ($from) { + case self::S_ARRAY: + $deserialized = + $serializer->fromArray(array_filter($data), self::normalizeNamespace($entityType), $context); + break; + case self::S_JSON: + $deserialized = + $serializer->deserialize($data, self::normalizeNamespace($entityType), $from, $context); + break; + } + + return is_object($deserialized) ? $deserialized : null; + } + + /** + * @param bool $deserialization (default: false) + * + * @return DeserializationContext|SerializationContext + */ + private static function getContext(bool $deserialization = false) + { + if ($deserialization) { + $context = new DeserializationContext(); + } else { + $context = new SerializationContext(); + } + + $context->setSerializeNull(false); + + return $context; + } + + /** + * @param string $namespace + * + * @return bool|string + */ + private static function normalizeNamespace(string $namespace) + { + if (substr($namespace, 0, 1) == '\\') { + $namespace = substr($namespace, 1); + } + + return $namespace; + } } diff --git a/src/Url.php b/src/Url.php index 983c30d..9b0aef3 100644 --- a/src/Url.php +++ b/src/Url.php @@ -25,15 +25,12 @@ namespace RetailCrm\Common; */ class Url { - const RFC_DEFAULT = 1; - const RFC_CUSTOM = 2; - - private $parts = []; - - public function __toString() - { - return $this->build(); - } + /** + * This class is used to store normalizeUrl method + * which is used in Client and HttpClient to check + * trailing slash. + */ + private function __construct() {} /** * Check trailing slash into url @@ -52,75 +49,26 @@ class Url } /** - * Build request url + * Convert request data to GET parameters * - * @param string $path - * @param array $parameters - * @param int $rfc + * @param array $params * * @return string */ - public function buildUrl($path, $parameters, $rfc = self::RFC_DEFAULT) + public static function buildGetParameters(array $params) { - $url = $path; + $result = ''; - switch ($rfc) { - case self::RFC_CUSTOM: - foreach ($parameters as $key => $value) { - if (is_array($value)) { - foreach ($value as $element) { - $this->add($key, $element); - } - } else { - $this->add($key, $value); - } + foreach ($params as $param => $value) { + if (!is_array($value)) { + $result .= '&' . $param . '=' . $value; + } else { + foreach ($value as $subvalue) { + $result .= '&' . $param . '=' . $subvalue; } - - $url = sprintf("%s?%s", $url, $this->build()); - break; - case self::RFC_DEFAULT: - default: - $queryString = http_build_query($parameters, '', '&'); - $url = sprintf("%s?%s", $path, $queryString); - break; + } } - return $url; - } - - /** - * Add each key valued element of parameters array - * to internal structure before build - * - * @param string $key - * @param mixed $value - * - * @return void - */ - private function add($key, $value) - { - $this->parts[] = array( - 'key' => $key, - 'value' => $value - ); - } - - /** - * Build query string with same keys if needed - * - * @param string $separator - * @param string $equals - * - * @return string - */ - private function build($separator = '&', $equals = '=') - { - $queryString = array(); - - foreach ($this->parts as $part) { - $queryString[] = urlencode($part['key']) . $equals . urlencode($part['value']); - } - - return implode($separator, $queryString); + return strlen($result) > 0 ? '?' . substr($result, 1) : ''; } } diff --git a/tests/Bot/Test/TestCase.php b/tests/Bot/Test/TestCase.php index 52a455c..6722555 100644 --- a/tests/Bot/Test/TestCase.php +++ b/tests/Bot/Test/TestCase.php @@ -14,6 +14,9 @@ namespace RetailCrm\Mg\Bot\Test; use PHPUnit\Framework\TestCase as BaseCase; +use GuzzleHttp\Handler\MockHandler; +use GuzzleHttp\HandlerStack; +use GuzzleHttp\Psr7\Response; use RetailCrm\Mg\Bot\Client; /** @@ -30,25 +33,118 @@ class TestCase extends BaseCase /** * Return bot api client object * - * @param string $url (default: null) - * @param string $key (default: null) - * @param bool $debug (default: false) + * @param string $url (default: null) + * @param string $key (default: null) + * @param bool $debug (default: false) + * @param array $response (default: null) * - * @return \RetailCrm\Mg\Bot\Client + * @return Client */ public static function getApiClient( $url = null, $key = null, - $debug = false + $debug = false, + ...$response ) { $configUrl = getenv('MG_BOT_URL'); $configKey = getenv('MG_BOT_KEY'); $configDbg = getenv('MG_BOT_DBG'); + $mock = new MockHandler($response ?: []); return new Client( $url ?: $configUrl, $key ?: $configKey, - $debug ?: $configDbg + $debug ?: $configDbg, + empty($response) ? null : HandlerStack::create($mock) ); } + + /** + * Returns mocked GuzzleHttp response + * + * @param string|null $body + * @param int $statusCode + * + * @return Response + */ + public function getResponse(string $body = null, int $statusCode = 200) + { + return new Response( + $statusCode, + array_filter( + [ + 'Server' => 'openresty/1.13.6.2', + 'Date' => gmdate("D, d M Y H:m:s \G\M\T"), + 'Content-Type' => 'application/json; charset=utf-8', + 'Content-Length' => is_null($body) ? null : strlen($body), + 'Connection' => 'keep-alive', + 'Access-Control-Allow-Credentials' => 'true', + 'Access-Control-Allow-Headers' => 'X-Requested-With, Content-Type, X-Api-Key, X-Client-Token', + 'Access-Control-Allow-Methods' => 'GET, POST, PUT, DELETE, OPTIONS' + ] + ), + $body + ); + } + + /** + * Generate and return mocked response. + * Response data should be stored in Resources directory as json file. + * Only file name (without extension or any other data) should be provided, + * e.g. `getJsonResponse('bots', 200)` + * + * @param string $jsonFile + * @param int $statusCode + * + * @return Response|null + */ + public function getJsonResponse(string $jsonFile, int $statusCode = 200) + { + $fileName = realpath( + join( + DIRECTORY_SEPARATOR, + [__DIR__, '..', '..', 'Resources', \sprintf('%s.json', $jsonFile)] + ) + ); + + if (file_exists($fileName)) { + $json = file_get_contents($fileName); + json_decode($json, true); + + if (json_last_error() == JSON_ERROR_NONE) { + return $this->getResponse($json, $statusCode); + } + } else { + return null; + } + } + + /** + * @param int $statusCode + * @param array ...$errors + * + * @return Response + */ + public function getErrorsResponse(int $statusCode = 400, ...$errors) + { + $json = ['errors' => []]; + + foreach ($errors as $error) { + $json['errors'][] = is_string($error) ? $error : null; + } + + return $this->getResponse(json_encode(array_filter($json)), $statusCode); + } + + /** + * Generate and return empty response + * + * @param int $statusCode + * + * @return Response|null + */ + public function getEmptyResponse(int $statusCode = 200) + { + return $this->getResponse(null, $statusCode); + } } diff --git a/tests/Bot/Tests/ClientListTest.php b/tests/Bot/Tests/ClientListTest.php index dea988a..d2d6129 100644 --- a/tests/Bot/Tests/ClientListTest.php +++ b/tests/Bot/Tests/ClientListTest.php @@ -14,6 +14,13 @@ namespace RetailCrm\Mg\Bot\Tests; use RetailCrm\Mg\Bot\Model\Constants; +use RetailCrm\Mg\Bot\Model\Entity\Channel; +use RetailCrm\Mg\Bot\Model\Entity\Chat\Chat; +use RetailCrm\Mg\Bot\Model\Entity\Chat\ChatMember; +use RetailCrm\Mg\Bot\Model\Entity\Customer; +use RetailCrm\Mg\Bot\Model\Entity\Dialog; +use RetailCrm\Mg\Bot\Model\Entity\Message\Message; +use RetailCrm\Mg\Bot\Model\Entity\User; use RetailCrm\Mg\Bot\Model\Request; use RetailCrm\Mg\Bot\Test\TestCase; @@ -29,22 +36,27 @@ use RetailCrm\Mg\Bot\Test\TestCase; */ class ClientListTest extends TestCase { - /** * @group("list") * @throws \Exception */ public function testChannels() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('channels') + ); $request = new Request\ChannelsRequest(); $request->setActive(true); - $request->setTypes([Constants::CHANNEL_TYPE_FACEBOOK, Constants::CHANNEL_TYPE_INSTAGRAM]); + $request->setTypes([Constants::CHANNEL_TYPE_TELEGRAM, Constants::CHANNEL_TYPE_INSTAGRAM]); $response = $client->channels($request); - self::assertTrue($response->isSuccessful() == true); + static::assertEquals(4, count($response), "Incorrect channels count"); + static::assertTrue($response[0] instanceof Channel\Channel, "Incorrect channel instance"); } /** @@ -53,14 +65,20 @@ class ClientListTest extends TestCase */ public function testChats() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('chats') + ); $request = new Request\ChatsRequest(); - $request->setChannelType(Constants::CHANNEL_TYPE_FACEBOOK); + $request->setChannelType(Constants::CHANNEL_TYPE_TELEGRAM); $response = $client->chats($request); - self::assertTrue($response->isSuccessful() == true); + static::assertEquals(2, count($response), "Incorrect chats count"); + static::assertTrue($response[0] instanceof Chat, "Incorrect chat instance"); } /** @@ -69,13 +87,18 @@ class ClientListTest extends TestCase */ public function testMembers() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('members') + ); $request = new Request\MembersRequest(); - $response = $client->members($request); - self::assertTrue($response->isSuccessful() == true); + static::assertEquals(4, count($response), "Incorrect members count"); + static::assertTrue($response[0] instanceof ChatMember, "Incorrect member instance"); } /** @@ -84,7 +107,12 @@ class ClientListTest extends TestCase */ public function testMessages() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('messages') + ); $request = new Request\MessagesRequest(); $request->setChannelType(Constants::CHANNEL_TYPE_INSTAGRAM); @@ -92,7 +120,8 @@ class ClientListTest extends TestCase $response = $client->messages($request); - self::assertTrue($response->isSuccessful() == true); + static::assertEquals(2, count($response), "Incorrect message count"); + static::assertTrue($response[0] instanceof Message, "Incorrect message instance"); } /** @@ -101,13 +130,17 @@ class ClientListTest extends TestCase */ public function testCommands() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getResponse('[]') + ); $request = new Request\CommandsRequest(); - $response = $client->commands($request); - self::assertTrue($response->isSuccessful() == true); + self::assertEquals(0, count($response), "Invalid commands count"); } /** @@ -116,15 +149,20 @@ class ClientListTest extends TestCase */ public function testBots() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('bots') + ); $request = new Request\BotsRequest(); $request->setActive(1); $request->setRoles([Constants::BOT_ROLE_RESPONSIBLE]); - $response = $client->bots($request); + $data = $client->bots($request); - self::assertTrue($response->isSuccessful() == true); + static::assertEquals(3, count($data)); } /** @@ -133,7 +171,12 @@ class ClientListTest extends TestCase */ public function testUsers() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('users') + ); $request = new Request\UsersRequest(); $request->setActive(1); @@ -141,7 +184,8 @@ class ClientListTest extends TestCase $response = $client->users($request); - self::assertTrue($response->isSuccessful() == true); + self::assertEquals(2, count($response)); + self::assertTrue($response[0] instanceof User); } /** @@ -150,7 +194,12 @@ class ClientListTest extends TestCase */ public function testDialogs() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('dialogs') + ); $request = new Request\DialogsRequest(); $request->setActive(1); @@ -158,7 +207,8 @@ class ClientListTest extends TestCase $response = $client->dialogs($request); - self::assertTrue($response->isSuccessful() == true); + self::assertEquals(2, count($response)); + self::assertTrue($response[0] instanceof Dialog); } /** @@ -167,12 +217,18 @@ class ClientListTest extends TestCase */ public function testCustomers() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('customers') + ); $request = new Request\CustomersRequest(); $response = $client->customers($request); - self::assertTrue($response->isSuccessful() == true); + self::assertEquals(2, count($response)); + self::assertTrue($response[0] instanceof Customer); } } diff --git a/tests/Bot/Tests/CommandsTest.php b/tests/Bot/Tests/CommandsTest.php index db3c6d3..91f059d 100644 --- a/tests/Bot/Tests/CommandsTest.php +++ b/tests/Bot/Tests/CommandsTest.php @@ -3,7 +3,7 @@ /** * PHP version 7.0 * - * Client Test + * Commands Test * * @package RetailCrm\Mg\Bot\Tests * @author retailCRM @@ -13,15 +13,15 @@ namespace RetailCrm\Mg\Bot\Tests; -use Exception; -use InvalidArgumentException; +use RetailCrm\Common\Exception\InvalidJsonException; use RetailCrm\Mg\Bot\Model\Request\CommandEditRequest; +use RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse; use RetailCrm\Mg\Bot\Test\TestCase; /** * PHP version 7.0 * - * Class ClientTest + * Class CommandsTest * * @package RetailCrm\Mg\Bot\Tests * @author retailCRM @@ -36,9 +36,14 @@ class CommandsTest extends TestCase */ public function testCommandEditException() { - self::expectException(InvalidArgumentException::class); + self::expectException(InvalidJsonException::class); - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getResponse('EOF', 400) + ); $request = new CommandEditRequest(); $request->setDescription("qwerty"); @@ -52,7 +57,7 @@ class CommandsTest extends TestCase */ public function testCommandDeleteException() { - self::expectException(Exception::class); + self::expectException(\Exception::class); $client = self::getApiClient(); @@ -67,7 +72,12 @@ class CommandsTest extends TestCase */ public function testCommandEdit() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('commandEdit') + ); $request = new CommandEditRequest(); $request->setBotId(1); @@ -76,7 +86,8 @@ class CommandsTest extends TestCase $response = $client->commandEdit($request); - self::assertTrue($response->isSuccessful() == true); + self::assertTrue($response instanceof ErrorOnlyResponse); + self::assertTrue($response->isSuccessful()); } /** @@ -86,7 +97,12 @@ class CommandsTest extends TestCase */ public function testCommandDelete() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('commandEdit') + ); $response = $client->commandDelete("show_payment_types"); diff --git a/tests/Bot/Tests/DialogsTest.php b/tests/Bot/Tests/DialogsTest.php new file mode 100644 index 0000000..7cfa32c --- /dev/null +++ b/tests/Bot/Tests/DialogsTest.php @@ -0,0 +1,118 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Tests; + +use InvalidArgumentException; +use RetailCrm\Mg\Bot\Model\Entity\Responsible; +use RetailCrm\Mg\Bot\Model\Request\DialogAssignRequest; +use RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse; +use RetailCrm\Mg\Bot\Test\TestCase; + +/** + * PHP version 7.0 + * + * Class DialogsTest + * + * @package RetailCrm\Mg\Bot\Tests + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class DialogsTest extends TestCase +{ + /** + * @group("dialogs") + * @throws \Exception + */ + public function testDialogAssignError() + { + $client = self::getApiClient( + null, + null, + false, + $this->getErrorsResponse(400, "incorrect dialog_id") + ); + + $request = new DialogAssignRequest(); + $request->setDialogId(-1); + + $response = $client->dialogAssign($request); + + self::assertTrue(!$response->isSuccessful()); + self::assertNotEmpty($response->getErrors()); + } + + /** + * @group("dialogs") + * @throws \Exception + */ + public function testDialogAssign() + { + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('dialogReassigned') + ); + + $request = new DialogAssignRequest(); + $request->setDialogId(60); + $request->setUserId(4); + + $response = $client->dialogAssign($request); + + self::assertTrue($response->isSuccessful()); + self::assertTrue($response->getIsReassign()); + self::assertTrue($response->getPreviousResponsible() instanceof Responsible); + self::assertTrue($response->getResponsible() instanceof Responsible); + } + + /** + * @group("dialogs") + * @throws \Exception + */ + public function testDialogCloseError() + { + self::expectException(InvalidArgumentException::class); + + $client = self::getApiClient( + null, + null, + false, + $this->getErrorsResponse(404, "dialog #2131231231 not found") + ); + + $client->dialogClose('2131231231'); + } + + /** + * @group("dialogs") + * @throws \Exception + */ + public function testDialogClose() + { + $client = self::getApiClient( + null, + null, + false, + $this->getResponse('{}') + ); + + $response = $client->dialogClose('62'); + + self::assertTrue($response instanceof ErrorOnlyResponse); + self::assertTrue($response->isSuccessful()); + self::assertEmpty($response->getErrors()); + } +} diff --git a/tests/Bot/Tests/FileTest.php b/tests/Bot/Tests/FileTest.php new file mode 100644 index 0000000..430ba1c --- /dev/null +++ b/tests/Bot/Tests/FileTest.php @@ -0,0 +1,111 @@ + + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ + +namespace RetailCrm\Mg\Bot\Tests; + +use RetailCrm\Mg\Bot\Model\Response\FullFileResponse; +use RetailCrm\Mg\Bot\Model\Response\UploadFileResponse; +use RetailCrm\Mg\Bot\Test\TestCase; + +/** + * PHP version 7.0 + * + * Class UploadFileTest + * + * @package RetailCrm\Mg\Bot\Tests + * @author retailCRM + * @license https://opensource.org/licenses/MIT MIT License + * @link http://help.retailcrm.pro/docs/Developers + */ +class FileTest extends TestCase +{ + /** + * @group("upload") + * @throws \Exception + */ + public function testUploadFileByUrlException() + { + $client = self::getApiClient( + null, + null, + false, + $this->getEmptyResponse(400) + ); + + self::expectException(\InvalidArgumentException::class); + $client->uploadFileByUrl(''); + $client->uploadFileByUrl('rar'); + } + + /** + * @group("upload") + * @throws \Exception + */ + public function testUploadFileByUrl() + { + $client = self::getApiClient( + null, + null, + false, + $this->getResponse('{"id":"881712bb-4062-4973-9e23-3373135836e2","type":"image","size":3773}') + ); + + $response = $client->uploadFileByUrl('https://2ip.ru/images/logo.gif'); + + self::assertTrue($response->isSuccessful()); + self::assertEquals('881712bb-4062-4973-9e23-3373135836e2', $response->getId()); + self::assertEquals('image', $response->getType()); + self::assertEquals('3773', $response->getSize()); + } + + /** + * @group("upload") + * @throws \Exception + */ + public function testUploadFileViaForm() + { + $client = self::getApiClient( + null, + null, + false, + $this->getResponse('{"id":"b2bdba90-166c-4e0a-829d-69f26a09fd2a","type":"file","size":214}') + ); + + $response = $client->uploadFile(__FILE__); + + self::assertTrue($response instanceof UploadFileResponse); + self::assertEquals('b2bdba90-166c-4e0a-829d-69f26a09fd2a', $response->getId()); + self::assertEquals('file', $response->getType()); + self::assertEquals(214, $response->getSize()); + } + + /** + * @group("upload") + * @throws \Exception + */ + public function testGetFileById() + { + $fileId = 'b2bdba90-166c-4e0a-829d-69f26a09fd2a'; + $client = self::getApiClient( + null, + null, + false, + $this->getJsonResponse('getFile') + ); + + $response = $client->getFileById($fileId); + + self::assertTrue($response instanceof FullFileResponse); + self::assertEquals($fileId, $response->getId()); + } +} diff --git a/tests/Bot/Tests/MessagesTest.php b/tests/Bot/Tests/MessagesTest.php index 259304f..e38d6ff 100644 --- a/tests/Bot/Tests/MessagesTest.php +++ b/tests/Bot/Tests/MessagesTest.php @@ -3,7 +3,7 @@ /** * PHP version 7.0 * - * Client Test + * Messages Test * * @package RetailCrm\Mg\Bot\Tests * @author retailCRM @@ -13,12 +13,8 @@ namespace RetailCrm\Mg\Bot\Tests; -use Exception; -use InvalidArgumentException; -use RetailCrm\Common\Exception\CurlException; -use RetailCrm\Common\Exception\InvalidJsonException; use RetailCrm\Mg\Bot\Model\Constants; -use RetailCrm\Mg\Bot\Model\Request\CommandEditRequest; +use RetailCrm\Mg\Bot\Model\Request\MessageEditRequest; use RetailCrm\Mg\Bot\Model\Request\MessageSendRequest; use RetailCrm\Mg\Bot\Test\TestCase; @@ -38,17 +34,144 @@ class MessagesTest extends TestCase * @group("messages") * @throws \Exception */ - public function testMessageSend() + public function testMessageSendError() { - $client = self::getApiClient(); + $client = self::getApiClient( + null, + null, + false, + $this->getErrorsResponse( + 400, + 'chat_id is a required field' + ) + ); $request = new MessageSendRequest(); $request->setChatId(0); $request->setScope(Constants::MESSAGE_SCOPE_PUBLIC); $request->setContent("Hello"); - $request = $client->messageSend($request); + $response = $client->messageSend($request); - self::assertEquals($request->getStatusCode(), 400); + self::assertTrue(!$response->isSuccessful()); + self::assertEquals(1, count($response->getErrors())); + } + + /** + * @group("messages") + * @throws \Exception + */ + public function testMessageSend() + { + $client = self::getApiClient( + null, + null, + false, + $this->getResponse( + '{"message_id":3636,"time":"2019-06-24T06:02:04.434291791Z"}', + 201 + ) + ); + + $request = new MessageSendRequest(); + $request->setChatId(28); + $request->setScope(Constants::MESSAGE_SCOPE_PUBLIC); + $request->setContent("Hello"); + + $response = $client->messageSend($request); + + self::assertTrue($response->isSuccessful()); + self::assertEquals(0, count($response->getErrors())); + self::assertEquals(3636, $response->getMessageId()); + } + + /** + * @group("messages") + * @throws \Exception + */ + public function testMessageEditError() + { + $client = self::getApiClient( + null, + null, + false, + $this->getErrorsResponse( + 400, + 'Incorrect message_id' + ) + ); + + $request = new MessageEditRequest(); + $request->setId(0); + $request->setContent("Hello"); + + $response = $client->messageEdit($request); + + self::assertTrue(!$response->isSuccessful()); + self::assertEquals(1, count($response->getErrors())); + } + + /** + * @group("messages") + * @throws \Exception + */ + public function testMessageEdit() + { + $client = self::getApiClient( + null, + null, + false, + $this->getResponse('{}', 200) + ); + + $request = new MessageEditRequest(); + $request->setId(3636); + $request->setContent("123"); + + $response = $client->messageEdit($request); + + self::assertTrue($response->isSuccessful()); + self::assertEquals(0, count($response->getErrors())); + } + + /** + * @group("messages") + * @throws \Exception + */ + public function testMessageDeleteError() + { + $client = self::getApiClient( + null, + null, + false, + $this->getErrorsResponse( + 400, + 'Incorrect message_id' + ) + ); + + $response = $client->messageDelete('0'); + + self::assertTrue(!$response->isSuccessful()); + self::assertEquals(1, count($response->getErrors())); + } + + /** + * @group("messages") + * @throws \Exception + */ + public function testMessageDelete() + { + $client = self::getApiClient( + null, + null, + false, + $this->getResponse('{}', 200) + ); + + $response = $client->messageDelete('3636'); + + self::assertTrue($response->isSuccessful()); + self::assertEquals(0, count($response->getErrors())); } } diff --git a/tests/Resources/bots.json b/tests/Resources/bots.json new file mode 100644 index 0000000..728f667 --- /dev/null +++ b/tests/Resources/bots.json @@ -0,0 +1,46 @@ +[ + { + "id": 9, + "name": "Помощник", + "events": null, + "client_id": "identifier_1", + "avatar_url": "https://s3-s1.retailcrm.tech/eu-central-1/retailcrm-billing/images/5b927ad342366-bot-logo.svg", + "roles": null, + "created_at": "2018-09-13T07:38:02.988438Z", + "updated_at": "2019-06-13T12:56:36.346811Z", + "deactivated_at": null, + "is_active": true, + "is_self": true, + "is_system": false + }, + { + "id": 7, + "name": "Helper", + "events": null, + "client_id": "identifier_2", + "avatar_url": "https://test.te/static/logo.svg", + "roles": null, + "created_at": "2018-09-07T07:27:41.87424Z", + "updated_at": "2018-10-25T07:43:03.077956Z", + "deactivated_at": "2019-10-25T07:43:03.077956Z", + "is_active": false, + "is_self": false, + "is_system": false + }, + { + "id": 6, + "name": "Mira chat bot", + "events": null, + "client_id": "identifier_3", + "avatar_url": "https://s3.retailcrm.pro/eu-central-1/retailcrm-billing/images/5b97bfd983d2b-bot-logo-2.svg", + "roles": [ + "responsible" + ], + "created_at": "2018-09-06T13:40:02.956515Z", + "updated_at": "2018-09-12T06:15:32.858632Z", + "deactivated_at": null, + "is_active": true, + "is_self": false, + "is_system": false + } +] \ No newline at end of file diff --git a/tests/Resources/channels.json b/tests/Resources/channels.json new file mode 100644 index 0000000..fb685d8 --- /dev/null +++ b/tests/Resources/channels.json @@ -0,0 +1,178 @@ +[ + { + "id": 72, + "type": "telegram", + "name": "@testbot", + "settings": { + "status": { + "delivered": "send" + }, + "text": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_chars_count": 4096 + }, + "product": { + "creating": "receive", + "editing": "receive" + }, + "order": { + "creating": "receive", + "editing": "receive" + }, + "image": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 10 + }, + "file": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 1 + } + }, + "created_at": "2019-06-11T12:46:48.72241Z", + "updated_at": "2019-06-11T12:56:48.72241Z", + "activated_at": "2019-06-11T12:46:48.722086Z", + "deactivated_at": null, + "is_active": true + }, + { + "id": 71, + "type": "telegram", + "name": "@testbot", + "settings": { + "status": { + "delivered": "send" + }, + "text": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_chars_count": 4096 + }, + "product": { + "creating": "receive", + "editing": "receive" + }, + "order": { + "creating": "receive", + "editing": "receive" + }, + "image": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 10 + }, + "file": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 1 + } + }, + "created_at": "2019-06-11T12:41:44.660495Z", + "updated_at": "2019-06-11T12:46:42.094353Z", + "activated_at": "2019-06-11T12:41:44.660204Z", + "deactivated_at": "2019-06-11T12:46:42.094135Z", + "is_active": true + }, + { + "id": 70, + "type": "telegram", + "name": "@testbot", + "settings": { + "status": { + "delivered": "send" + }, + "text": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_chars_count": 4096 + }, + "product": { + "creating": "receive", + "editing": "receive" + }, + "order": { + "creating": "receive", + "editing": "receive" + }, + "image": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 10 + }, + "file": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 1 + } + }, + "created_at": "2019-06-11T12:38:24.322413Z", + "updated_at": "2019-06-11T12:41:42.335889Z", + "activated_at": "2019-06-11T12:38:24.322125Z", + "deactivated_at": "2019-06-11T12:41:42.335678Z", + "is_active": true + }, + { + "id": 69, + "type": "telegram", + "name": "@testbot", + "settings": { + "status": { + "delivered": "send" + }, + "text": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_chars_count": 4096 + }, + "product": { + "creating": "receive", + "editing": "receive" + }, + "order": { + "creating": "receive", + "editing": "receive" + }, + "image": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 10 + }, + "file": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 1 + } + }, + "created_at": "2019-06-11T12:33:08.676214Z", + "updated_at": "2019-06-11T12:38:19.615651Z", + "activated_at": "2019-06-11T12:33:08.676043Z", + "deactivated_at": "2019-06-11T12:38:19.615335Z", + "is_active": true + } +] \ No newline at end of file diff --git a/tests/Resources/chats.json b/tests/Resources/chats.json new file mode 100644 index 0000000..1bd6785 --- /dev/null +++ b/tests/Resources/chats.json @@ -0,0 +1,116 @@ +[ + { + "id": 30, + "avatar": "", + "name": "", + "channel": { + "id": 72, + "avatar": "", + "transport_id": 4, + "type": "fbmessenger", + "settings": { + "status": { + "delivered": "send" + }, + "text": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_chars_count": 4096 + }, + "product": { + "creating": "receive", + "editing": "receive" + }, + "order": { + "creating": "receive", + "editing": "receive" + }, + "image": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 10 + }, + "file": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 1 + } + }, + "name": "testbot", + "is_active": true + }, + "members": null, + "customer": { + "id": 39, + "type": "customer", + "avatar": "", + "name": "Иван", + "username": "Иван", + "first_name": "Иван" + }, + "author_id": 0, + "last_message": null, + "last_activity": "2019-06-11T17:36:20+03:00", + "created_at": "2019-06-11T12:49:26.938879Z", + "updated_at": "2019-06-14T14:40:28.7111Z" + }, + { + "id": 29, + "avatar": "", + "name": "", + "channel": { + "id": 68, + "avatar": "", + "transport_id": 5, + "type": "fbmessenger", + "settings": { + "status": { + "delivered": "send", + "read": "send" + }, + "text": { + "creating": "both", + "quoting": "receive", + "max_chars_count": 2000 + }, + "product": { + "creating": "receive" + }, + "order": { + "creating": "receive" + }, + "image": { + "creating": "both", + "max_items_count": 10 + }, + "file": { + "creating": "both", + "max_items_count": 10 + } + }, + "name": "testbot", + "is_active": false + }, + "members": null, + "customer": { + "id": 38, + "type": "customer", + "avatar": "", + "name": "Пётр Петрович", + "username": "Пётр", + "first_name": "Пётр", + "last_name": "Петрович" + }, + "author_id": 0, + "last_message": null, + "last_activity": "2019-06-13T11:07:14+03:00", + "created_at": "2019-06-11T07:34:16.082957Z", + "updated_at": "2019-06-16T08:10:28.657972Z" + } +] \ No newline at end of file diff --git a/tests/Resources/commandEdit.json b/tests/Resources/commandEdit.json new file mode 100644 index 0000000..6f28ef9 --- /dev/null +++ b/tests/Resources/commandEdit.json @@ -0,0 +1 @@ +{"id":6,"name":"show_payment_types","description":"Get available payment types","created_at":"2019-06-19T09:02:35Z","updated_at":"2019-06-19T09:39:00Z"} \ No newline at end of file diff --git a/tests/Resources/customers.json b/tests/Resources/customers.json new file mode 100644 index 0000000..280b478 --- /dev/null +++ b/tests/Resources/customers.json @@ -0,0 +1,34 @@ +[ + { + "id": 39, + "external_id": "333296016", + "channel_id": 3, + "username": "user1", + "first_name": "User1", + "last_name": "Lastname1", + "created_at": "2019-06-11T12:49:26.935824Z", + "updated_at": "2019-06-11T14:36:20.840304Z", + "avatar_url": "", + "profile_url": "", + "country": "", + "language": "en", + "phone": "", + "email": "" + }, + { + "id": 38, + "external_id": "2272664739519803", + "channel_id": 3, + "username": "user2", + "first_name": "User2", + "last_name": "Lastname2", + "created_at": "2019-06-11T07:34:16.079453Z", + "updated_at": "2019-06-13T08:07:14.898472Z", + "avatar_url": "", + "profile_url": "", + "country": "", + "language": "ru", + "phone": "", + "email": "" + } +] \ No newline at end of file diff --git a/tests/Resources/dialogReassigned.json b/tests/Resources/dialogReassigned.json new file mode 100644 index 0000000..60f9aa0 --- /dev/null +++ b/tests/Resources/dialogReassigned.json @@ -0,0 +1 @@ +{"responsible":{"type":"user","id":4,"assigned_at":"2019-06-21T08:01:09Z"},"is_reassign":true,"previous_responsible":{"type":"user","id":12,"assigned_at":"2019-06-11T12:49:34Z"},"left_user_id":12} \ No newline at end of file diff --git a/tests/Resources/dialogs.json b/tests/Resources/dialogs.json new file mode 100644 index 0000000..b7e750b --- /dev/null +++ b/tests/Resources/dialogs.json @@ -0,0 +1,34 @@ +[ + { + "id": 60, + "chat_id": 30, + "begin_message_id": 3540, + "ending_message_id": 3625, + "created_at": "2019-06-11T12:49:26.955306Z", + "updated_at": "2019-06-14T14:40:28.711974Z", + "closed_at": "2019-06-14T14:40:28.684683Z", + "is_assigned": true, + "responsible": { + "type": "user", + "id": 12, + "assigned_at": "2019-06-11T12:49:34.716716Z" + }, + "is_active": true + }, + { + "id": 59, + "chat_id": 29, + "begin_message_id": 3483, + "ending_message_id": 3626, + "created_at": "2019-06-11T07:34:16.101228Z", + "updated_at": "2019-06-16T08:10:28.659389Z", + "closed_at": "2019-06-16T08:10:28.645607Z", + "is_assigned": true, + "responsible": { + "type": "user", + "id": 12, + "assigned_at": "2019-06-11T08:40:14.136916Z" + }, + "is_active": true + } +] \ No newline at end of file diff --git a/tests/Resources/getFile.json b/tests/Resources/getFile.json new file mode 100644 index 0000000..ed16333 --- /dev/null +++ b/tests/Resources/getFile.json @@ -0,0 +1 @@ +{"id":"b2bdba90-166c-4e0a-829d-69f26a09fd2a","type":"file","size":214,"Url":"https://s3.eu-central-1.amazonaws.com/mg-node-files/files/21/b2bdba90-166c-4e0a-829d-69f26a09fd2a"} \ No newline at end of file diff --git a/tests/Resources/members.json b/tests/Resources/members.json new file mode 100644 index 0000000..e3f8672 --- /dev/null +++ b/tests/Resources/members.json @@ -0,0 +1,38 @@ +[ + { + "id": 50, + "created_at": "2019-06-11T12:49:34.718596Z", + "updated_at": "2019-06-11T14:36:22.086823Z", + "is_author": false, + "state": "active", + "chat_id": 30, + "user_id": 12 + }, + { + "id": 49, + "created_at": "2019-06-11T12:49:26.967903Z", + "updated_at": "2019-06-11T12:49:34.723983Z", + "is_author": false, + "state": "kicked", + "chat_id": 30, + "user_id": 4 + }, + { + "id": 48, + "created_at": "2019-06-11T08:40:14.139024Z", + "updated_at": "2019-06-13T08:10:03.576754Z", + "is_author": false, + "state": "active", + "chat_id": 29, + "user_id": 12 + }, + { + "id": 47, + "created_at": "2019-06-11T07:34:16.117109Z", + "updated_at": "2019-06-11T08:40:14.145243Z", + "is_author": false, + "state": "kicked", + "chat_id": 29, + "user_id": 4 + } +] \ No newline at end of file diff --git a/tests/Resources/messages.json b/tests/Resources/messages.json new file mode 100644 index 0000000..dcd9b55 --- /dev/null +++ b/tests/Resources/messages.json @@ -0,0 +1,48 @@ +[ + { + "id": 3376, + "time": "2019-05-20T17:17:28+03:00", + "type": "text", + "scope": "public", + "chat_id": 26, + "is_read": false, + "is_edit": false, + "status": "seen", + "from": { + "id": 35, + "type": "customer", + "avatar": "", + "name": "Иванов Иван", + "username": "username", + "first_name": "Иванов Иван" + }, + "content": "Text", + "quote": null, + "channel_id": 61, + "created_at": "2019-05-20T14:17:28.025314Z", + "updated_at": "2019-05-20T14:20:57.05964Z" + }, + { + "id": 3373, + "time": "2019-05-20T15:24:52+03:00", + "type": "text", + "scope": "public", + "chat_id": 26, + "is_read": false, + "is_edit": false, + "status": "seen", + "from": { + "id": 35, + "type": "customer", + "avatar": "", + "name": "Иванов Иван", + "username": "username", + "first_name": "Иванов Иван" + }, + "content": "❤️", + "quote": null, + "channel_id": 61, + "created_at": "2019-05-20T12:24:52.478633Z", + "updated_at": "2019-05-20T12:24:52.585284Z" + } +] \ No newline at end of file diff --git a/tests/Resources/users.json b/tests/Resources/users.json new file mode 100644 index 0000000..4a47fa8 --- /dev/null +++ b/tests/Resources/users.json @@ -0,0 +1,23 @@ +[ + { + "id": 1, + "external_id": "11", + "username": "User 1", + "first_name": "User", + "created_at": "2018-10-02T10:10:10.066295Z", + "updated_at": "2019-06-17T07:40:26.613546Z", + "is_online": false, + "is_active": true, + "avatar_url": "" + }, + { + "id": 2, + "external_id": "22", + "username": "User 2", + "first_name": "User", + "created_at": "2018-09-06T13:19:25.01842Z", + "updated_at": "2019-06-07T11:36:52.342065Z", + "is_online": false, + "is_active": true + } +] \ No newline at end of file diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d5251eb..7255d36 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -12,4 +12,9 @@ $loader->add('RetailCrm\\Mg\\Bot\\Test', __DIR__); use Symfony\Component\Dotenv\Dotenv; $dotenv = new Dotenv(); -$dotenv->load(__DIR__ . '/../.env'); + +try { + $dotenv->load(__DIR__ . '/../.env'); +} catch (Exception $exception) { + echo "WARNING: Can't load .env file. Using default environment."; +}