add request model (except ws and files), move serializer & url handling into separate namespace
This commit is contained in:
parent
114e02ab72
commit
0e2892581b
42 changed files with 3458 additions and 318 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -82,7 +82,7 @@ fabric.properties
|
|||
### NetBeans template
|
||||
nbproject/private/
|
||||
nbbuild/
|
||||
dist/
|
||||
/dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
### Eclipse template
|
||||
|
@ -183,3 +183,4 @@ $RECYCLE.BIN/
|
|||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
/.php_cs.cache
|
||||
|
|
|
@ -13,4 +13,4 @@ before_script:
|
|||
- flags="-o"
|
||||
- composer install $flags
|
||||
|
||||
script: php ./vendor/phpunit/phpunit/phpunit -c phpunit.xml.dist
|
||||
script: make test
|
||||
|
|
2
Makefile
2
Makefile
|
@ -10,7 +10,7 @@ deps:
|
|||
test:
|
||||
@echo "==> Running tests"
|
||||
@cd $(ROOT_DIR)
|
||||
@php -d memory_limit=-1 $(BIN_DIR)/phpunit -c phpunit.xml.dist --log-junit test-report.xml
|
||||
@php -d memory_limit=-1 $(BIN_DIR)/phpunit -c phpunit.xml.dist --log-junit $(ROOT_DIR)/test-report.xml
|
||||
@echo "==> Testing complete"
|
||||
|
||||
stan:
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
"phpmd/phpmd": "2.6.*",
|
||||
"phpstan/phpstan": "0.9.*",
|
||||
"squizlabs/php_codesniffer": "3.4.*",
|
||||
"symfony/dotenv": "^4.2"
|
||||
"symfony/dotenv": "^4.2",
|
||||
"friendsofphp/php-cs-fixer": "^2.14"
|
||||
},
|
||||
"support": {
|
||||
"email": "support@retailcrm.ru"
|
||||
|
|
670
composer.lock
generated
670
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "36d096c81a3aa192b431d6237766fca4",
|
||||
"content-hash": "e2dc59137064db9a4933e3049f8e0c34",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
|
@ -807,6 +807,200 @@
|
|||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "composer/semver",
|
||||
"version": "1.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/composer/semver.git",
|
||||
"reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/composer/semver/zipball/46d9139568ccb8d9e7cdd4539cab7347568a5e2e",
|
||||
"reference": "46d9139568ccb8d9e7cdd4539cab7347568a5e2e",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.3.2 || ^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.5 || ^5.0.5",
|
||||
"phpunit/phpunit-mock-objects": "2.3.0 || ^3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Composer\\Semver\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Nils Adermann",
|
||||
"email": "naderman@naderman.de",
|
||||
"homepage": "http://www.naderman.de"
|
||||
},
|
||||
{
|
||||
"name": "Jordi Boggiano",
|
||||
"email": "j.boggiano@seld.be",
|
||||
"homepage": "http://seld.be"
|
||||
},
|
||||
{
|
||||
"name": "Rob Bast",
|
||||
"email": "rob.bast@gmail.com",
|
||||
"homepage": "http://robbast.nl"
|
||||
}
|
||||
],
|
||||
"description": "Semver library that offers utilities, version constraint parsing and validation.",
|
||||
"keywords": [
|
||||
"semantic",
|
||||
"semver",
|
||||
"validation",
|
||||
"versioning"
|
||||
],
|
||||
"time": "2019-03-19T17:25:45+00:00"
|
||||
},
|
||||
{
|
||||
"name": "composer/xdebug-handler",
|
||||
"version": "1.3.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/composer/xdebug-handler.git",
|
||||
"reference": "d17708133b6c276d6e42ef887a877866b909d892"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/composer/xdebug-handler/zipball/d17708133b6c276d6e42ef887a877866b909d892",
|
||||
"reference": "d17708133b6c276d6e42ef887a877866b909d892",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.3.2 || ^7.0",
|
||||
"psr/log": "^1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Composer\\XdebugHandler\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "John Stevenson",
|
||||
"email": "john-stevenson@blueyonder.co.uk"
|
||||
}
|
||||
],
|
||||
"description": "Restarts a process without xdebug.",
|
||||
"keywords": [
|
||||
"Xdebug",
|
||||
"performance"
|
||||
],
|
||||
"time": "2019-01-28T20:25:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "friendsofphp/php-cs-fixer",
|
||||
"version": "v2.14.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
|
||||
"reference": "ff401e58261ffc5934a58f795b3f95b355e276cb"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/ff401e58261ffc5934a58f795b3f95b355e276cb",
|
||||
"reference": "ff401e58261ffc5934a58f795b3f95b355e276cb",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"composer/semver": "^1.4",
|
||||
"composer/xdebug-handler": "^1.2",
|
||||
"doctrine/annotations": "^1.2",
|
||||
"ext-json": "*",
|
||||
"ext-tokenizer": "*",
|
||||
"php": "^5.6 || ^7.0",
|
||||
"php-cs-fixer/diff": "^1.3",
|
||||
"symfony/console": "^3.4.17 || ^4.1.6",
|
||||
"symfony/event-dispatcher": "^3.0 || ^4.0",
|
||||
"symfony/filesystem": "^3.0 || ^4.0",
|
||||
"symfony/finder": "^3.0 || ^4.0",
|
||||
"symfony/options-resolver": "^3.0 || ^4.0",
|
||||
"symfony/polyfill-php70": "^1.0",
|
||||
"symfony/polyfill-php72": "^1.4",
|
||||
"symfony/process": "^3.0 || ^4.0",
|
||||
"symfony/stopwatch": "^3.0 || ^4.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0",
|
||||
"justinrainbow/json-schema": "^5.0",
|
||||
"keradus/cli-executor": "^1.2",
|
||||
"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",
|
||||
"phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1",
|
||||
"phpunitgoodpractices/traits": "^1.5.1",
|
||||
"symfony/phpunit-bridge": "^4.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-mbstring": "For handling non-UTF8 characters in cache signature.",
|
||||
"php-cs-fixer/phpunit-constraint-isidenticalstring": "For IsIdenticalString constraint.",
|
||||
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "For XmlMatchesXsd constraint.",
|
||||
"symfony/polyfill-mbstring": "When enabling `ext-mbstring` is not possible."
|
||||
},
|
||||
"bin": [
|
||||
"php-cs-fixer"
|
||||
],
|
||||
"type": "application",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"PhpCsFixer\\": "src/"
|
||||
},
|
||||
"classmap": [
|
||||
"tests/Test/AbstractFixerTestCase.php",
|
||||
"tests/Test/AbstractIntegrationCaseFactory.php",
|
||||
"tests/Test/AbstractIntegrationTestCase.php",
|
||||
"tests/Test/Assert/AssertTokensTrait.php",
|
||||
"tests/Test/IntegrationCase.php",
|
||||
"tests/Test/IntegrationCaseFactory.php",
|
||||
"tests/Test/IntegrationCaseFactoryInterface.php",
|
||||
"tests/Test/InternalIntegrationCaseFactory.php",
|
||||
"tests/TestCase.php"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dariusz Rumiński",
|
||||
"email": "dariusz.ruminski@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"email": "fabien@symfony.com"
|
||||
}
|
||||
],
|
||||
"description": "A tool to automatically fix PHP code style",
|
||||
"time": "2019-02-17T17:44:13+00:00"
|
||||
},
|
||||
{
|
||||
"name": "jean85/pretty-package-versions",
|
||||
"version": "1.2",
|
||||
|
@ -1530,6 +1724,51 @@
|
|||
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
|
||||
"time": "2019-02-21T12:16:21+00:00"
|
||||
},
|
||||
{
|
||||
"name": "paragonie/random_compat",
|
||||
"version": "v9.99.99",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/paragonie/random_compat.git",
|
||||
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
|
||||
"reference": "84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "4.*|5.*",
|
||||
"vimeo/psalm": "^1"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes."
|
||||
},
|
||||
"type": "library",
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Paragon Initiative Enterprises",
|
||||
"email": "security@paragonie.com",
|
||||
"homepage": "https://paragonie.com"
|
||||
}
|
||||
],
|
||||
"description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7",
|
||||
"keywords": [
|
||||
"csprng",
|
||||
"polyfill",
|
||||
"pseudorandom",
|
||||
"random"
|
||||
],
|
||||
"time": "2018-07-02T15:55:56+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pdepend/pdepend",
|
||||
"version": "2.5.2",
|
||||
|
@ -1672,6 +1911,57 @@
|
|||
"description": "Library for handling version information and constraints",
|
||||
"time": "2017-03-05T17:38:23+00:00"
|
||||
},
|
||||
{
|
||||
"name": "php-cs-fixer/diff",
|
||||
"version": "v1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/PHP-CS-Fixer/diff.git",
|
||||
"reference": "78bb099e9c16361126c86ce82ec4405ebab8e756"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/PHP-CS-Fixer/diff/zipball/78bb099e9c16361126c86ce82ec4405ebab8e756",
|
||||
"reference": "78bb099e9c16361126c86ce82ec4405ebab8e756",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^5.6 || ^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.7.23 || ^6.4.3",
|
||||
"symfony/process": "^3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Kore Nordmann",
|
||||
"email": "mail@kore-nordmann.de"
|
||||
},
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de"
|
||||
},
|
||||
{
|
||||
"name": "SpacePossum"
|
||||
}
|
||||
],
|
||||
"description": "sebastian/diff v2 backport support for PHP5.6",
|
||||
"homepage": "https://github.com/PHP-CS-Fixer",
|
||||
"keywords": [
|
||||
"diff"
|
||||
],
|
||||
"time": "2018-02-15T16:58:55+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-common",
|
||||
"version": "1.0.1",
|
||||
|
@ -2503,6 +2793,53 @@
|
|||
],
|
||||
"time": "2017-02-14T16:28:37+00:00"
|
||||
},
|
||||
{
|
||||
"name": "psr/log",
|
||||
"version": "1.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/php-fig/log.git",
|
||||
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
|
||||
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psr\\Log\\": "Psr/Log/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "PHP-FIG",
|
||||
"homepage": "http://www.php-fig.org/"
|
||||
}
|
||||
],
|
||||
"description": "Common interface for logging libraries",
|
||||
"homepage": "https://github.com/php-fig/log",
|
||||
"keywords": [
|
||||
"log",
|
||||
"psr",
|
||||
"psr-3"
|
||||
],
|
||||
"time": "2018-11-20T15:27:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "sebastian/code-unit-reverse-lookup",
|
||||
"version": "1.0.1",
|
||||
|
@ -3378,6 +3715,70 @@
|
|||
],
|
||||
"time": "2019-04-01T07:32:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/event-dispatcher",
|
||||
"version": "v4.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/event-dispatcher.git",
|
||||
"reference": "ca5af306fbc37f3cf597e91bc9cfa0c7d3f33544"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ca5af306fbc37f3cf597e91bc9cfa0c7d3f33544",
|
||||
"reference": "ca5af306fbc37f3cf597e91bc9cfa0c7d3f33544",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/contracts": "^1.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/dependency-injection": "<3.4"
|
||||
},
|
||||
"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"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/dependency-injection": "",
|
||||
"symfony/http-kernel": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\EventDispatcher\\": ""
|
||||
},
|
||||
"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 EventDispatcher Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2019-03-30T15:58:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/filesystem",
|
||||
"version": "v4.2.5",
|
||||
|
@ -3477,6 +3878,273 @@
|
|||
"homepage": "https://symfony.com",
|
||||
"time": "2019-02-23T15:42:05+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/options-resolver",
|
||||
"version": "v4.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/options-resolver.git",
|
||||
"reference": "3896e5a7d06fd15fa4947694c8dcdd371ff147d1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/3896e5a7d06fd15fa4947694c8dcdd371ff147d1",
|
||||
"reference": "3896e5a7d06fd15fa4947694c8dcdd371ff147d1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\OptionsResolver\\": ""
|
||||
},
|
||||
"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 OptionsResolver Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"config",
|
||||
"configuration",
|
||||
"options"
|
||||
],
|
||||
"time": "2019-02-23T15:17:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php70",
|
||||
"version": "v1.11.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php70.git",
|
||||
"reference": "bc4858fb611bda58719124ca079baff854149c89"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/bc4858fb611bda58719124ca079baff854149c89",
|
||||
"reference": "bc4858fb611bda58719124ca079baff854149c89",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"paragonie/random_compat": "~1.0|~2.0|~9.99",
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.11-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Php70\\": ""
|
||||
},
|
||||
"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.0+ features to lower PHP versions",
|
||||
"homepage": "https://symfony.com",
|
||||
"keywords": [
|
||||
"compatibility",
|
||||
"polyfill",
|
||||
"portable",
|
||||
"shim"
|
||||
],
|
||||
"time": "2019-02-06T07:57:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-php72",
|
||||
"version": "v1.11.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/polyfill-php72.git",
|
||||
"reference": "ab50dcf166d5f577978419edd37aa2bb8eabce0c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/ab50dcf166d5f577978419edd37aa2bb8eabce0c",
|
||||
"reference": "ab50dcf166d5f577978419edd37aa2bb8eabce0c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.11-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Polyfill\\Php72\\": ""
|
||||
},
|
||||
"files": [
|
||||
"bootstrap.php"
|
||||
]
|
||||
},
|
||||
"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.2+ 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": "v4.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/process.git",
|
||||
"reference": "1e6cbb41dadcaf29e0db034d6ad0d039a9df06e6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/process/zipball/1e6cbb41dadcaf29e0db034d6ad0d039a9df06e6",
|
||||
"reference": "1e6cbb41dadcaf29e0db034d6ad0d039a9df06e6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Process\\": ""
|
||||
},
|
||||
"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 Process Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2019-03-10T20:07:02+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/stopwatch",
|
||||
"version": "v4.2.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/stopwatch.git",
|
||||
"reference": "b1a5f646d56a3290230dbc8edf2a0d62cda23f67"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/b1a5f646d56a3290230dbc8edf2a0d62cda23f67",
|
||||
"reference": "b1a5f646d56a3290230dbc8edf2a0d62cda23f67",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/contracts": "^1.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "4.2-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Component\\Stopwatch\\": ""
|
||||
},
|
||||
"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 Stopwatch Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2019-01-16T20:31:39+00:00"
|
||||
},
|
||||
{
|
||||
"name": "theseer/tokenizer",
|
||||
"version": "1.1.2",
|
||||
|
|
|
@ -15,6 +15,8 @@ namespace RetailCrm\Mg\Bot;
|
|||
|
||||
use RetailCrm\Common\Exception\CurlException;
|
||||
use RetailCrm\Common\Exception\InvalidJsonException;
|
||||
use RetailCrm\Common\Url;
|
||||
use RetailCrm\Common\Serializer;
|
||||
use RetailCrm\Mg\Bot\Model;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
|
@ -44,7 +46,7 @@ class Client
|
|||
*/
|
||||
public function __construct($url, $token, $debug = false)
|
||||
{
|
||||
$url = sprintf("%sapi/bot/%s", Request::normalizeUrl($url), self::VERSION);
|
||||
$url = sprintf("%sapi/bot/%s", Url::normalizeUrl($url), self::VERSION);
|
||||
$this->client = new Request($url, $token, $debug);
|
||||
}
|
||||
|
||||
|
@ -62,7 +64,24 @@ class Client
|
|||
*/
|
||||
public function bots(Model\Request\BotsRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/bots', Request::METHOD_GET, $request, Request::S_ARRAY);
|
||||
return $this->client->makeRequest('/bots', Request::METHOD_GET, $request, Serializer::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit bot info
|
||||
*
|
||||
* @param Model\Request\InfoRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws CurlException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function info(Model\Request\InfoRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/my/info', Request::METHOD_PATCH, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +94,7 @@ class Client
|
|||
*/
|
||||
public function channels(Model\Request\ChannelsRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/channels', Request::METHOD_GET, $request, Request::S_ARRAY);
|
||||
return $this->client->makeRequest('/channels', Request::METHOD_GET, $request, Serializer::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -92,7 +111,7 @@ class Client
|
|||
*/
|
||||
public function chats(Model\Request\ChatsRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/chats', Request::METHOD_GET, $request, Request::S_ARRAY);
|
||||
return $this->client->makeRequest('/chats', Request::METHOD_GET, $request, Serializer::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,7 +128,7 @@ class Client
|
|||
*/
|
||||
public function commands(Model\Request\CommandsRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/my/commands', Request::METHOD_GET, $request, Request::S_ARRAY);
|
||||
return $this->client->makeRequest('/my/commands', Request::METHOD_GET, $request, Serializer::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,11 +166,7 @@ class Client
|
|||
*/
|
||||
public function commandDelete(string $request)
|
||||
{
|
||||
return $this->client->makeRequest(
|
||||
sprintf("/my/commands/%s", $request),
|
||||
Request::METHOD_DELETE,
|
||||
$request
|
||||
);
|
||||
return $this->client->makeRequest(sprintf("/my/commands/%s", $request), Request::METHOD_DELETE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,7 +183,7 @@ class Client
|
|||
*/
|
||||
public function customers(Model\Request\CustomersRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/customers', Request::METHOD_GET, $request, Request::S_ARRAY);
|
||||
return $this->client->makeRequest('/customers', Request::METHOD_GET, $request, Serializer::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,7 +200,45 @@ class Client
|
|||
*/
|
||||
public function dialogs(Model\Request\DialogsRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/dialogs', Request::METHOD_GET, $request, Request::S_ARRAY);
|
||||
return $this->client->makeRequest('/dialogs', Request::METHOD_GET, $request, Serializer::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign dialog to exact user
|
||||
*
|
||||
* @param Model\Request\DialogAssignRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function dialogAssign(Model\Request\DialogAssignRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest(
|
||||
sprintf("/dialogs/%d/assign", $request->getDialogId()),
|
||||
Request::METHOD_PATCH,
|
||||
$request
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close exact dialog
|
||||
*
|
||||
* @param string $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function dialogClose(string $request)
|
||||
{
|
||||
return $this->client->makeRequest(sprintf("/dialogs/%d/close", $request), Request::METHOD_DELETE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -202,7 +255,7 @@ class Client
|
|||
*/
|
||||
public function members(Model\Request\MembersRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/members', Request::METHOD_GET, $request, Request::S_ARRAY);
|
||||
return $this->client->makeRequest('/members', Request::METHOD_GET, $request, Serializer::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -219,7 +272,58 @@ class Client
|
|||
*/
|
||||
public function messages(Model\Request\MessagesRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/messages', Request::METHOD_GET, $request, Request::S_ARRAY);
|
||||
return $this->client->makeRequest('/messages', Request::METHOD_GET, $request, Serializer::S_ARRAY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message
|
||||
*
|
||||
* @param Model\Request\MessageSendRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function messageSend(Model\Request\MessageSendRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/messages', Request::METHOD_POST, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a message
|
||||
*
|
||||
* @param Model\Request\MessageEditRequest $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function messageEdit(Model\Request\MessageEditRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/messages/%d', Request::METHOD_PATCH, $request->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a message
|
||||
*
|
||||
* @param string $request
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws CurlException
|
||||
* @throws InvalidJsonException
|
||||
* @throws Exception
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function messageDelete(string $request)
|
||||
{
|
||||
return $this->client->makeRequest(sprintf("/messages/%d", $request), Request::METHOD_DELETE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -236,6 +340,6 @@ class Client
|
|||
*/
|
||||
public function users(Model\Request\UsersRequest $request)
|
||||
{
|
||||
return $this->client->makeRequest('/users', Request::METHOD_GET, $request, Request::S_ARRAY);
|
||||
return $this->client->makeRequest('/users', Request::METHOD_GET, $request, Serializer::S_ARRAY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Request Helper
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* RequestHelper class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class IntegrationHelper
|
||||
{
|
||||
/**
|
||||
* Prepare module data
|
||||
*
|
||||
* @param array $config
|
||||
* @param string $clientId
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function moduleRequest(array $config, string $clientId)
|
||||
{
|
||||
$config['host'] = str_replace("https://", '', $config['host']);
|
||||
|
||||
$moduleConfiguration = [
|
||||
'code' => $config['code'],
|
||||
'integrationCode' => $config['code'],
|
||||
'active' => true,
|
||||
'name' => $config['name'],
|
||||
'clientId' => $clientId,
|
||||
'logo' => sprintf("https://%s%s", $config['host'], $config['logo']),
|
||||
'baseUrl' => sprintf("https://%s", $config['host']),
|
||||
'accountURL' => sprintf("https://%s/settings/%s", $config['host'], $clientId),
|
||||
'actions' => ['activity' => '/actions/activity'],
|
||||
'integrations' => ['mgBot' => []]
|
||||
];
|
||||
|
||||
return $moduleConfiguration;
|
||||
}
|
||||
}
|
|
@ -35,9 +35,9 @@ class Constants
|
|||
const CHANNEL_TYPE_CONSULTANT = "consultant";
|
||||
const CHANNEL_TYPE_CUSTOM = "custom";
|
||||
|
||||
const CHAT_MEMBER_STATEACTIVE = "active";
|
||||
const CHAT_MEMBER_STATEKICKED = "kicked";
|
||||
const CHAT_MEMBER_STATELEAVED = "leaved";
|
||||
const CHAT_MEMBER_STATE_ACTIVE = "active";
|
||||
const CHAT_MEMBER_STATE_KICKED = "kicked";
|
||||
const CHAT_MEMBER_STATE_LEAVED = "leaved";
|
||||
|
||||
const CHANNEL_FEATURE_NONE = "none";
|
||||
const CHANNEL_FEATURE_RECEIVE = "receive";
|
||||
|
@ -82,10 +82,4 @@ class Constants
|
|||
const WS_EVENT_BOT_UPDATED = "bot_updated";
|
||||
const WS_EVENT_CHANNEL_UPDATED = "channel_updated";
|
||||
const WS_EVENT_SETTINGS_UPDATED = "settings_updated";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
82
src/Bot/Model/Entity/Cost.php
Normal file
82
src/Bot/Model/Entity/Cost.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Cost entity
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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
|
||||
*
|
||||
* Cost class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Cost
|
||||
{
|
||||
/**
|
||||
* @var float $value
|
||||
*
|
||||
* @Type("float")
|
||||
* @Accessor(getter="getValue",setter="setValue")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @var string $currency
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getCurrency",setter="setCurrency")
|
||||
*
|
||||
* @Assert\Currency
|
||||
*/
|
||||
private $currency;
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $value
|
||||
*/
|
||||
public function setValue(float $value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrency()
|
||||
{
|
||||
return $this->currency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $currency
|
||||
*/
|
||||
public function setCurrency(string $currency)
|
||||
{
|
||||
$this->currency = $currency;
|
||||
}
|
||||
}
|
133
src/Bot/Model/Entity/Delivery.php
Normal file
133
src/Bot/Model/Entity/Delivery.php
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Delivery entity
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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
|
||||
*
|
||||
* Delivery class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Delivery
|
||||
{
|
||||
/**
|
||||
* @var string $name
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Cost $price
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Cost")
|
||||
* @Accessor(getter="getPrice",setter="setPrice")
|
||||
*
|
||||
* @Assert\Currency
|
||||
*/
|
||||
private $price;
|
||||
|
||||
/**
|
||||
* @var string $address
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getAddress",setter="setAddress")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $address;
|
||||
|
||||
/**
|
||||
* @var string $comment
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getComment",setter="setComment")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $comment;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Cost
|
||||
*/
|
||||
public function getPrice()
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Cost $price
|
||||
*/
|
||||
public function setPrice(Cost $price)
|
||||
{
|
||||
$this->price = $price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAddress()
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $address
|
||||
*/
|
||||
public function setAddress(string $address)
|
||||
{
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getComment()
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $comment
|
||||
*/
|
||||
public function setComment(string $comment)
|
||||
{
|
||||
$this->comment = $comment;
|
||||
}
|
||||
}
|
81
src/Bot/Model/Entity/Item.php
Normal file
81
src/Bot/Model/Entity/Item.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Item entity
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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
|
||||
*
|
||||
* Item class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Item
|
||||
{
|
||||
/**
|
||||
* @var string $id
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getId",setter="setId")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string $caption
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getCaption",setter="setCaption")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $caption;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $id
|
||||
*/
|
||||
public function setId(string $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCaption()
|
||||
{
|
||||
return $this->caption;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $caption
|
||||
*/
|
||||
public function setCaption(string $caption)
|
||||
{
|
||||
$this->caption = $caption;
|
||||
}
|
||||
}
|
232
src/Bot/Model/Entity/Order.php
Normal file
232
src/Bot/Model/Entity/Order.php
Normal file
|
@ -0,0 +1,232 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Order entity
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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
|
||||
*
|
||||
* Order class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Order
|
||||
{
|
||||
/**
|
||||
* @var string $number
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getNumber",setter="setNumber")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $number;
|
||||
|
||||
/**
|
||||
* @var string $url
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getUrl",setter="setUrl")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @var string $date
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getDate",setter="setDate")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $date;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Cost $cost
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Cost")
|
||||
* @Accessor(getter="getCost",setter="setCost")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $cost;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Status $status
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Status")
|
||||
* @Accessor(getter="getStatus",setter="setStatus")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Delivery $delivery
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Delivery")
|
||||
* @Accessor(getter="getDelivery",setter="setDelivery")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $delivery;
|
||||
|
||||
/**
|
||||
* @var array $items
|
||||
*
|
||||
* @Type("array")
|
||||
* @Accessor(getter="getItems",setter="setItems")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $items;
|
||||
|
||||
/**
|
||||
* @var array $payments
|
||||
*
|
||||
* @Type("array")
|
||||
* @Accessor(getter="getPayments",setter="setPayments")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $payments;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNumber()
|
||||
{
|
||||
return $this->number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $number
|
||||
*/
|
||||
public function setNumber(string $number)
|
||||
{
|
||||
$this->number = $number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*/
|
||||
public function setUrl(string $url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDate()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $date
|
||||
*/
|
||||
public function setDate(string $date)
|
||||
{
|
||||
$this->date = $date;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Cost
|
||||
*/
|
||||
public function getCost()
|
||||
{
|
||||
return $this->cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Cost $cost
|
||||
*/
|
||||
public function setCost(Cost $cost)
|
||||
{
|
||||
$this->cost = $cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Status
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Status $status
|
||||
*/
|
||||
public function setStatus(Status $status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Delivery
|
||||
*/
|
||||
public function getDelivery()
|
||||
{
|
||||
return $this->delivery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Delivery $delivery
|
||||
*/
|
||||
public function setDelivery(Delivery $delivery)
|
||||
{
|
||||
$this->delivery = $delivery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $items
|
||||
*/
|
||||
public function setItems(array $items)
|
||||
{
|
||||
$this->items = $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getPayments()
|
||||
{
|
||||
return $this->payments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $payments
|
||||
*/
|
||||
public function setPayments(array $payments)
|
||||
{
|
||||
$this->payments = $payments;
|
||||
}
|
||||
}
|
156
src/Bot/Model/Entity/OrderItem.php
Normal file
156
src/Bot/Model/Entity/OrderItem.php
Normal file
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Order item entity
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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
|
||||
*
|
||||
* OrderItem class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class OrderItem
|
||||
{
|
||||
/**
|
||||
* @var string $name
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string $url
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getUrl",setter="setUrl")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @var string $img
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getImg",setter="setImg")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $img;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Cost $price
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Cost")
|
||||
* @Accessor(getter="getPrice",setter="setPrice")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $price;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Quantity $quantity
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Quantity")
|
||||
* @Accessor(getter="getQuantity",setter="setQuantity)
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $quantity;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*/
|
||||
public function setUrl(string $url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getImg()
|
||||
{
|
||||
return $this->img;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $img
|
||||
*/
|
||||
public function setImg(string $img)
|
||||
{
|
||||
$this->img = $img;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Cost
|
||||
*/
|
||||
public function getPrice()
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Cost $price
|
||||
*/
|
||||
public function setPrice(Cost $price)
|
||||
{
|
||||
$this->price = $price;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Quantity
|
||||
*/
|
||||
public function getQuantity()
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Quantity $quantity
|
||||
*/
|
||||
public function setQuantity(Quantity $quantity)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
}
|
||||
}
|
106
src/Bot/Model/Entity/Payment.php
Normal file
106
src/Bot/Model/Entity/Payment.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Payment entity
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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
|
||||
*
|
||||
* Payment class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Payment
|
||||
{
|
||||
/**
|
||||
* @var string $name
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\PaymentStatus $status
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\PaymentStatus")
|
||||
* @Accessor(getter="getStatus",setter="setStatus")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $status;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Cost $amount
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Cost")
|
||||
* @Accessor(getter="getAmount",setter="setAmount")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $amount;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\PaymentStatus
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\PaymentStatus $status
|
||||
*/
|
||||
public function setStatus(PaymentStatus $status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Cost
|
||||
*/
|
||||
public function getAmount()
|
||||
{
|
||||
return $this->amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Cost $amount
|
||||
*/
|
||||
public function setAmount(Cost $amount)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
}
|
||||
}
|
81
src/Bot/Model/Entity/PaymentStatus.php
Normal file
81
src/Bot/Model/Entity/PaymentStatus.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Payment status entity
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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
|
||||
*
|
||||
* PaymentStatus class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class PaymentStatus
|
||||
{
|
||||
/**
|
||||
* @var string $name
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var bool $payed
|
||||
*
|
||||
* @Type("bool")
|
||||
* @Accessor(getter="getPayed",setter="setPayed")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $payed;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPayed()
|
||||
{
|
||||
return $this->payed;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $payed
|
||||
*/
|
||||
public function setPayed(bool $payed)
|
||||
{
|
||||
$this->payed = $payed;
|
||||
}
|
||||
}
|
208
src/Bot/Model/Entity/Product.php
Normal file
208
src/Bot/Model/Entity/Product.php
Normal file
|
@ -0,0 +1,208 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Product entity
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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
|
||||
*
|
||||
* Product class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Product
|
||||
{
|
||||
/**
|
||||
* @var int $id
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getId",setter="setId")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string $name
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string $article
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getArticle",setter="setArticle")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $article;
|
||||
|
||||
/**
|
||||
* @var string $url
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getUrl",setter="setUrl")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $url;
|
||||
|
||||
/**
|
||||
* @var string $img
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getImg",setter="setImg")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $img;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Cost $cost
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Cost")
|
||||
* @Accessor(getter="getCost",setter="setCost")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $cost;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Quantity $quantity
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Quantity")
|
||||
* @Accessor(getter="getQuantity",setter="setQuantity)
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $quantity;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public function setId(int $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getArticle()
|
||||
{
|
||||
return $this->article;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $article
|
||||
*/
|
||||
public function setArticle(string $article)
|
||||
{
|
||||
$this->article = $article;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
*/
|
||||
public function setUrl(string $url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getImg()
|
||||
{
|
||||
return $this->img;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $img
|
||||
*/
|
||||
public function setImg(string $img)
|
||||
{
|
||||
$this->img = $img;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Cost
|
||||
*/
|
||||
public function getCost()
|
||||
{
|
||||
return $this->cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Cost $cost
|
||||
*/
|
||||
public function setCost(Cost $cost)
|
||||
{
|
||||
$this->cost = $cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Quantity
|
||||
*/
|
||||
public function getQuantity()
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Quantity $quantity
|
||||
*/
|
||||
public function setQuantity(Quantity $quantity)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
}
|
||||
}
|
82
src/Bot/Model/Entity/Quantity.php
Normal file
82
src/Bot/Model/Entity/Quantity.php
Normal file
|
@ -0,0 +1,82 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Quantity entity
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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
|
||||
*
|
||||
* Quantity class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Quantity
|
||||
{
|
||||
/**
|
||||
* @var float $value
|
||||
*
|
||||
* @Type("float")
|
||||
* @Accessor(getter="getValue",setter="setValue")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @var string $unit
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getUnit",setter="setUnit")
|
||||
*
|
||||
* @Assert\Currency
|
||||
*/
|
||||
private $unit;
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getValue()
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $value
|
||||
*/
|
||||
public function setValue(float $value)
|
||||
{
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUnit()
|
||||
{
|
||||
return $this->unit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $unit
|
||||
*/
|
||||
public function setUnit(string $unit)
|
||||
{
|
||||
$this->unit = $unit;
|
||||
}
|
||||
}
|
81
src/Bot/Model/Entity/Status.php
Normal file
81
src/Bot/Model/Entity/Status.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Status entity
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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
|
||||
*
|
||||
* Status class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Entity
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Status
|
||||
{
|
||||
/**
|
||||
* @var string $code
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getCode",setter="setCode")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @var string $name
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*/
|
||||
public function setCode(string $code)
|
||||
{
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Channels Request
|
||||
* Channels list request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Chats Request
|
||||
* Chats list request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
@ -34,14 +34,14 @@ class ChatsRequest
|
|||
/**
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getChannelId",setter="setChannelId")
|
||||
* @SkipWhenEmpty
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $channelId;
|
||||
|
||||
/**
|
||||
/**
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getChannelType",setter="setChannelType")
|
||||
* @SkipWhenEmpty
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $channelType;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Commands Request
|
||||
* Edit Command Request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
@ -17,12 +17,11 @@ use JMS\Serializer\Annotation\Accessor;
|
|||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Mapping\ClassMetadata;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CommandsRequest class
|
||||
* CommandEditRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
@ -31,13 +30,23 @@ use Symfony\Component\Validator\Mapping\ClassMetadata;
|
|||
*/
|
||||
class CommandEditRequest
|
||||
{
|
||||
/**
|
||||
* @var string $name
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
* @SkipWhenEmpty
|
||||
* @Assert\NotBlank
|
||||
/**
|
||||
* @var int $botId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getBotId",setter="setBotId")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $botId;
|
||||
|
||||
/**
|
||||
* @var string $name
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $name;
|
||||
|
||||
|
@ -81,4 +90,20 @@ class CommandEditRequest
|
|||
{
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBotId()
|
||||
{
|
||||
return $this->botId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $botId
|
||||
*/
|
||||
public function setBotId(int $botId)
|
||||
{
|
||||
$this->botId = $botId;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Commands Request
|
||||
* Commands list request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Common Fields
|
||||
* Common fields
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Customers Request
|
||||
* Customers list request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
|
106
src/Bot/Model/Request/DialogAssignRequest.php
Normal file
106
src/Bot/Model/Request/DialogAssignRequest.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Dialog assign request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* DialogAssignRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class DialogAssignRequest
|
||||
{
|
||||
/**
|
||||
* @var int $dialogId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getDialogId,setter="setDialogId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $dialogId;
|
||||
|
||||
/**
|
||||
* @var int $userId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getUserId",setter="setUserId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @var int $botId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getBotId",setter="setBotId")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $botId;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDialogId()
|
||||
{
|
||||
return $this->dialogId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $dialogId
|
||||
*/
|
||||
public function setDialogId(int $dialogId)
|
||||
{
|
||||
$this->dialogId = $dialogId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getUserId()
|
||||
{
|
||||
return $this->userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
*/
|
||||
public function setUserId(int $userId)
|
||||
{
|
||||
$this->userId = $userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBotId()
|
||||
{
|
||||
return $this->botId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $botId
|
||||
*/
|
||||
public function setBotId(int $botId)
|
||||
{
|
||||
$this->botId = $botId;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Commands Request
|
||||
* Dialogs list request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
@ -20,7 +20,7 @@ use JMS\Serializer\Annotation\Type;
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CommandsRequest class
|
||||
* DialogsRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
|
106
src/Bot/Model/Request/InfoRequest.php
Normal file
106
src/Bot/Model/Request/InfoRequest.php
Normal file
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Bot info request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* InfoRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class InfoRequest
|
||||
{
|
||||
/**
|
||||
* @var string $name
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAvatarUrl()
|
||||
{
|
||||
return $this->avatarUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $avatarUrl
|
||||
*/
|
||||
public function setAvatarUrl(string $avatarUrl)
|
||||
{
|
||||
$this->avatarUrl = $avatarUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getRoles()
|
||||
{
|
||||
return $this->roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $roles
|
||||
*/
|
||||
public function setRoles(array $roles)
|
||||
{
|
||||
$this->roles = $roles;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Commands Request
|
||||
* Members list request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
@ -20,7 +20,7 @@ use JMS\Serializer\Annotation\Type;
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CommandsRequest class
|
||||
* MembersRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
|
81
src/Bot/Model/Request/MessageEditRequest.php
Normal file
81
src/Bot/Model/Request/MessageEditRequest.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Messages edit request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* MessageEditRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class MessageEditRequest
|
||||
{
|
||||
/**
|
||||
* @var int $id
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getId",setter="setId")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var string $content
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getContent",setter="setContent")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
public function setId(int $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
*/
|
||||
public function setContent(string $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
}
|
235
src/Bot/Model/Request/MessageSendRequest.php
Normal file
235
src/Bot/Model/Request/MessageSendRequest.php
Normal file
|
@ -0,0 +1,235 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Messages send request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
use RetailCrm\Mg\Bot\Model\Entity\Order;
|
||||
use RetailCrm\Mg\Bot\Model\Entity\Product;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* MessageSendRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class MessageSendRequest
|
||||
{
|
||||
/**
|
||||
* @var string $type
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getType",setter="setType")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @var string $content
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getContent",setter="setContent")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $content;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Product $product
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Product")
|
||||
* @Accessor(getter="getProduct",setter="setProduct")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $product;
|
||||
|
||||
/**
|
||||
* @var \RetailCrm\Mg\Bot\Model\Entity\Order $order
|
||||
*
|
||||
* @Type("\RetailCrm\Mg\Bot\Model\Entity\Order")
|
||||
* @Accessor(getter="getOrder",setter="setOrder")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* @var array $items
|
||||
*
|
||||
* @Type("array")
|
||||
* @Accessor(getter="getItems",setter="setItems")
|
||||
* @SkipWhenEmpty()
|
||||
*/
|
||||
private $items;
|
||||
|
||||
/**
|
||||
* @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 int $quoteMessageId
|
||||
*
|
||||
* @Type("int")
|
||||
* @Accessor(getter="getQuoteMessageId",setter="setQuoteMessageId")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $quoteMessageId;
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getChatId()
|
||||
{
|
||||
return $this->chatId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $chatId
|
||||
*/
|
||||
public function setChatId(int $chatId)
|
||||
{
|
||||
$this->chatId = $chatId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getScope()
|
||||
{
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $scope
|
||||
*/
|
||||
public function setScope(string $scope)
|
||||
{
|
||||
$this->scope = $scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
*/
|
||||
public function setType(string $type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
*/
|
||||
public function setContent(string $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Product
|
||||
*/
|
||||
public function getProduct()
|
||||
{
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Product $product
|
||||
*/
|
||||
public function setProduct(Product $product)
|
||||
{
|
||||
$this->product = $product;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \RetailCrm\Mg\Bot\Model\Entity\Order
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \RetailCrm\Mg\Bot\Model\Entity\Order $order
|
||||
*/
|
||||
public function setOrder(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getItems()
|
||||
{
|
||||
return $this->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $items
|
||||
*/
|
||||
public function setItems(array $items)
|
||||
{
|
||||
$this->items = $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getQuoteMessageId()
|
||||
{
|
||||
return $this->quoteMessageId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $quoteMessageId
|
||||
*/
|
||||
public function setQuoteMessageId(int $quoteMessageId)
|
||||
{
|
||||
$this->quoteMessageId = $quoteMessageId;
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Customers Request
|
||||
* Messages list request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
@ -20,7 +20,7 @@ use JMS\Serializer\Annotation\Type;
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CustomersRequest class
|
||||
* MessagesRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Customers Request
|
||||
* Users list request
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
@ -20,7 +20,7 @@ use JMS\Serializer\Annotation\Type;
|
|||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* CustomersRequest class
|
||||
* UsersRequest class
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Model\Request
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
|
||||
namespace RetailCrm\Mg\Bot;
|
||||
|
||||
use JMS\Serializer\SerializerBuilder;
|
||||
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;
|
||||
|
||||
/**
|
||||
|
@ -35,24 +36,24 @@ class Request
|
|||
const METHOD_GET = 'GET';
|
||||
const METHOD_POST = 'POST';
|
||||
const METHOD_PUT = 'PUT';
|
||||
const METHOD_PATCH = 'PATCH';
|
||||
const METHOD_DELETE = 'DELETE';
|
||||
|
||||
const S_ARRAY = 0;
|
||||
const S_JSON = 1;
|
||||
|
||||
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 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)
|
||||
public function __construct($url, $token, $debug, $stdout = STDOUT)
|
||||
{
|
||||
if (false === stripos($url, 'https://')) {
|
||||
throw new InvalidArgumentException('API schema requires HTTPS protocol');
|
||||
|
@ -61,7 +62,14 @@ class Request
|
|||
$this->url = $url;
|
||||
$this->token = $token;
|
||||
$this->debug = $debug;
|
||||
$this->allowedMethods = [self::METHOD_GET, self::METHOD_POST, self::METHOD_PUT, self::METHOD_DELETE];
|
||||
$this->stdout = $stdout;
|
||||
$this->allowedMethods = [
|
||||
self::METHOD_GET,
|
||||
self::METHOD_POST,
|
||||
self::METHOD_PUT,
|
||||
self::METHOD_PATCH,
|
||||
self::METHOD_DELETE
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,13 +83,21 @@ class Request
|
|||
* @return Response
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function makeRequest($path, $method, $request = null, $serializeTo = self::S_JSON)
|
||||
public function makeRequest($path, $method, $request = null, $serializeTo = Serializer::S_JSON)
|
||||
{
|
||||
$this->validateMethod($method);
|
||||
$this->validateRequest($request);
|
||||
|
||||
$parameters = $this->serialize($request, $serializeTo);
|
||||
$url = $this->buildUrl($path, $method, $parameters);
|
||||
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);
|
||||
|
@ -92,14 +108,15 @@ class Request
|
|||
curl_setopt($curlHandler, CURLOPT_SSL_VERIFYHOST, false);
|
||||
curl_setopt($curlHandler, CURLOPT_TIMEOUT, 60);
|
||||
curl_setopt($curlHandler, CURLOPT_CONNECTTIMEOUT, 60);
|
||||
curl_setopt($curlHandler, CURLOPT_VERBOSE, (int)$this->debug);
|
||||
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_DELETE])) {
|
||||
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);
|
||||
}
|
||||
|
@ -135,22 +152,6 @@ class Request
|
|||
return new Response($statusCode, $responseBody);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check trailing slash into url
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function normalizeUrl($url)
|
||||
{
|
||||
if ('/' !== $url[strlen($url) - 1]) {
|
||||
$url .= '/';
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate HTTP method
|
||||
*
|
||||
|
@ -189,50 +190,4 @@ class Request
|
|||
throw new InvalidArgumentException($message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize given object to JSON or Array
|
||||
*
|
||||
* @param object $request
|
||||
* @param int $serialize
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
private function serialize($request, $serialize)
|
||||
{
|
||||
$serialized = null;
|
||||
|
||||
switch ($serialize) {
|
||||
case self::S_ARRAY:
|
||||
$serializer = SerializerBuilder::create()->build();
|
||||
$serialized = $serializer->toArray($request);
|
||||
break;
|
||||
case self::S_JSON:
|
||||
$serializer = SerializerBuilder::create()->build();
|
||||
$serialized = $serializer->serialize($request, 'json');
|
||||
}
|
||||
|
||||
return $serialized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build request url
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $method
|
||||
* @param array $parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function buildUrl($path, $method, $parameters)
|
||||
{
|
||||
$url = $this->url . $path;
|
||||
|
||||
if (self::METHOD_GET === $method && count($parameters)) {
|
||||
$queryString = http_build_query($parameters, '', '&');
|
||||
$url = sprintf("%s?%s", $url, $queryString);
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
|
346
src/Register.php
Normal file
346
src/Register.php
Normal file
|
@ -0,0 +1,346 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Register Helper
|
||||
*
|
||||
* @package RetailCrm\Common
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Common;
|
||||
|
||||
use JMS\Serializer\Annotation\Accessor;
|
||||
use JMS\Serializer\Annotation\SkipWhenEmpty;
|
||||
use JMS\Serializer\Annotation\Type;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* RequestHelper class
|
||||
*
|
||||
* @package RetailCrm\Common
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Register
|
||||
{
|
||||
/**
|
||||
* @var string $code
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getCode",setter="setCode")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @var string $integrationCode
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getIntegrationCode",setter="setIntegrationCode")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $integrationCode;
|
||||
|
||||
/**
|
||||
* @var string $active
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getActive",setter="setActive")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $active;
|
||||
|
||||
/**
|
||||
* @var string $name
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getName",setter="setName")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string $logo
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getLogo",setter="setLogo")
|
||||
* @SkipWhenEmpty
|
||||
*
|
||||
* @Assert\Url(
|
||||
* message = "The logo url is not a valid url",
|
||||
* protocols = {"http", "https"}
|
||||
* )
|
||||
*/
|
||||
private $logo;
|
||||
|
||||
/**
|
||||
* @var string $clientId
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getClientId",setter="setClientId")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $clientId;
|
||||
|
||||
/**
|
||||
* @var string $baseUrl
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getBaseUrl",setter="setBaseUrl")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
* @Assert\Url(
|
||||
* message = "The baseUrl is not a valid url",
|
||||
* protocols = {"http", "https"}
|
||||
* )
|
||||
*/
|
||||
private $baseUrl;
|
||||
|
||||
/**
|
||||
* @var string $accountUrl
|
||||
*
|
||||
* @Type("string")
|
||||
* @Accessor(getter="getAccountUrl",setter="setAccountUrl")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
* @Assert\Url(
|
||||
* message = "The baseUrl is not a valid url",
|
||||
* protocols = {"http", "https"}
|
||||
* )
|
||||
*/
|
||||
private $accountUrl;
|
||||
|
||||
/**
|
||||
* @var array $actions
|
||||
*
|
||||
* @Type("array")
|
||||
* @Accessor(getter="getActions",setter="setActions")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $actions;
|
||||
|
||||
/**
|
||||
* @var array $availableCountries
|
||||
*
|
||||
* @Type("array")
|
||||
* @Accessor(getter="getAvailableCountries",setter="setAvailableCountries")
|
||||
* @SkipWhenEmpty
|
||||
*/
|
||||
private $availableCountries;
|
||||
|
||||
/**
|
||||
* @var array $integrations
|
||||
*
|
||||
* @Type("array")
|
||||
* @Accessor(getter="getIntegrations",setter="setIntegrations")
|
||||
*
|
||||
* @Assert\NotBlank
|
||||
*/
|
||||
private $integrations;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
*/
|
||||
public function setCode(string $code)
|
||||
{
|
||||
$this->code = $code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getIntegrationCode()
|
||||
{
|
||||
return $this->integrationCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $integrationCode
|
||||
*/
|
||||
public function setIntegrationCode(string $integrationCode)
|
||||
{
|
||||
$this->integrationCode = $integrationCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getActive()
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $active
|
||||
*/
|
||||
public function setActive(string $active)
|
||||
{
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName(string $name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLogo()
|
||||
{
|
||||
return $this->logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $logo
|
||||
*/
|
||||
public function setLogo(string $logo)
|
||||
{
|
||||
$this->logo = $logo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClientId()
|
||||
{
|
||||
return $this->clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $clientId
|
||||
*/
|
||||
public function setClientId(string $clientId)
|
||||
{
|
||||
$this->clientId = $clientId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getBaseUrl()
|
||||
{
|
||||
return $this->baseUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $baseUrl
|
||||
*/
|
||||
public function setBaseUrl(string $baseUrl)
|
||||
{
|
||||
$this->baseUrl = $baseUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getAccountUrl()
|
||||
{
|
||||
return $this->accountUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $accountUrl
|
||||
*/
|
||||
public function setAccountUrl(string $accountUrl)
|
||||
{
|
||||
$this->accountUrl = $accountUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getActions()
|
||||
{
|
||||
return $this->actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $actions
|
||||
*/
|
||||
public function setActions(array $actions)
|
||||
{
|
||||
$this->actions = $actions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getAvailableCountries()
|
||||
{
|
||||
return $this->availableCountries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $availableCountries
|
||||
*/
|
||||
public function setAvailableCountries(array $availableCountries)
|
||||
{
|
||||
$this->availableCountries = $availableCountries;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getIntegrations()
|
||||
{
|
||||
return $this->integrations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $integrations
|
||||
*/
|
||||
public function setIntegrations(array $integrations)
|
||||
{
|
||||
$this->integrations = $integrations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get configuration as JSON
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
public function getJsonConfiguration()
|
||||
{
|
||||
return Serializer::serialize($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get configuration as array
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
public function getArrayConfiguration()
|
||||
{
|
||||
return Serializer::serialize($this, Serializer::S_ARRAY);
|
||||
}
|
||||
}
|
58
src/Serializer.php
Normal file
58
src/Serializer.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Serializer
|
||||
*
|
||||
* @package RetailCrm\Common
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Common;
|
||||
|
||||
use JMS\Serializer\SerializerBuilder;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Serializer class
|
||||
*
|
||||
* @package RetailCrm\Common
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Serializer
|
||||
{
|
||||
const S_ARRAY = 0;
|
||||
const S_JSON = 1;
|
||||
|
||||
/**
|
||||
* Serialize given object to JSON or Array
|
||||
*
|
||||
* @param object $request
|
||||
* @param int $serialize
|
||||
*
|
||||
* @return array|string
|
||||
*/
|
||||
public static function serialize($request, $serialize = self::S_JSON)
|
||||
{
|
||||
$serialized = null;
|
||||
$serializer = SerializerBuilder::create()->build();
|
||||
|
||||
switch ($serialize) {
|
||||
case self::S_ARRAY:
|
||||
$serialized = $serializer->toArray($request);
|
||||
break;
|
||||
case self::S_JSON:
|
||||
default:
|
||||
$serialized = $serializer->serialize($request, 'json');
|
||||
break;
|
||||
}
|
||||
|
||||
return $serialized;
|
||||
}
|
||||
}
|
126
src/Url.php
Normal file
126
src/Url.php
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Url handler
|
||||
*
|
||||
* @package RetailCrm\Common
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Common;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Url class
|
||||
*
|
||||
* @package RetailCrm\Common
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class Url
|
||||
{
|
||||
const RFC_DEFAULT = 1;
|
||||
const RFC_CUSTOM = 2;
|
||||
|
||||
private $parts = [];
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return $this->build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check trailing slash into url
|
||||
*
|
||||
* @param string $url
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function normalizeUrl($url)
|
||||
{
|
||||
if ('/' !== $url[strlen($url) - 1]) {
|
||||
$url .= '/';
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build request url
|
||||
*
|
||||
* @param string $path
|
||||
* @param array $parameters
|
||||
* @param int $rfc
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function buildUrl($path, $parameters, $rfc = self::RFC_DEFAULT)
|
||||
{
|
||||
$url = $path;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
|
@ -28,22 +28,22 @@ use RetailCrm\Mg\Bot\Client;
|
|||
class TestCase extends BaseCase
|
||||
{
|
||||
/**
|
||||
* Return ApiClient object
|
||||
* Return bot api client object
|
||||
*
|
||||
* @param string $url (default: null)
|
||||
* @param string $key (default: null)
|
||||
* @param bool $debug (default: false)
|
||||
*
|
||||
* @return Client
|
||||
* @return \RetailCrm\Mg\Bot\Client
|
||||
*/
|
||||
public static function getApiClient(
|
||||
$url = null,
|
||||
$key = null,
|
||||
$debug = false
|
||||
) {
|
||||
$configUrl = getenv('MG_BOT_URL') ?: $_SERVER['MG_BOT_URL'];
|
||||
$configKey = getenv('MG_BOT_KEY') ?: $_SERVER['MG_BOT_KEY'];
|
||||
$configDbg = getenv('MG_BOT_DBG') ?: $_SERVER['MG_BOT_DBG'];
|
||||
$configUrl = getenv('MG_BOT_URL');
|
||||
$configKey = getenv('MG_BOT_KEY');
|
||||
$configDbg = getenv('MG_BOT_DBG');
|
||||
|
||||
return new Client(
|
||||
$url ?: $configUrl,
|
||||
|
|
178
tests/Bot/Tests/ClientListTest.php
Normal file
178
tests/Bot/Tests/ClientListTest.php
Normal file
|
@ -0,0 +1,178 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Client Test
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Tests
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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\Constants;
|
||||
use RetailCrm\Mg\Bot\Model\Request;
|
||||
use RetailCrm\Mg\Bot\Test\TestCase;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class ClientListTest
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Tests
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class ClientListTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testChannels()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new Request\ChannelsRequest();
|
||||
$request->setActive(true);
|
||||
$request->setTypes([Constants::CHANNEL_TYPE_FACEBOOK, Constants::CHANNEL_TYPE_INSTAGRAM]);
|
||||
|
||||
$response = $client->channels($request);
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testChats()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new Request\ChatsRequest();
|
||||
$request->setChannelType(Constants::CHANNEL_TYPE_FACEBOOK);
|
||||
|
||||
$response = $client->chats($request);
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testMembers()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new Request\MembersRequest();
|
||||
|
||||
$response = $client->members($request);
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testMessages()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new Request\MessagesRequest();
|
||||
$request->setChannelType(Constants::CHANNEL_TYPE_INSTAGRAM);
|
||||
$request->setType(Constants::MESSAGE_TYPE_TEXT);
|
||||
|
||||
$response = $client->messages($request);
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testCommands()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new Request\CommandsRequest();
|
||||
|
||||
$response = $client->commands($request);
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testBots()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new Request\BotsRequest();
|
||||
$request->setActive(1);
|
||||
$request->setRoles([Constants::BOT_ROLE_RESPONSIBLE]);
|
||||
|
||||
$response = $client->bots($request);
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testUsers()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new Request\UsersRequest();
|
||||
$request->setActive(1);
|
||||
$request->setOnline(0);
|
||||
|
||||
$response = $client->users($request);
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testDialogs()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new Request\DialogsRequest();
|
||||
$request->setActive(1);
|
||||
$request->setAssign(1);
|
||||
|
||||
$response = $client->dialogs($request);
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testCustomers()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new Request\CustomersRequest();
|
||||
|
||||
$response = $client->customers($request);
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Client Test
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Tests
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @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\Constants;
|
||||
use RetailCrm\Mg\Bot\Model\Request\BotsRequest;
|
||||
use RetailCrm\Mg\Bot\Model\Request\ChannelsRequest;
|
||||
use RetailCrm\Mg\Bot\Model\Request\CommandEditRequest;
|
||||
use RetailCrm\Mg\Bot\Test\TestCase;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class ClientTest
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Tests
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class ClientTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @group("list")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testChannels()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
$request = new ChannelsRequest();
|
||||
$request->setActive(true);
|
||||
$request->setTypes([Constants::CHANNEL_TYPE_FACEBOOK]);
|
||||
$channels = $client->channels($request);
|
||||
|
||||
self::assertTrue($channels->isSuccessful() == true);
|
||||
}
|
||||
|
||||
public function testChats()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testMembers()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testMessages()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testCommands()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testCommandEditException()
|
||||
{
|
||||
self::expectException(InvalidArgumentException::class);
|
||||
|
||||
$client = self::getApiClient();
|
||||
$command = new CommandEditRequest();
|
||||
$command->setDescription("qwerty");
|
||||
|
||||
$client->commandEdit($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testCommandDeleteException()
|
||||
{
|
||||
self::expectException(\Exception::class);
|
||||
|
||||
$client = self::getApiClient();
|
||||
$command = "qwerty";
|
||||
|
||||
$client->commandDelete($command);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testBots()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
$request = new BotsRequest();
|
||||
$request->setActive(1);
|
||||
$request->setRoles([Constants::BOT_ROLE_RESPONSIBLE]);
|
||||
$bots = $client->bots($request);
|
||||
|
||||
self::assertTrue($bots->isSuccessful() == true);
|
||||
}
|
||||
|
||||
public function testUsers()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testDialogs()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
|
||||
public function testCustomers()
|
||||
{
|
||||
self::assertTrue(1 == 1);
|
||||
}
|
||||
}
|
95
tests/Bot/Tests/CommandsTest.php
Normal file
95
tests/Bot/Tests/CommandsTest.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Client Test
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Tests
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
|
||||
namespace RetailCrm\Mg\Bot\Tests;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use RetailCrm\Mg\Bot\Model\Request\CommandEditRequest;
|
||||
use RetailCrm\Mg\Bot\Test\TestCase;
|
||||
|
||||
/**
|
||||
* PHP version 7.0
|
||||
*
|
||||
* Class ClientTest
|
||||
*
|
||||
* @package RetailCrm\Mg\Bot\Tests
|
||||
* @author retailCRM <integration@retailcrm.ru>
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link http://help.retailcrm.pro/docs/Developers
|
||||
*/
|
||||
class CommandsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @group("commands")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testCommandEditException()
|
||||
{
|
||||
self::expectException(InvalidArgumentException::class);
|
||||
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new CommandEditRequest();
|
||||
$request->setDescription("qwerty");
|
||||
|
||||
$client->commandEdit($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("commands")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testCommandDeleteException()
|
||||
{
|
||||
self::expectException(Exception::class);
|
||||
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = "qwerty";
|
||||
|
||||
$client->commandDelete($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("commands")
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testCommandEdit()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$request = new CommandEditRequest();
|
||||
$request->setBotId(1);
|
||||
$request->setName("show_payment_types");
|
||||
$request->setDescription("Get available payment types");
|
||||
|
||||
$response = $client->commandEdit($request);
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @group("commands")
|
||||
* @depends testCommandEdit
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function testCommandDelete()
|
||||
{
|
||||
$client = self::getApiClient();
|
||||
|
||||
$response = $client->commandDelete("show_payment_types");
|
||||
|
||||
self::assertTrue($response->isSuccessful() == true);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue