1
0
Fork 0
mirror of synced 2025-04-10 04:21:01 +00:00

validator

This commit is contained in:
Alex Lushpai 2019-04-03 19:37:20 +03:00
parent e13edca8c5
commit fbbfaa5b0e
7 changed files with 659 additions and 201 deletions

View file

@ -15,7 +15,10 @@
"php": ">=7.0",
"ext-curl": "*",
"ext-json": "*",
"jms/serializer": "1.13.*"
"jms/serializer": "1.13.*",
"symfony/validator": "^4.2",
"doctrine/annotations": "^1.6",
"doctrine/cache": "^1.8"
},
"require-dev": {
"phpunit/phpunit": "6.5.*",

536
composer.lock generated
View file

@ -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": "ee133cf54adab9dae874b4b6f54bca9b",
"content-hash": "48599ce720e1f6fdb177855a1da35720",
"packages": [
{
"name": "doctrine/annotations",
@ -74,6 +74,81 @@
],
"time": "2019-03-25T19:12:02+00:00"
},
{
"name": "doctrine/cache",
"version": "v1.8.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
"reference": "d768d58baee9a4862ca783840eca1b9add7a7f57"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/cache/zipball/d768d58baee9a4862ca783840eca1b9add7a7f57",
"reference": "d768d58baee9a4862ca783840eca1b9add7a7f57",
"shasum": ""
},
"require": {
"php": "~7.1"
},
"conflict": {
"doctrine/common": ">2.2,<2.4"
},
"require-dev": {
"alcaeus/mongo-php-adapter": "^1.1",
"doctrine/coding-standard": "^4.0",
"mongodb/mongodb": "^1.1",
"phpunit/phpunit": "^7.0",
"predis/predis": "~1.0"
},
"suggest": {
"alcaeus/mongo-php-adapter": "Required to use legacy MongoDB driver"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.8.x-dev"
}
},
"autoload": {
"psr-4": {
"Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "Caching library offering an object-oriented API for many cache backends",
"homepage": "https://www.doctrine-project.org",
"keywords": [
"cache",
"caching"
],
"time": "2018-08-21T18:01:43+00:00"
},
{
"name": "doctrine/instantiator",
"version": "1.2.0",
@ -455,6 +530,280 @@
"type"
],
"time": "2015-07-25T16:39:46+00:00"
},
{
"name": "symfony/contracts",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/contracts.git",
"reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf",
"reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf",
"shasum": ""
},
"require": {
"php": "^7.1.3"
},
"require-dev": {
"psr/cache": "^1.0",
"psr/container": "^1.0"
},
"suggest": {
"psr/cache": "When using the Cache contracts",
"psr/container": "When using the Service contracts",
"symfony/cache-contracts-implementation": "",
"symfony/service-contracts-implementation": "",
"symfony/translation-contracts-implementation": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\": ""
},
"exclude-from-classmap": [
"**/Tests/"
]
},
"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": "A set of abstractions extracted out of the Symfony components",
"homepage": "https://symfony.com",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"time": "2018-12-05T08:06:11+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "82ebae02209c21113908c229e9883c419720738a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "backendtea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "fe5e94c604826c35a32fa832f35bd036b6799609"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609",
"reference": "fe5e94c604826c35a32fa832f35bd036b6799609",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"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 for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/validator",
"version": "v4.2.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/validator.git",
"reference": "db5457ed88aacc1a040d4961ee52cddad3e5a4aa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/validator/zipball/db5457ed88aacc1a040d4961ee52cddad3e5a4aa",
"reference": "db5457ed88aacc1a040d4961ee52cddad3e5a4aa",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"symfony/contracts": "^1.0.2",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",
"symfony/dependency-injection": "<3.4",
"symfony/http-kernel": "<3.4",
"symfony/intl": "<4.1",
"symfony/translation": "<4.2",
"symfony/yaml": "<3.4"
},
"require-dev": {
"doctrine/annotations": "~1.0",
"doctrine/cache": "~1.0",
"egulias/email-validator": "^1.2.8|~2.0",
"symfony/cache": "~3.4|~4.0",
"symfony/config": "~3.4|~4.0",
"symfony/dependency-injection": "~3.4|~4.0",
"symfony/expression-language": "~3.4|~4.0",
"symfony/http-foundation": "~4.1",
"symfony/http-kernel": "~3.4|~4.0",
"symfony/intl": "~4.1",
"symfony/property-access": "~3.4|~4.0",
"symfony/translation": "~4.2",
"symfony/var-dumper": "~3.4|~4.0",
"symfony/yaml": "~3.4|~4.0"
},
"suggest": {
"doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.",
"doctrine/cache": "For using the default cached annotation reader and metadata cache.",
"egulias/email-validator": "Strict (RFC compliant) email validation",
"psr/cache-implementation": "For using the metadata cache.",
"symfony/config": "",
"symfony/expression-language": "For using the Expression validator",
"symfony/http-foundation": "",
"symfony/intl": "",
"symfony/property-access": "For accessing properties within comparison constraints",
"symfony/translation": "For translating validation errors.",
"symfony/yaml": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.2-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\Validator\\": ""
},
"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 Validator Component",
"homepage": "https://symfony.com",
"time": "2019-03-30T15:58:42+00:00"
}
],
"packages-dev": [
@ -2850,74 +3199,6 @@
"homepage": "https://symfony.com",
"time": "2019-04-01T07:32:59+00:00"
},
{
"name": "symfony/contracts",
"version": "v1.0.2",
"source": {
"type": "git",
"url": "https://github.com/symfony/contracts.git",
"reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/contracts/zipball/1aa7ab2429c3d594dd70689604b5cf7421254cdf",
"reference": "1aa7ab2429c3d594dd70689604b5cf7421254cdf",
"shasum": ""
},
"require": {
"php": "^7.1.3"
},
"require-dev": {
"psr/cache": "^1.0",
"psr/container": "^1.0"
},
"suggest": {
"psr/cache": "When using the Cache contracts",
"psr/container": "When using the Service contracts",
"symfony/cache-contracts-implementation": "",
"symfony/service-contracts-implementation": "",
"symfony/translation-contracts-implementation": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Contracts\\": ""
},
"exclude-from-classmap": [
"**/Tests/"
]
},
"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": "A set of abstractions extracted out of the Symfony components",
"homepage": "https://symfony.com",
"keywords": [
"abstractions",
"contracts",
"decoupling",
"interfaces",
"interoperability",
"standards"
],
"time": "2018-12-05T08:06:11+00:00"
},
{
"name": "symfony/dependency-injection",
"version": "v4.2.5",
@ -3090,123 +3371,6 @@
"homepage": "https://symfony.com",
"time": "2019-02-23T15:42:05+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "82ebae02209c21113908c229e9883c419720738a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-ctype": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Ctype\\": ""
},
"files": [
"bootstrap.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
},
{
"name": "Gert de Pagter",
"email": "backendtea@gmail.com"
}
],
"description": "Symfony polyfill for ctype functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"ctype",
"polyfill",
"portable"
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "fe5e94c604826c35a32fa832f35bd036b6799609"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/fe5e94c604826c35a32fa832f35bd036b6799609",
"reference": "fe5e94c604826c35a32fa832f35bd036b6799609",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"suggest": {
"ext-mbstring": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.11-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Mbstring\\": ""
},
"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 for the Mbstring extension",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"mbstring",
"polyfill",
"portable",
"shim"
],
"time": "2019-02-06T07:57:58+00:00"
},
{
"name": "theseer/tokenizer",
"version": "1.1.0",

View file

@ -62,7 +62,7 @@ class Client
*/
public function bots(Model\Request\BotsRequest $request)
{
return $this->client->makeRequest('/bots', 'GET', $request, Request::S_ARRAY);
return $this->client->makeRequest('/bots', Request::METHOD_GET, $request, Request::S_ARRAY);
}
/**
@ -75,7 +75,7 @@ class Client
*/
public function channels(Model\Request\ChannelsRequest $request)
{
return $this->client->makeRequest('/channels', 'GET', $request, Request::S_ARRAY);
return $this->client->makeRequest('/channels', Request::METHOD_GET, $request, Request::S_ARRAY);
}
/**
@ -92,7 +92,7 @@ class Client
*/
public function chats(Model\Request\ChatsRequest $request)
{
return $this->client->makeRequest('/chats', 'GET', $request, Request::S_ARRAY);
return $this->client->makeRequest('/chats', Request::METHOD_GET, $request, Request::S_ARRAY);
}
/**
@ -109,7 +109,55 @@ class Client
*/
public function commands(Model\Request\CommandsRequest $request)
{
return $this->client->makeRequest('/my/commands', 'GET', $request, Request::S_ARRAY);
return $this->client->makeRequest('/my/commands', Request::METHOD_GET, $request, Request::S_ARRAY);
}
/**
* Edit commands for exact bot
*
* @param Model\Request\CommandEditRequest $request
*
* @throws InvalidArgumentException
* @throws CurlException
* @throws InvalidJsonException
* @throws Exception
*
* @return Response
*/
public function commandEdit(Model\Request\CommandEditRequest $request)
{
$validation = Component\Validator::validate($request);
if (!empty($validation)) {
throw new InvalidArgumentException($validation);
}
return $this->client->makeRequest(
sprintf("/my/commands/%s", $request->getName()),
Request::METHOD_PUT,
$request
);
}
/**
* Delete command for exact bot
*
* @param string $request
*
* @throws InvalidArgumentException
* @throws CurlException
* @throws InvalidJsonException
* @throws Exception
*
* @return Response
*/
public function commandDelete(string $request)
{
return $this->client->makeRequest(
sprintf("/my/commands/%s", $request),
Request::METHOD_DELETE,
$request
);
}
/**
@ -126,7 +174,7 @@ class Client
*/
public function customers(Model\Request\CustomersRequest $request)
{
return $this->client->makeRequest('/customers', 'GET', $request, Request::S_ARRAY);
return $this->client->makeRequest('/customers', Request::METHOD_GET, $request, Request::S_ARRAY);
}
/**
@ -143,7 +191,7 @@ class Client
*/
public function dialogs(Model\Request\DialogsRequest $request)
{
return $this->client->makeRequest('/dialogs', 'GET', $request, Request::S_ARRAY);
return $this->client->makeRequest('/dialogs', Request::METHOD_GET, $request, Request::S_ARRAY);
}
/**
@ -160,7 +208,7 @@ class Client
*/
public function members(Model\Request\MembersRequest $request)
{
return $this->client->makeRequest('/members', 'GET', $request, Request::S_ARRAY);
return $this->client->makeRequest('/members', Request::METHOD_GET, $request, Request::S_ARRAY);
}
/**
@ -177,7 +225,7 @@ class Client
*/
public function messages(Model\Request\MessagesRequest $request)
{
return $this->client->makeRequest('/messages', 'GET', $request, Request::S_ARRAY);
return $this->client->makeRequest('/messages', Request::METHOD_GET, $request, Request::S_ARRAY);
}
/**
@ -194,6 +242,6 @@ class Client
*/
public function users(Model\Request\UsersRequest $request)
{
return $this->client->makeRequest('/users', 'GET', $request, Request::S_ARRAY);
return $this->client->makeRequest('/users', Request::METHOD_GET, $request, Request::S_ARRAY);
}
}

View file

@ -0,0 +1,53 @@
<?php
/**
* PHP version 7.0
*
* Validator
*
* @package RetailCrm\Mg\Bot\Component
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Component;
use Symfony\Component\Validator\Validation;
/**
* PHP version 7.0
*
* Validator class
*
* @package RetailCrm\Mg\Bot\Component
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Validator
{
/**
* Validate given class
*
* @param $class
*
* @return string
*/
public static function validate($class)
{
$errorsString = '';
$validator = Validation::createValidatorBuilder()
->addMethodMapping('loadValidatorMetadata')
->getValidator();
$errors = $validator->validate($class);
if (count($errors) > 0) {
$errorsString = (string) $errors;
}
return $errorsString;
}
}

View file

@ -0,0 +1,91 @@
<?php
/**
* PHP version 7.0
*
* Constants
*
* @package RetailCrm\Mg\Bot\Model
* @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;
/**
* PHP version 7.0
*
* Constants class
*
* @package RetailCrm\Mg\Bot\Model
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Constants
{
const CHANNEL_TYPE_TELEGRAM = "telegram";
const CHANNEL_TYPE_FACEBOOK = "fbmessenger";
const CHANNEL_TYPE_VIBER = "viber";
const CHANNEL_TYPE_WHATSAPP = "whatsapp";
const CHANNEL_TYPE_SKYPE = "skype";
const CHANNEL_TYPE_VK = "vk";
const CHANNEL_TYPE_INSTAGRAM = "instagram";
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 CHANNEL_FEATURE_NONE = "none";
const CHANNEL_FEATURE_RECEIVE = "receive";
const CHANNEL_FEATURE_SEND = "send";
const CHANNEL_FEATURE_BOTH = "both";
const BOT_ROLE_DISTRIBUTOR = "distributor";
const BOT_ROLE_RESPONSIBLE = "responsible";
const MESSAGE_SCOPE_PUBLIC = "public";
const MESSAGE_SCOPE_PRIVATE = "private";
const MESSAGE_TYPE_TEXT = "text";
const MESSAGE_TYPE_SYSTEM = "system";
const MESSAGE_TYPE_COMMAND = "command";
const MESSAGE_TYPE_ORDER = "order";
const MESSAGE_TYPE_PRODUCT = "product";
const MESSAGE_TYPE_FILE = "file";
const MESSAGE_TYPE_IMAGE = "image";
const MESSAGE_ORDER_STATUS_CODE_NEW = "new";
const MESSAGE_ORDER_STATUS_CODE_APPROVAL = "approval";
const MESSAGE_ORDER_STATUS_CODE_ASSEMBLING = "assembling";
const MESSAGE_ORDER_STATUS_CODE_DELIVERY = "delivery";
const MESSAGE_ORDER_STATUS_CODE_COMPLETE = "complete";
const MESSAGE_ORDER_STATUS_CODE_CANCEL = "cancel";
const WS_EVENT_MESSAGE_NEW = "message_new";
const WS_EVENT_MESSAGE_UPDATED = "message_updated";
const WS_EVENT_MESSAGE_DELETED = "message_deleted";
const WS_EVENT_DIALOG_OPENED = "dialog_opened";
const WS_EVENT_DIALOG_CLOSED = "dialog_closed";
const WS_EVENT_DIALOG_ASSIGN = "dialog_assign";
const WS_EVENT_CHAT_CREATED = "chat_created";
const WS_EVENT_CHAT_UPDATED = "chat_updated";
const WS_EVENT_CHAT_UNREAD_UPDATED = "chat_unread_updated";
const WS_EVENT_USER_ONLINE_UPDATED = "user_online_updated";
const WS_EVENT_USER_JOINED = "user_joined_chat";
const WS_EVENT_USER_LEAVE = "user_left_chat";
const WS_EVENT_USER_UPDATED = "user_updated";
const WS_EVENT_CUSTOMER_UPDATED = "customer_updated";
const WS_EVENT_BOT_UPDATED = "bot_updated";
const WS_EVENT_CHANNEL_UPDATED = "channel_updated";
const WS_EVENT_SETTINGS_UPDATED = "settings_updated";
}

View file

@ -0,0 +1,91 @@
<?php
/**
* PHP version 7.0
*
* Commands 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 Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
/**
* PHP version 7.0
*
* CommandsRequest 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 CommandEditRequest
{
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
* @SkipWhenEmpty
*/
private $name;
/**
* @var string $description
*
* @Type("string")
* @Accessor(getter="getDescription",setter="setDescription")
* @SkipWhenEmpty
*/
private $description;
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name)
{
$this->name = $name;
}
/**
* @return string
*/
public function getDescription(): string
{
return $this->description;
}
/**
* @param string $description
*/
public function setDescription(string $description)
{
$this->description = $description;
}
/**
* @param \Symfony\Component\Validator\Mapping\ClassMetadata $metadata
*/
public static function loadValidatorMetadata(ClassMetadata $metadata)
{
$metadata->addPropertyConstraint('name', new Assert\NotBlank());
}
}

View file

@ -13,7 +13,9 @@
namespace RetailCrm\Mg\Bot\Tests;
use InvalidArgumentException;
use RetailCrm\Mg\Bot\Client;
use RetailCrm\Mg\Bot\Model\Request\CommandEditRequest;
use RetailCrm\Mg\Bot\Test\TestCase;
/**
@ -57,6 +59,17 @@ class ClientTest extends TestCase
self::assertTrue(1 == 1);
}
public function testCommandEditException()
{
self::expectException(InvalidArgumentException::class);
$client = self::getApiClient();
$command = new CommandEditRequest();
$command->setDescription("qwerty");
$client->commandEdit($command);
}
public function testBots()
{
self::assertTrue(1 == 1);
@ -72,11 +85,6 @@ class ClientTest extends TestCase
self::assertTrue(1 == 1);
}
public function test__construct()
{
self::assertTrue(1 == 1);
}
public function testCustomers()
{
self::assertTrue(1 == 1);