1
0
mirror of synced 2024-11-23 12:16:02 +03:00

Update models & serialization (#3)

This commit is contained in:
Alex Lushpai 2019-07-16 15:04:54 +03:00 committed by GitHub
parent 8001ab64e2
commit 318b2e74cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
86 changed files with 2634 additions and 1943 deletions

View File

@ -1,3 +1,3 @@
MG_BOT_URL="https://mg-test.retailcrm.pro/" MG_BOT_URL="https://mg-s1.retailcrm.pro/"
MG_BOT_KEY="" MG_BOT_KEY=""
MG_BOT_DBG="" MG_BOT_DBG=""

2
.gitignore vendored
View File

@ -196,4 +196,4 @@ build/*
test-report.xml test-report.xml
# GraphViz Dot # GraphViz Dot
dot/* dot/*

View File

@ -5,7 +5,6 @@ cache:
- $HOME/.composer/cache - $HOME/.composer/cache
php: php:
- '7.0'
- '7.1' - '7.1'
- '7.2' - '7.2'
- '7.3' - '7.3'
@ -14,4 +13,7 @@ before_script:
- flags="-o" - flags="-o"
- composer install $flags - composer install $flags
script: make travis script: make travis
after_success:
- bash <(curl -s https://codecov.io/bash)

View File

@ -1,6 +1,6 @@
ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) ROOT_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
SRC_DIR=$(ROOT_DIR)/src SRC_DIR=$(ROOT_DIR)/src
BIN_DIR=$(ROOT_DIR)/bin BIN_DIR=$(ROOT_DIR)/vendor/bin
test: test:
@echo "==> Running tests" @echo "==> Running tests"
@ -11,7 +11,7 @@ test:
stan: stan:
@echo "==> Running analysis" @echo "==> Running analysis"
@php $(BIN_DIR)/phpstan analyse -a $(ROOT_DIR)/extra/autoloader.php -l 4 src @php $(BIN_DIR)/phpstan analyse
@echo "==> Analysis complete" @echo "==> Analysis complete"
travis: test stan travis: test stan

View File

@ -1,6 +1,7 @@
[![Build Status](https://img.shields.io/travis/retailcrm/mg-bot-api-client-php/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/mg-bot-api-client-php) [![Build Status](https://img.shields.io/travis/retailcrm/mg-bot-api-client-php/master.svg?style=flat-square)](https://travis-ci.org/retailcrm/mg-bot-api-client-php)
[![Covarage](https://img.shields.io/codecov/c/gh/retailcrm/mg-bot-api-client-php/master.svg?style=flat-square)](https://codecov.io/gh/retailcrm/mg-bot-api-client-php)
[![Latest stable](https://img.shields.io/packagist/v/retailcrm/mg-bot-api-client-php.svg?style=flat-square)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php) [![Latest stable](https://img.shields.io/packagist/v/retailcrm/mg-bot-api-client-php.svg?style=flat-square)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php)
[![PHP from Packagist](https://img.shields.io/packagist/php-v/mg-bot-retailcrm/api-client-php.svg?style=flat-square)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php) [![PHP from Packagist](https://img.shields.io/packagist/php-v/retailcrm/mg-bot-api-client-php.svg?style=flat-square)](https://packagist.org/packages/retailcrm/mg-bot-api-client-php)
# retailCRM API PHP client # retailCRM API PHP client
@ -9,7 +10,7 @@ This is php retailCRM MG Bot API client.
## Requirements ## Requirements
* PHP 7.0 and above * PHP 7.1 and above
* PHP's cURL support * PHP's cURL support
* PHP's JSON support * PHP's JSON support

View File

@ -12,40 +12,21 @@
} }
], ],
"require": { "require": {
"php": ">=7.0", "php": ">=7.1",
"ext-curl": "*", "ext-curl": "*",
"ext-json": "*", "ext-json": "*",
"jms/serializer": "1.14.*", "jms/serializer": "1.14.*",
"symfony/validator": "3.*", "symfony/validator": "4.3.*",
"doctrine/annotations": "1.4.*", "doctrine/annotations": "1.6.*",
"doctrine/cache": "1.6.*", "doctrine/cache": "1.6.*",
"guzzlehttp/guzzle": "6.*", "guzzlehttp/guzzle": "6.*"
"doctrine/instantiator": "1.0.*",
"symfony/translation": "3.*",
"symfony/dependency-injection": "3.*",
"symfony/config": "3.*",
"symfony/finder": "3.4.*",
"symfony/filesystem": "3.*"
}, },
"require-dev": { "require-dev": {
"phpmd/phpmd": "2.*", "phpmd/phpmd": "2.*",
"squizlabs/php_codesniffer": "3.4.*", "squizlabs/php_codesniffer": "3.4.*",
"symfony/dotenv": "3.*", "symfony/dotenv": "4.3.*",
"friendsofphp/php-cs-fixer": "2.*", "phpunit/phpunit": "7.*",
"phpunit/phpunit": "6.*", "phpstan/phpstan": "0.11.*"
"nette/bootstrap": "2.*",
"nette/neon": "2.*",
"nette/php-generator": "3.0.*",
"phpstan/phpstan": "0.9.*",
"ocramius/package-versions": "1.2.*",
"nette/finder": "2.4.*",
"symfony/console": "3.*",
"symfony/debug": "3.*",
"symfony/event-dispatcher": "3.*",
"symfony/options-resolver": "3.4.*",
"symfony/process": "3.4.*",
"symfony/stopwatch": "3.4.*",
"myclabs/deep-copy": "1.6.*"
}, },
"support": { "support": {
"email": "support@retailcrm.ru" "email": "support@retailcrm.ru"
@ -63,7 +44,7 @@
} }
}, },
"config": { "config": {
"bin-dir": "bin", "bin-dir": "vendor/bin",
"process-timeout": 600 "process-timeout": 600
} }
} }

1758
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@ use Composer\Autoload\ClassLoader;
$autoloadFile = file_exists(__DIR__ . '/../vendor/autoload.php') $autoloadFile = file_exists(__DIR__ . '/../vendor/autoload.php')
? __DIR__ . '/../vendor/autoload.php' ? __DIR__ . '/../vendor/autoload.php'
: __DIR__ . '/../../../autoload.php'; : __DIR__ . '/../../../autoload.php';
$loader = require $autoloadFile; $loader = require $autoloadFile;
AnnotationRegistry::registerLoader('class_exists'); AnnotationRegistry::registerLoader('class_exists');

View File

@ -1,6 +1,6 @@
parameters: parameters:
autoload_files: autoload_files:
- %currentWorkingDirectory%/vendor/autoload.php - %currentWorkingDirectory%/vendor/autoload.php
level: 4 level: 7
paths: paths:
- %currentWorkingDirectory%/src - %currentWorkingDirectory%/src

View File

@ -1,22 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="phpunit.xsd"
bootstrap="./tests/bootstrap.php"
colors="true"
verbose="true"
processIsolation="false"
stopOnFailure="false">
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.5/phpunit.xsd"
backupGlobals="false"
colors="false"
bootstrap="tests/bootstrap.php"
backupStaticAttributes="false"
convertErrorsToExceptions="false"
convertNoticesToExceptions="false"
convertWarningsToExceptions="false"
processIsolation="true"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
stopOnRisky="false"
>
<testsuites> <testsuites>
<testsuite name="RetailCrm"> <testsuite name="Project Test Suite">
<directory>tests/Bot/Tests</directory> <directory>tests</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<filter> <filter>
<whitelist> <whitelist>
<directory suffix=".php">./src/Bot</directory> <directory>src</directory>
</whitelist> </whitelist>
</filter> </filter>
<logging>
<log type="coverage-clover" target="clover.xml"/>
<log type="junit" target="/tmp/logfile.xml"/>
</logging>
</phpunit> </phpunit>

View File

@ -0,0 +1,87 @@
<?php
/**
* PHP version 7.1
*
* ModelAdapter
*
* @package RetailCrm\Mg\Bot\Adapter
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Adapter;
use RetailCrm\Common\Exception\InvalidJsonException;
use RetailCrm\Common\Serializer;
use RetailCrm\Mg\Bot\Model\Response;
/**
* Class ModelAdapter
*
* @package RetailCrm\Mg\Bot\Adapter
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class ModelAdapter
{
/**
* @var mixed $model
*/
private $model;
/**
* @var string $classname
*/
private $classname;
/**
* ModelAdapter constructor.
*
* @param string $classname
*
*/
public function __construct(string $classname)
{
$this->model = new $classname;
$this->classname = $classname;
}
/**
* Get Response Model
*
* @param \RetailCrm\Mg\Bot\Model\Response $response
*
* @return \RetailCrm\Mg\Bot\Model\ModelInterface
*/
public function getResponseModel(Response $response)
{
return Serializer::deserialize($response->getBody(), $this->model);
}
/**
* Get Response List
*
* @param \RetailCrm\Mg\Bot\Model\Response $response
*
* @return array
*/
public function getResponseList(Response $response)
{
$array = json_decode($response->getBody(), true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new InvalidJsonException('Received invalid JSON', 1);
}
$result = [];
foreach ($array as $item) {
$result[] = Serializer::deserialize($item, $this->classname, Serializer::S_ARRAY);
}
return $result;
}
}

View File

@ -0,0 +1,61 @@
<?php
/**
* PHP version 7.1
*
* Response adapter
*
* @package RetailCrm\Mg\Bot\Adapter
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Adapter;
use Psr\Http\Message\ResponseInterface;
use RetailCrm\Mg\Bot\Model\Response;
/**
* Class ResponseAdapter
*
* @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 ResponseAdapter
{
/**
* @var \RetailCrm\Mg\Bot\Model\Response $model
*/
private $model;
/**
* @var \Psr\Http\Message\ResponseInterface $interface
*/
private $interface;
/**
* ResponseAdapter constructor.
*
* @param \Psr\Http\Message\ResponseInterface $interface
*/
public function __construct(ResponseInterface $interface)
{
$this->interface = $interface;
$this->model = new Response();
}
/**
* Build response
*
* @return \RetailCrm\Mg\Bot\Model\Response
*/
public function build(): Response
{
$this->model->setStatus($this->interface->getStatusCode());
$this->model->setBody((string) $this->interface->getBody());
return $this->model;
}
}

View File

@ -1,36 +1,44 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Client * Client
* *
* @package RetailCrm\Mg\Bot * @package RetailCrm\Mg\Bot
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
namespace RetailCrm\Mg\Bot; namespace RetailCrm\Mg\Bot;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use RetailCrm\Common\Exception\InvalidJsonException;
use RetailCrm\Common\Url; use RetailCrm\Common\Url;
use RetailCrm\Common\Serializer; use RetailCrm\Common\Serializer;
use RetailCrm\Mg\Bot\Adapter\ModelAdapter;
use RetailCrm\Mg\Bot\Model\Entity\Bot;
use RetailCrm\Mg\Bot\Model\Entity\Channel\Channel;
use RetailCrm\Mg\Bot\Model\Entity\Chat\Chat;
use RetailCrm\Mg\Bot\Model\Entity\Chat\ChatMember;
use RetailCrm\Mg\Bot\Model\Entity\Command;
use RetailCrm\Mg\Bot\Model\Entity\Customer;
use RetailCrm\Mg\Bot\Model\Entity\Dialog;
use RetailCrm\Mg\Bot\Model\Entity\Message\Message;
use RetailCrm\Mg\Bot\Model\Entity\User;
use RetailCrm\Mg\Bot\Model\Request\UploadFileByUrlRequest; use RetailCrm\Mg\Bot\Model\Request\UploadFileByUrlRequest;
use RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse;
use RetailCrm\Mg\Bot\Model\Response\FullFileResponse; use RetailCrm\Mg\Bot\Model\Response\FullFileResponse;
use RetailCrm\Mg\Bot\Model\Response\ListResponse; use RetailCrm\Mg\Bot\Model\Response\MessageSendResponse;
use RetailCrm\Mg\Bot\Model\Response\UploadFileResponse; use RetailCrm\Mg\Bot\Model\Response\UploadFileResponse;
/** /**
* PHP version 7.0 * Class Client
* *
* Client class * @package RetailCrm\Mg\Bot
* * @author retailCRM <integration@retailcrm.ru>
* @package RetailCrm\Mg\Bot * @license https://opensource.org/licenses/MIT MIT License
* @author retailCRM <integration@retailcrm.ru> * @link http://help.retailcrm.pro/docs/Developers
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/ */
class Client class Client
{ {
@ -39,11 +47,6 @@ class Client
*/ */
const VERSION = 'v1'; const VERSION = 'v1';
/**
* @internal
*/
const ERROR_ONLY_RESPONSE = 'ErrorOnlyResponse';
/** /**
* @var HttpClient * @var HttpClient
*/ */
@ -52,9 +55,9 @@ class Client
/** /**
* Init * Init
* *
* @param string $url MG API URL * @param string $url MG API URL
* @param string $token MG API Key * @param string $token MG API Key
* @param bool $debug Enable or disable debug mode - will log all requests to STDOUT (default: false) * @param bool $debug Enable or disable debug mode - will log all requests to STDOUT (default: false)
* @param \GuzzleHttp\HandlerStack $handler GuzzleHttp::HandlerStack instance (default: null) * @param \GuzzleHttp\HandlerStack $handler GuzzleHttp::HandlerStack instance (default: null)
*/ */
public function __construct($url, $token, $debug = false, $handler = null) public function __construct($url, $token, $debug = false, $handler = null)
@ -63,115 +66,25 @@ class Client
$this->client = new HttpClient($url, $token, $debug ? STDOUT : null, $handler); $this->client = new HttpClient($url, $token, $debug ? STDOUT : null, $handler);
} }
/**
* @param string $path
* @param string $method
* @param object|null $request Request parameters
* @param string $responseType
* @param bool $arrayOfObjects
*
* @return object|null
* @throws \Exception
*/
private function submitRequest(
$path,
$method,
$request,
$responseType,
$arrayOfObjects = false
) {
$response = $this->client->makeRequest(
$path,
$method,
$request
);
$statusCode = $response->getStatusCode();
$data = json_decode((string) $response->getBody(), true);
if (json_last_error() == JSON_ERROR_NONE) {
if ($arrayOfObjects) {
return new ListResponse($responseType, $data, $statusCode);
} else {
$obj = Serializer::deserialize($data, $responseType, Serializer::S_ARRAY);
if ($statusCode >= 400
&& method_exists($obj, 'setErrors')
&& method_exists($obj, 'getErrors')
&& count(call_user_func([$obj, 'getErrors'])) == 0
) {
call_user_func_array([$obj, 'setErrors'], [['Status Code ' . $response->getStatusCode()]]);
}
if (method_exists($obj, 'setStatusCode')) {
call_user_func_array([$obj, 'setStatusCode'], [$statusCode]);
}
return $obj;
}
} else {
throw new InvalidJsonException('Received invalid JSON', 1);
}
}
/**
* @param bool $fromRoot
* @param string ...$classes
*
* @return string
*/
private static function concatClasspath($fromRoot, ...$classes)
{
$path = '';
foreach ($classes as $class) {
if (empty($path) && !$fromRoot) {
$path .= $class;
} else {
$path .= '\\' . $class;
}
}
return $path;
}
/**
* @param string ...$classes
*
* @return string
*/
private static function getEntityClass(...$classes)
{
return static::concatClasspath(true, 'RetailCrm', 'Mg', 'Bot', 'Model', 'Entity', ...$classes);
}
/**
* @param string ...$classes
*
* @return string
*/
private static function getResponseClass(...$classes)
{
return static::concatClasspath(true, 'RetailCrm', 'Mg', 'Bot', 'Model', 'Response', ...$classes);
}
/** /**
* Returns filtered bots list * Returns filtered bots list
* *
* @param Model\Request\BotsRequest $request Request parameters * @param Model\Request\BotsRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object * @return array
* @throws \Exception * @throws \Exception
*/ */
public function bots(Model\Request\BotsRequest $request) public function bots(Model\Request\BotsRequest $request): array
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/bots', '/bots',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request
static::getEntityClass('Bot'),
true
); );
$adapter = new ModelAdapter(Bot::class);
return $adapter->getResponseList($response);
} }
/** /**
@ -179,17 +92,20 @@ class Client
* *
* @param Model\Request\InfoRequest $request Request parameters * @param Model\Request\InfoRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception * @throws \Exception
*/ */
public function info(Model\Request\InfoRequest $request) public function info(Model\Request\InfoRequest $request)
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/my/info', '/my/info',
HttpClient::METHOD_PATCH, HttpClient::METHOD_PATCH,
$request, $request
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
); );
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
} }
/** /**
@ -197,18 +113,20 @@ class Client
* *
* @param Model\Request\ChannelsRequest $request Request parameters * @param Model\Request\ChannelsRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object * @return array
* @throws \Exception * @throws \Exception
*/ */
public function channels(Model\Request\ChannelsRequest $request) public function channels(Model\Request\ChannelsRequest $request): array
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/channels', '/channels',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request
static::getEntityClass('Channel', 'Channel'),
true
); );
$adapter = new ModelAdapter(Channel::class);
return $adapter->getResponseList($response);
} }
/** /**
@ -216,18 +134,20 @@ class Client
* *
* @param Model\Request\ChatsRequest $request Request parameters * @param Model\Request\ChatsRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object * @return array
* @throws \Exception * @throws \Exception
*/ */
public function chats(Model\Request\ChatsRequest $request) public function chats(Model\Request\ChatsRequest $request): array
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/chats', '/chats',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request
static::getEntityClass('Chat', 'Chat'),
true
); );
$adapter = new ModelAdapter(Chat::class);
return $adapter->getResponseList($response);
} }
/** /**
@ -235,18 +155,20 @@ class Client
* *
* @param Model\Request\CommandsRequest $request Request parameters * @param Model\Request\CommandsRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object * @return array
* @throws \Exception * @throws \Exception
*/ */
public function commands(Model\Request\CommandsRequest $request) public function commands(Model\Request\CommandsRequest $request): array
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/my/commands', '/my/commands',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request
static::getEntityClass('Command'),
true
); );
$adapter = new ModelAdapter(Command::class);
return $adapter->getResponseList($response);
} }
/** /**
@ -254,17 +176,20 @@ class Client
* *
* @param Model\Request\CommandEditRequest $request Request parameters * @param Model\Request\CommandEditRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception * @throws \Exception
*/ */
public function commandEdit(Model\Request\CommandEditRequest $request) public function commandEdit(Model\Request\CommandEditRequest $request)
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
sprintf("/my/commands/%s", $request->getName()), sprintf("/my/commands/%s", $request->getName()),
HttpClient::METHOD_PUT, HttpClient::METHOD_PUT,
$request, $request
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
); );
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
} }
/** /**
@ -272,17 +197,19 @@ class Client
* *
* @param string $request Request parameters * @param string $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception * @throws \Exception
*/ */
public function commandDelete(string $request) public function commandDelete(string $request)
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
sprintf("/my/commands/%s", $request), sprintf("/my/commands/%s", $request),
HttpClient::METHOD_DELETE, HttpClient::METHOD_DELETE
null,
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
); );
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
} }
/** /**
@ -290,18 +217,20 @@ class Client
* *
* @param Model\Request\CustomersRequest $request Request parameters * @param Model\Request\CustomersRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object * @return array
* @throws \Exception * @throws \Exception
*/ */
public function customers(Model\Request\CustomersRequest $request) public function customers(Model\Request\CustomersRequest $request): array
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/customers', '/customers',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request
static::getEntityClass('Customer'),
true
); );
$adapter = new ModelAdapter(Customer::class);
return $adapter->getResponseList($response);
} }
/** /**
@ -309,18 +238,20 @@ class Client
* *
* @param Model\Request\DialogsRequest $request Request parameters * @param Model\Request\DialogsRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object * @return array
* @throws \Exception * @throws \Exception
*/ */
public function dialogs(Model\Request\DialogsRequest $request) public function dialogs(Model\Request\DialogsRequest $request): array
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/dialogs', '/dialogs',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request
static::getEntityClass('Dialog'),
true
); );
$adapter = new ModelAdapter(Dialog::class);
return $adapter->getResponseList($response);
} }
/** /**
@ -328,17 +259,20 @@ class Client
* *
* @param Model\Request\DialogAssignRequest $request Request parameters * @param Model\Request\DialogAssignRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\AssignResponse|object * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception * @throws \Exception
*/ */
public function dialogAssign(Model\Request\DialogAssignRequest $request) public function dialogAssign(Model\Request\DialogAssignRequest $request)
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
sprintf("/dialogs/%d/assign", $request->getDialogId()), sprintf("/dialogs/%d/assign", $request->getDialogId()),
HttpClient::METHOD_PATCH, HttpClient::METHOD_PATCH,
$request, $request
static::getResponseClass('AssignResponse')
); );
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
} }
/** /**
@ -346,17 +280,20 @@ class Client
* *
* @param string $request Request parameters * @param string $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception * @throws \Exception
*/ */
public function dialogClose(string $request) public function dialogClose(string $request)
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
sprintf("/dialogs/%d/close", $request), sprintf("/dialogs/%d/close", $request),
HttpClient::METHOD_DELETE, HttpClient::METHOD_DELETE,
null, null
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
); );
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
} }
/** /**
@ -364,18 +301,20 @@ class Client
* *
* @param Model\Request\MembersRequest $request Request parameters * @param Model\Request\MembersRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object * @return array
* @throws \Exception * @throws \Exception
*/ */
public function members(Model\Request\MembersRequest $request) public function members(Model\Request\MembersRequest $request): array
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/members', '/members',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request
static::getEntityClass('Chat', 'ChatMember'),
true
); );
$adapter = new ModelAdapter(ChatMember::class);
return $adapter->getResponseList($response);
} }
/** /**
@ -383,18 +322,20 @@ class Client
* *
* @param Model\Request\MessagesRequest $request Request parameters * @param Model\Request\MessagesRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object * @return array
* @throws \Exception * @throws \Exception
*/ */
public function messages(Model\Request\MessagesRequest $request) public function messages(Model\Request\MessagesRequest $request): array
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/messages', '/messages',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request
self::getEntityClass('Message', 'Message'),
true
); );
$adapter = new ModelAdapter(Message::class);
return $adapter->getResponseList($response);
} }
/** /**
@ -402,17 +343,20 @@ class Client
* *
* @param Model\Request\MessageSendRequest $request Request parameters * @param Model\Request\MessageSendRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\MessageSendResponse|object * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception * @throws \Exception
*/ */
public function messageSend(Model\Request\MessageSendRequest $request) public function messageSend(Model\Request\MessageSendRequest $request)
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/messages', '/messages',
HttpClient::METHOD_POST, HttpClient::METHOD_POST,
$request, $request
static::getResponseClass('MessageSendResponse')
); );
$adapter = new ModelAdapter(MessageSendResponse::class);
return $adapter->getResponseModel($response);
} }
/** /**
@ -420,17 +364,20 @@ class Client
* *
* @param Model\Request\MessageEditRequest $request Request parameters * @param Model\Request\MessageEditRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\MessageSendResponse|object * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception * @throws \Exception
*/ */
public function messageEdit(Model\Request\MessageEditRequest $request) public function messageEdit(Model\Request\MessageEditRequest $request)
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
sprintf("/messages/%d", $request->getId()), sprintf("/messages/%d", $request->getId()),
HttpClient::METHOD_PATCH, HttpClient::METHOD_PATCH,
$request, $request
static::getResponseClass('MessageSendResponse')
); );
$adapter = new ModelAdapter(MessageSendResponse::class);
return $adapter->getResponseModel($response);
} }
/** /**
@ -438,17 +385,20 @@ class Client
* *
* @param string $request Request parameters * @param string $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse|object * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception * @throws \Exception
*/ */
public function messageDelete(string $request) public function messageDelete(string $request)
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
sprintf("/messages/%d", $request), sprintf("/messages/%d", $request),
HttpClient::METHOD_DELETE, HttpClient::METHOD_DELETE,
null, null
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
); );
$adapter = new ModelAdapter(ErrorOnlyResponse::class);
return $adapter->getResponseModel($response);
} }
/** /**
@ -456,18 +406,20 @@ class Client
* *
* @param Model\Request\UsersRequest $request Request parameters * @param Model\Request\UsersRequest $request Request parameters
* *
* @return \RetailCrm\Mg\Bot\Model\Response\ListResponse|object * @return array
* @throws \Exception * @throws \Exception
*/ */
public function users(Model\Request\UsersRequest $request) public function users(Model\Request\UsersRequest $request): array
{ {
return $this->submitRequest( $response = $this->client->makeRequest(
'/users', '/users',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request
self::getEntityClass('User'),
true
); );
$adapter = new ModelAdapter(User::class);
return $adapter->getResponseList($response);
} }
/** /**
@ -475,7 +427,7 @@ class Client
* *
* @param string $url File URL * @param string $url File URL
* *
* @return \RetailCrm\Mg\Bot\Model\Response\UploadFileResponse|object * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* @throws \Exception * @throws \Exception
*/ */
public function uploadFileByUrl(string $url) public function uploadFileByUrl(string $url)
@ -483,51 +435,54 @@ class Client
$request = new UploadFileByUrlRequest(); $request = new UploadFileByUrlRequest();
$request->setUrl($url); $request->setUrl($url);
return $this->submitRequest( $response = $this->client->makeRequest(
'/files/upload_by_url', '/files/upload_by_url',
HttpClient::METHOD_POST, HttpClient::METHOD_POST,
$request, $request
self::getResponseClass('UploadFileResponse')
); );
$adapter = new ModelAdapter(UploadFileResponse::class);
return $adapter->getResponseModel($response);
} }
/** /**
* @param string $filename * @param string $filename
* @return Model\Response\UploadFileResponse|null * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* *
* @throws \Exception * @throws \Exception
*/ */
public function uploadFile(string $filename) public function uploadFile(string $filename)
{ {
$obj = new ErrorOnlyResponse();
$response = $this->client->postFile($filename); $response = $this->client->postFile($filename);
if ($response instanceof ResponseInterface) { if ($response instanceof ResponseInterface) {
$obj = Serializer::deserialize( $obj = Serializer::deserialize(
(string) $response->getBody(), (string) $response->getBody(),
self::getResponseClass('UploadFileResponse') UploadFileResponse::class
); );
return $obj instanceof UploadFileResponse ? $obj : null;
} }
return null; return $obj;
} }
/** /**
* @param string $fileId * @param string $fileId
* @return Model\Response\FullFileResponse|null * @return \RetailCrm\Mg\Bot\Model\ModelInterface
* *
* @throws \Exception * @throws \Exception
*/ */
public function getFileById(string $fileId) public function getFileById(string $fileId)
{ {
$obj = $this->submitRequest( $response = $this->client->makeRequest(
\sprintf('/files/%s', $fileId), sprintf('/files/%s', $fileId),
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
null, null
self::getResponseClass('FullFileResponse')
); );
return ($obj instanceof FullFileResponse) ? $obj : null; $adapter = new ModelAdapter(FullFileResponse::class);
return $adapter->getResponseModel($response);
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* HttpClient * HttpClient
* *
@ -13,11 +13,18 @@
namespace RetailCrm\Mg\Bot; namespace RetailCrm\Mg\Bot;
use BadMethodCallException;
use ErrorException;
use Exception;
use InvalidArgumentException;
use RetailCrm\Common\Exception\InvalidJsonException; use RetailCrm\Common\Exception\InvalidJsonException;
use RetailCrm\Common\Exception\LimitException; use RetailCrm\Common\Exception\LimitException;
use InvalidArgumentException; use RetailCrm\Common\Exception\NotFoundException;
use RetailCrm\Common\Exception\UnauthorizedException;
use RetailCrm\Common\Serializer; use RetailCrm\Common\Serializer;
use RetailCrm\Common\Url; use RetailCrm\Common\Url;
use RetailCrm\Mg\Bot\Adapter\ResponseAdapter;
use RuntimeException;
use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\Validation;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Request;
@ -26,9 +33,7 @@ use Psr\Http\Message\ResponseInterface;
use function GuzzleHttp\Psr7\stream_for; use function GuzzleHttp\Psr7\stream_for;
/** /**
* PHP version 7.0 * Class HttpClient
*
* HttpClient class
* *
* @package RetailCrm\Mg\Bot * @package RetailCrm\Mg\Bot
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
@ -107,7 +112,7 @@ class HttpClient
* @param string $method Request method (default: 'GET') * @param string $method Request method (default: 'GET')
* @param mixed $request Request model (default: null) * @param mixed $request Request model (default: null)
* *
* @return ResponseInterface * @return \RetailCrm\Mg\Bot\Model\Response
* @throws \Exception * @throws \Exception
*/ */
public function makeRequest($path, $method, $request = null) public function makeRequest($path, $method, $request = null)
@ -121,20 +126,20 @@ class HttpClient
} }
if ($method == self::METHOD_GET && !is_null($request)) { if ($method == self::METHOD_GET && !is_null($request)) {
$getParameters = Url::buildGetParameters(Serializer::serialize($request, Serializer::S_ARRAY)); $getParameters = Url::buildGetParameters((array)Serializer::serialize($request, Serializer::S_ARRAY));
} }
$requestBody = is_null($request) ? null : Serializer::serialize($request, Serializer::S_JSON); $requestBody = is_null($request) ? '' : Serializer::serialize($request, Serializer::S_JSON);
$request = new Request( $request = new Request(
$method, $method,
\sprintf("%s%s%s", $this->basePath, $path, $getParameters), sprintf("%s%s%s", $this->basePath, $path, $getParameters),
[ [
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
'X-Bot-Token' => $this->token 'X-Bot-Token' => $this->token
] ]
); );
if (in_array($method, [self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_DELETE])) { if (in_array($method, [self::METHOD_POST, self::METHOD_PUT, self::METHOD_PATCH, self::METHOD_DELETE]) && is_string($requestBody)) {
$request = $request->withBody(stream_for($requestBody)); $request = $request->withBody(stream_for($requestBody));
} }
@ -151,27 +156,14 @@ class HttpClient
] ]
); );
} catch (GuzzleException $exception) { } catch (GuzzleException $exception) {
throw new \Exception($exception->getMessage(), $exception->getCode(), $exception); throw new Exception($exception->getMessage(), $exception->getCode(), $exception);
} }
$statusCode = $responseObject->getStatusCode(); $this->validateResponse($responseObject);
$response = self::parseJSON((string) $responseObject->getBody());
$errorMessage = !empty($response['errorMsg']) ? $response['errorMsg'] : '';
$errorMessage = !empty($response['errors']) ? $this->getErrors($response['errors']) : $errorMessage;
/** $adapter = new ResponseAdapter($responseObject);
* responses with 400 & 460 http codes contains extended error data
* therefore they are not handled as exceptions
*/
if (in_array($statusCode, [403, 404, 500])) {
throw new \InvalidArgumentException($errorMessage);
}
if ($statusCode == 503) { return $adapter->build();
throw new LimitException($errorMessage);
}
return $responseObject;
} }
/** /**
@ -183,17 +175,17 @@ class HttpClient
public function postFile(string $filename) public function postFile(string $filename)
{ {
if (!file_exists($filename)) { if (!file_exists($filename)) {
throw new \InvalidArgumentException("File doesn't exist"); throw new InvalidArgumentException("File doesn't exist");
} }
if (filesize($filename) == 0) { if (filesize($filename) == 0) {
throw new \InvalidArgumentException("Empty file provided"); throw new InvalidArgumentException("Empty file provided");
} }
try { try {
$responseData = $this->client->request( $responseData = $this->client->request(
self::METHOD_POST, self::METHOD_POST,
\sprintf("%s/files/upload", $this->basePath), sprintf("%s/files/upload", $this->basePath),
[ [
'headers' => [ 'headers' => [
'X-Bot-Token' => $this->token 'X-Bot-Token' => $this->token
@ -202,7 +194,7 @@ class HttpClient
] ]
); );
} catch (GuzzleException $exception) { } catch (GuzzleException $exception) {
throw new \Exception($exception->getMessage(), $exception->getCode(), $exception); throw new Exception($exception->getMessage(), $exception->getCode(), $exception);
} }
return isset($responseData) ? $responseData : null; return isset($responseData) ? $responseData : null;
@ -235,19 +227,62 @@ class HttpClient
*/ */
private function validateRequest($class) private function validateRequest($class)
{ {
if (!is_string($class) && method_exists($class, 'validate')) { $validator = Validation::createValidatorBuilder()
$errors = $class->validate(); ->enableAnnotationMapping()
} else { ->getValidator();
$validator = Validation::createValidatorBuilder()
->enableAnnotationMapping()
->getValidator();
$errors = $validator->validate($class); $errors = $validator->validate($class);
if ($errors->count() > 0) {
$message = '';
foreach ($errors as $error) {
$message .= (string)$error;
}
throw new InvalidArgumentException($message);
}
}
/**
* @param \Psr\Http\Message\ResponseInterface $responseObject
*
* @throws \ErrorException
*/
private function validateResponse(ResponseInterface $responseObject)
{
$statusCode = $responseObject->getStatusCode();
$response = self::parseJSON((string)$responseObject->getBody());
$errorMessage = !empty($response['errorMsg']) ? $response['errorMsg'] : '';
$errorMessage = !empty($response['errors']) ? $this->getErrors($response['errors']) : $errorMessage;
/**
* responses with 400 & 460 http codes contains extended error data
* therefore they are not handled as exceptions
*/
if ($statusCode == 400) {
throw new RuntimeException($errorMessage);
} }
if ((is_object($errors) && call_user_func([$errors, 'count']) > 0) || is_string($errors)) { if (in_array($statusCode, [401, 403])) {
$message = (string) $errors; throw new UnauthorizedException($errorMessage);
throw new InvalidArgumentException($message); }
if ($statusCode == 404) {
throw new NotFoundException($errorMessage);
}
if (in_array($statusCode, [405, 501])) {
throw new BadMethodCallException($errorMessage);
}
if (in_array($statusCode, [500, 502])) {
throw new ErrorException($errorMessage);
}
if ($statusCode == 503) {
throw new LimitException($errorMessage);
} }
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Constants * Constants
* *
@ -14,8 +14,6 @@
namespace RetailCrm\Mg\Bot\Model; namespace RetailCrm\Mg\Bot\Model;
/** /**
* PHP version 7.0
*
* Constants class * Constants class
* *
* @package RetailCrm\Mg\Bot\Model * @package RetailCrm\Mg\Bot\Model

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Bot entity * Bot entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* Bot class * Bot class
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @package RetailCrm\Mg\Bot\Model\Entity
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class Bot class Bot implements ModelInterface
{ {
/** /**
* @var string $id * @var string $id

View File

@ -1,33 +1,32 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Channel entity * Channel entity
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Channel * @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
namespace RetailCrm\Mg\Bot\Model\Entity\Channel; namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation\SkipWhenEmpty; use DateTime;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0 * Class Channel
* *
* Channel class * @package RetailCrm\Mg\Bot\Model\Entity\Channel
* * @author retailCRM <integration@retailcrm.ru>
* @package RetailCrm\Mg\Bot\Model\Entity\Channel * @license https://opensource.org/licenses/MIT MIT License
* @author retailCRM <integration@retailcrm.ru> * @link http://help.retailcrm.pro/docs/Developers
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/ */
class Channel class Channel implements ModelInterface
{ {
/** /**
* @var string $id * @var string $id
@ -120,7 +119,7 @@ class Channel
/** /**
* @return \DateTime * @return \DateTime
*/ */
public function getCreatedAt(): \DateTime public function getCreatedAt(): DateTime
{ {
return $this->createdAt; return $this->createdAt;
} }
@ -128,7 +127,7 @@ class Channel
/** /**
* @param \DateTime $createdAt * @param \DateTime $createdAt
*/ */
public function setCreatedAt(\DateTime $createdAt) public function setCreatedAt(DateTime $createdAt)
{ {
$this->createdAt = $createdAt; $this->createdAt = $createdAt;
} }
@ -136,7 +135,7 @@ class Channel
/** /**
* @return \DateTime * @return \DateTime
*/ */
public function getUpdatedAt(): \DateTime public function getUpdatedAt(): DateTime
{ {
return $this->updatedAt; return $this->updatedAt;
} }
@ -144,7 +143,7 @@ class Channel
/** /**
* @param \DateTime $updatedAt * @param \DateTime $updatedAt
*/ */
public function setUpdatedAt(\DateTime $updatedAt) public function setUpdatedAt(DateTime $updatedAt)
{ {
$this->updatedAt = $updatedAt; $this->updatedAt = $updatedAt;
} }
@ -152,7 +151,7 @@ class Channel
/** /**
* @return \DateTime * @return \DateTime
*/ */
public function getActivatedAt(): \DateTime public function getActivatedAt(): DateTime
{ {
return $this->activatedAt; return $this->activatedAt;
} }
@ -160,7 +159,7 @@ class Channel
/** /**
* @param \DateTime $activatedAt * @param \DateTime $activatedAt
*/ */
public function setActivatedAt(\DateTime $activatedAt) public function setActivatedAt(DateTime $activatedAt)
{ {
$this->activatedAt = $activatedAt; $this->activatedAt = $activatedAt;
} }
@ -168,7 +167,7 @@ class Channel
/** /**
* @return \DateTime * @return \DateTime
*/ */
public function getDeactivatedAt(): \DateTime public function getDeactivatedAt(): DateTime
{ {
return $this->deactivatedAt; return $this->deactivatedAt;
} }
@ -176,7 +175,7 @@ class Channel
/** /**
* @param \DateTime $deactivatedAt * @param \DateTime $deactivatedAt
*/ */
public function setDeactivatedAt(\DateTime $deactivatedAt) public function setDeactivatedAt(DateTime $deactivatedAt)
{ {
$this->deactivatedAt = $deactivatedAt; $this->deactivatedAt = $deactivatedAt;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* ChannelSettings entity * ChannelSettings entity
* *
@ -16,18 +16,17 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0 * Class ChannelSettings
*
* ChannelSettings class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Channel * @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class ChannelSettings class ChannelSettings implements ModelInterface
{ {
/** /**
* @var ChannelSettingsStatus $status * @var ChannelSettingsStatus $status

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* ChannelSettingsItem entity * ChannelSettingsItem entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* ChannelSettingsItem class * ChannelSettingsItem class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Channel * @package RetailCrm\Mg\Bot\Model\Entity\Channel
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class ChannelSettingsItem class ChannelSettingsItem implements ModelInterface
{ {
/** /**
* @var string $creating * @var string $creating

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* ChannelSettingsStatus entity * ChannelSettingsStatus entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* ChannelSettingsStatus class * ChannelSettingsStatus class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Channel * @package RetailCrm\Mg\Bot\Model\Entity\Channel
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class ChannelSettingsStatus class ChannelSettingsStatus implements ModelInterface
{ {
/** /**
* @var string $delivered * @var string $delivered

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Chat entity * Chat entity
* *
@ -18,10 +18,9 @@ use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Customer; use RetailCrm\Mg\Bot\Model\Entity\Customer;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* Chat class * Chat class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Chat * @package RetailCrm\Mg\Bot\Model\Entity\Chat
@ -29,7 +28,7 @@ use RetailCrm\Mg\Bot\Model\Entity\Customer;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class Chat class Chat implements ModelInterface
{ {
/** /**
* @var string $id * @var string $id

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* ChatLastMessage entity * ChatLastMessage entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Chat;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* ChatLastMessage class * ChatLastMessage class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Chat * @package RetailCrm\Mg\Bot\Model\Entity\Chat
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class ChatLastMessage class ChatLastMessage implements ModelInterface
{ {
/** /**
* @var int $creating * @var int $creating

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* ChatMember entity * ChatMember entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Chat;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* ChatMember class * ChatMember class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Chat * @package RetailCrm\Mg\Bot\Model\Entity\Chat
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class ChatMember class ChatMember implements ModelInterface
{ {
/** /**
* @var string $id * @var string $id

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Command entity * Command entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* Command class * Command class
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @package RetailCrm\Mg\Bot\Model\Entity
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class Command class Command implements ModelInterface
{ {
/** /**
* @var string $id * @var string $id

View File

@ -0,0 +1,81 @@
<?php
/**
* PHP version 7.1
*
* 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;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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 implements ModelInterface
{
/**
* @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;
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Customer entity * Customer entity
* *
@ -13,23 +13,21 @@
namespace RetailCrm\Mg\Bot\Model\Entity; namespace RetailCrm\Mg\Bot\Model\Entity;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
/** /**
* PHP version 7.0
*
* Customer class * Customer class
* | email | string |
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class Customer class Customer implements ModelInterface
{ {
/** /**
* @var string $id * @var string $id

View File

@ -0,0 +1,132 @@
<?php
/**
* PHP version 7.1
*
* 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;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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 implements ModelInterface
{
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
*
* @Assert\NotBlank
*/
private $name;
/**
* @var Cost $price
*
* @Type("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 Cost
*/
public function getPrice()
{
return $this->price;
}
/**
* @param 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;
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Dialog entity * Dialog entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* Dialog class * Dialog class
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @package RetailCrm\Mg\Bot\Model\Entity
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class Dialog class Dialog implements ModelInterface
{ {
/** /**
* @var string $id * @var string $id

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* FileMeta entity * FileMeta entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* FileMeta class * FileMeta class
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @package RetailCrm\Mg\Bot\Model\Entity
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class FileMeta class FileMeta implements ModelInterface
{ {
/** /**
* @var int $height * @var int $height

View File

@ -0,0 +1,80 @@
<?php
/**
* PHP version 7.1
*
* 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;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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 implements ModelInterface
{
/**
* @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;
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Item entity * Item entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* Item class * Item class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Message * @package RetailCrm\Mg\Bot\Model\Entity\Message
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class Item class Item implements ModelInterface
{ {
/** /**
* @var string $id * @var string $id

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Message entity * Message entity
* *
@ -18,10 +18,9 @@ use RetailCrm\Mg\Bot\Model\Entity\User;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* Message class * Message class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Message * @package RetailCrm\Mg\Bot\Model\Entity\Message
@ -29,7 +28,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class Message class Message implements ModelInterface
{ {
/** /**
* @var string $id * @var string $id

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* MessageCost entity * MessageCost entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessageCost class * MessageCost class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Message * @package RetailCrm\Mg\Bot\Model\Entity\Message
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessageCost class MessageCost implements ModelInterface
{ {
/** /**
* @var float $value * @var float $value

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* MessageDelivery entity * MessageDelivery entity
* *
@ -16,11 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost; use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessageDelivery class * MessageDelivery class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Message * @package RetailCrm\Mg\Bot\Model\Entity\Message
@ -28,7 +26,7 @@ use RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessageDelivery class MessageDelivery implements ModelInterface
{ {
/** /**
* @var string $name * @var string $name

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* MessageOrder entity * MessageOrder entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessageOrder class * MessageOrder class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Message * @package RetailCrm\Mg\Bot\Model\Entity\Message
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessageOrder class MessageOrder implements ModelInterface
{ {
/** /**
* @var string $number * @var string $number

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0. * PHP version 7.1
* *
* MessageOrderItem entity * MessageOrderItem entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0.
*
* MessageOrderItem class * MessageOrderItem class
* *
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* *
* @see http://help.retailcrm.pro/docs/Developers * @see http://help.retailcrm.pro/docs/Developers
*/ */
class MessageOrderItem class MessageOrderItem implements ModelInterface
{ {
/** /**
* @var string * @var string

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* MessageOrderPaymentStatus entity * MessageOrderPaymentStatus entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessageOrderPaymentStatus class * MessageOrderPaymentStatus class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Message * @package RetailCrm\Mg\Bot\Model\Entity\Message
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessageOrderPaymentStatus class MessageOrderPaymentStatus implements ModelInterface
{ {
/** /**
* @var string $name * @var string $name

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* MessagePayment entity * MessagePayment entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessagePayment class * MessagePayment class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Message * @package RetailCrm\Mg\Bot\Model\Entity\Message
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessagePayment class MessagePayment implements ModelInterface
{ {
/** /**
* @var string $name * @var string $name

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* MessageProduct entity * MessageProduct entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessageProduct class * MessageProduct class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Message * @package RetailCrm\Mg\Bot\Model\Entity\Message
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessageProduct class MessageProduct implements ModelInterface
{ {
/** /**
* @var int $id * @var int $id

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* MessageQuantity entity * MessageQuantity entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessageQuantity class * MessageQuantity class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Message * @package RetailCrm\Mg\Bot\Model\Entity\Message
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessageQuantity class MessageQuantity implements ModelInterface
{ {
/** /**
* @var float $value * @var float $value

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* MessageStatus entity * MessageStatus entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Message;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessageStatus class * MessageStatus class
* *
* @package RetailCrm\Mg\Bot\Model\Entity\Message * @package RetailCrm\Mg\Bot\Model\Entity\Message
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessageStatus class MessageStatus implements ModelInterface
{ {
/** /**
* @var string $code * @var string $code

View File

@ -0,0 +1,230 @@
<?php
/**
* PHP version 7.1
*
* 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;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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 implements ModelInterface
{
/**
* @var string $number
*
* @Type("string")
* @Accessor(getter="getNumber",setter="setNumber")
* @SkipWhenEmpty()
*/
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 Cost $cost
*
* @Type("Cost")
* @Accessor(getter="getCost",setter="setCost")
* @SkipWhenEmpty()
*/
private $cost;
/**
* @var Status $status
*
* @Type("Status")
* @Accessor(getter="getStatus",setter="setStatus")
* @SkipWhenEmpty()
*/
private $status;
/**
* @var Delivery $delivery
*
* @Type("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 Cost
*/
public function getCost()
{
return $this->cost;
}
/**
* @param Cost $cost
*/
public function setCost(Cost $cost)
{
$this->cost = $cost;
}
/**
* @return Status
*/
public function getStatus()
{
return $this->status;
}
/**
* @param Status $status
*/
public function setStatus(Status $status)
{
$this->status = $status;
}
/**
* @return Delivery
*/
public function getDelivery()
{
return $this->delivery;
}
/**
* @param 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;
}
}

View File

@ -0,0 +1,155 @@
<?php
/**
* PHP version 7.1
*
* 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;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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 implements ModelInterface
{
/**
* @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 Cost $price
*
* @Type("Cost")
* @Accessor(getter="getPrice",setter="setPrice")
* @SkipWhenEmpty()
*/
private $price;
/**
* @var Quantity $quantity
*
* @Type("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 Cost
*/
public function getPrice()
{
return $this->price;
}
/**
* @param Cost $price
*/
public function setPrice(Cost $price)
{
$this->price = $price;
}
/**
* @return Quantity
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* @param Quantity $quantity
*/
public function setQuantity(Quantity $quantity)
{
$this->quantity = $quantity;
}
}

View File

@ -0,0 +1,105 @@
<?php
/**
* PHP version 7.1
*
* 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;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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 implements ModelInterface
{
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
* @SkipWhenEmpty()
*/
private $name;
/**
* @var PaymentStatus $status
*
* @Type("PaymentStatus")
* @Accessor(getter="getStatus",setter="setStatus")
* @SkipWhenEmpty()
*/
private $status;
/**
* @var Cost $amount
*
* @Type("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 PaymentStatus
*/
public function getStatus()
{
return $this->status;
}
/**
* @param PaymentStatus $status
*/
public function setStatus(PaymentStatus $status)
{
$this->status = $status;
}
/**
* @return Cost
*/
public function getAmount()
{
return $this->amount;
}
/**
* @param Cost $amount
*/
public function setAmount(Cost $amount)
{
$this->amount = $amount;
}
}

View File

@ -0,0 +1,80 @@
<?php
/**
* PHP version 7.1
*
* 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;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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 implements ModelInterface
{
/**
* @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;
}
}

View File

@ -0,0 +1,205 @@
<?php
/**
* PHP version 7.1
*
* 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;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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 implements ModelInterface
{
/**
* @var int $id
*
* @Type("int")
* @Accessor(getter="getId",setter="setId")
* @SkipWhenEmpty()
*/
private $id;
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
* @SkipWhenEmpty()
*/
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 Cost $cost
*
* @Type("Cost")
* @Accessor(getter="getCost",setter="setCost")
* @SkipWhenEmpty()
*/
private $cost;
/**
* @var Quantity $quantity
*
* @Type("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 Cost
*/
public function getCost()
{
return $this->cost;
}
/**
* @param Cost $cost
*/
public function setCost(Cost $cost)
{
$this->cost = $cost;
}
/**
* @return Quantity
*/
public function getQuantity()
{
return $this->quantity;
}
/**
* @param Quantity $quantity
*/
public function setQuantity(Quantity $quantity)
{
$this->quantity = $quantity;
}
}

View File

@ -0,0 +1,81 @@
<?php
/**
* PHP version 7.1
*
* 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;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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 implements ModelInterface
{
/**
* @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;
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Responsible entity * Responsible entity
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* Responsible class * Responsible class
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @package RetailCrm\Mg\Bot\Model\Entity
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class Responsible class Responsible implements ModelInterface
{ {
/** /**
* @var string $assignedAt * @var string $assignedAt

View File

@ -0,0 +1,80 @@
<?php
/**
* PHP version 7.1
*
* 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;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/**
* 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 implements ModelInterface
{
/**
* @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;
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* User entity * User entity
* *
@ -13,14 +13,13 @@
namespace RetailCrm\Mg\Bot\Model\Entity; namespace RetailCrm\Mg\Bot\Model\Entity;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
/** /**
* PHP version 7.0
*
* User class * User class
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @package RetailCrm\Mg\Bot\Model\Entity
@ -28,7 +27,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class User class User implements ModelInterface
{ {
/** /**
* @var string $id * @var string $id

View File

@ -0,0 +1,18 @@
<?php
/**
* PHP version 7.1
*
* ModelInterface
*
* @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;
interface ModelInterface
{
}

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Bots Request * Bots Request
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* BotsRequest class * BotsRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class BotsRequest class BotsRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Channels list request * Channels list request
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* ChannelsRequest class * ChannelsRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class ChannelsRequest class ChannelsRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Chats list request * Chats list request
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* ChatsRequest class * ChatsRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class ChatsRequest class ChatsRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Edit Command Request * Edit Command Request
* *
@ -13,15 +13,12 @@
namespace RetailCrm\Mg\Bot\Model\Request; namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use Symfony\Component\Validator\Constraints as Assert; use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* CommandEditRequest class * CommandEditRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -29,7 +26,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class CommandEditRequest class CommandEditRequest implements ModelInterface
{ {
/** /**
* @var int $botId * @var int $botId

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Commands list request * Commands list request
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* CommandsRequest class * CommandsRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class CommandsRequest class CommandsRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Common fields * Common fields
* *
@ -18,8 +18,6 @@ use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
/** /**
* PHP version 7.0
*
* CommonFields trait * CommonFields trait
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Customers list request * Customers list request
* *
@ -16,11 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Request\CommonFields; use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* CustomersRequest class * CustomersRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -28,7 +26,7 @@ use RetailCrm\Mg\Bot\Model\Request\CommonFields;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class CustomersRequest class CustomersRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Dialog assign request * Dialog assign request
* *
@ -17,10 +17,9 @@ use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* DialogAssignRequest class * DialogAssignRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -28,7 +27,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class DialogAssignRequest class DialogAssignRequest implements ModelInterface
{ {
/** /**
* @var int $dialogId * @var int $dialogId

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Dialogs list request * Dialogs list request
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* DialogsRequest class * DialogsRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class DialogsRequest class DialogsRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Bot info request * Bot info request
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* InfoRequest class * InfoRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class InfoRequest class InfoRequest implements ModelInterface
{ {
/** /**
* @var string $name * @var string $name

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Members list request * Members list request
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MembersRequest class * MembersRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MembersRequest class MembersRequest implements ModelInterface
{ {
/** /**
* @var int $chatId * @var int $chatId

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Messages edit request * Messages edit request
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessageEditRequest class * MessageEditRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessageEditRequest class MessageEditRequest implements ModelInterface
{ {
/** /**
* @var int $id * @var int $id

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Messages send request * Messages send request
* *
@ -18,13 +18,10 @@ use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder; use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder;
use RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct; use RetailCrm\Mg\Bot\Model\Entity\Message\MessageProduct;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
use RetailCrm\Mg\Bot\Model\Entity\Order;
use RetailCrm\Mg\Bot\Model\Entity\Product;
/** /**
* PHP version 7.0
*
* MessageSendRequest class * MessageSendRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -32,7 +29,7 @@ use RetailCrm\Mg\Bot\Model\Entity\Product;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessageSendRequest class MessageSendRequest implements ModelInterface
{ {
/** /**
* @var string $type * @var string $type

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Messages list request * Messages list request
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessagesRequest class * MessagesRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessagesRequest class MessagesRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Upload file by url request * Upload file by url request
* *
@ -15,11 +15,10 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
* PHP version 7.0
*
* UploadFileByUrlRequest class * UploadFileByUrlRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class UploadFileByUrlRequest class UploadFileByUrlRequest implements ModelInterface
{ {
/** /**
* @var string $url * @var string $url

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Users list request * Users list request
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Request;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* UsersRequest class * UsersRequest class
* *
* @package RetailCrm\Mg\Bot\Model\Request * @package RetailCrm\Mg\Bot\Model\Request
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class UsersRequest class UsersRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -0,0 +1,57 @@
<?php
/**
* PHP version 7.1
*
* ModelInterface
*
* @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;
/**
* Class Response
*
* @package RetailCrm\Mg\Bot\Model
*/
class Response
{
private $status;
private $body;
/**
* @return mixed
*/
public function getStatus()
{
return $this->status;
}
/**
* @param mixed $status
*/
public function setStatus($status)
{
$this->status = $status;
}
/**
* @return mixed
*/
public function getBody()
{
return $this->body;
}
/**
* @param mixed $body
*/
public function setBody($body)
{
$this->body = $body;
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* AssignResponse * AssignResponse
* *
@ -17,10 +17,9 @@ use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Responsible; use RetailCrm\Mg\Bot\Model\Entity\Responsible;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* AssignResponse class * AssignResponse class
* *
* @package RetailCrm\Mg\Bot\Model\Response * @package RetailCrm\Mg\Bot\Model\Response
@ -28,7 +27,7 @@ use RetailCrm\Mg\Bot\Model\Entity\Responsible;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class AssignResponse class AssignResponse implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* ErrorTrait * ErrorTrait
* *
@ -19,8 +19,6 @@ use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
/** /**
* PHP version 7.0
*
* CommonFields trait * CommonFields trait
* *
* @package RetailCrm\Mg\Bot\Model\Response * @package RetailCrm\Mg\Bot\Model\Response
@ -50,7 +48,7 @@ trait CommonFields
*/ */
public function getErrors(): array public function getErrors(): array
{ {
return is_null($this->errors) ? [] : $this->errors; return empty($this->errors) ? [] : $this->errors;
} }
/** /**

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* ErrorOnlyResponse * ErrorOnlyResponse
* *
@ -13,9 +13,9 @@
namespace RetailCrm\Mg\Bot\Model\Response; namespace RetailCrm\Mg\Bot\Model\Response;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* ErrorOnlyResponse class * ErrorOnlyResponse class
* *
* @package RetailCrm\Mg\Bot\Model\Response * @package RetailCrm\Mg\Bot\Model\Response
@ -23,7 +23,7 @@ namespace RetailCrm\Mg\Bot\Model\Response;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class ErrorOnlyResponse class ErrorOnlyResponse implements ModelInterface
{ {
use CommonFields; use CommonFields;
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* FullFileResponse * FullFileResponse
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Response;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* FullFileResponse class * FullFileResponse class
* *
* @package RetailCrm\Mg\Bot\Model\Response * @package RetailCrm\Mg\Bot\Model\Response
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class FullFileResponse class FullFileResponse implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -1,202 +0,0 @@
<?php
/**
* PHP version 7.0
*
* ListResponse
*
* @package RetailCrm\Mg\Bot\Model\Response
* @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\Response;
use RetailCrm\Common\Serializer;
/**
* PHP version 7.0
*
* ListResponse class. Used to store multiple objects at once.
* Implements `Iterator`, `ArrayAccess` and `Countable`.
*
* @package RetailCrm\Mg\Bot\Model\Response
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class ListResponse implements \Iterator, \ArrayAccess, \Countable
{
use CommonFields;
/**
* @var array
*/
private $items = [];
/**
* @var int
*/
private $position = 0;
/**
* ListResponse constructor.
*
* @param string $responseType
* @param array $data
* @param int $statusCode
*/
public function __construct($responseType, $data, $statusCode)
{
$this->setStatusCode($statusCode);
if (isset($data['errors'])) {
$this->setErrors($data['errors']);
} else {
foreach ($data as $item) {
$this->items[] =
Serializer::deserialize($item, $responseType, Serializer::S_ARRAY);
}
}
}
/**
* @return bool
*/
public function isSuccessful()
{
return empty($this->errors);
}
/**
* \Countable implementation
*
* @return int
*/
public function count(): int
{
return count($this->items ?: []);
}
/**
* Set offset
*
* @param mixed $offset offset value
* @param mixed $value value
*
* @return void
* @internal
*/
public function offsetSet($offset, $value)
{
throw new \BadMethodCallException(
"This call not allowed: offsetSet [$offset] [$value]"
);
}
/**
* Unset offset
*
* @param mixed $offset offset value
*
* @return void
* @internal
*/
public function offsetUnset($offset)
{
throw new \BadMethodCallException(
"This call not allowed: offsetSet [$offset]"
);
}
/**
* Check offset
*
* @param mixed $offset offset value
*
* @return bool
* @internal
*/
public function offsetExists($offset)
{
return isset($this->items[$offset]);
}
/**
* Get offset
*
* @param mixed $offset offset value
*
* @return mixed
* @internal
*/
public function offsetGet($offset)
{
if (!isset($this->items[$offset])) {
throw new \InvalidArgumentException("Item \"$offset\" not found");
}
return $this->items[$offset];
}
/**
* @param mixed $name
*
* @return mixed
* @internal
*/
public function __get($name)
{
return $this->items[$name];
}
/**
* Implements rewind() for Iterable
* @internal
*/
public function rewind()
{
$this->position = 0;
}
/**
* Implements current() for Iterable
*
* @internal
* @return mixed
*/
public function current()
{
return $this->items[$this->position];
}
/**
* Implements key() for Iterable
*
* @internal
* @return int|mixed
*/
public function key()
{
return $this->position;
}
/**
* Implements next() for Iterable
* @internal
*/
public function next()
{
++$this->position;
}
/**
* Implements valid() for Iterable
*
* @internal
* @return bool
*/
public function valid()
{
return isset($this->items[$this->position]);
}
}

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* MessageSendResponse * MessageSendResponse
* *
@ -16,10 +16,9 @@ namespace RetailCrm\Mg\Bot\Model\Response;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* MessageSendResponse class * MessageSendResponse class
* *
* @package RetailCrm\Mg\Bot\Model\Response * @package RetailCrm\Mg\Bot\Model\Response
@ -27,7 +26,7 @@ use JMS\Serializer\Annotation\Type;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class MessageSendResponse class MessageSendResponse implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* UploadFileResponse * UploadFileResponse
* *
@ -17,10 +17,9 @@ use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\FileMeta; use RetailCrm\Mg\Bot\Model\Entity\FileMeta;
use RetailCrm\Mg\Bot\Model\ModelInterface;
/** /**
* PHP version 7.0
*
* UploadFileResponse class * UploadFileResponse class
* *
* @package RetailCrm\Mg\Bot\Model\Response * @package RetailCrm\Mg\Bot\Model\Response
@ -28,7 +27,7 @@ use RetailCrm\Mg\Bot\Model\Entity\FileMeta;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class UploadFileResponse class UploadFileResponse implements ModelInterface
{ {
use CommonFields; use CommonFields;

View File

@ -0,0 +1,29 @@
<?php
/**
* PHP version 7.1
*
* CurlException
*
* @package RetailCrm\Common\Exception
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Common\Exception;
use RuntimeException;
use Throwable;
/**
* Class CurlException
*
* @package RetailCrm\Common\Exception
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class CurlException extends RuntimeException implements Throwable
{
}

View File

@ -1,9 +1,9 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* CurlException * InvalidJsonException
* *
* @package RetailCrm\Common\Exception * @package RetailCrm\Common\Exception
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
@ -14,10 +14,9 @@
namespace RetailCrm\Common\Exception; namespace RetailCrm\Common\Exception;
use DomainException; use DomainException;
use Throwable;
/** /**
* PHP version 7.0
*
* Class InvalidJsonException * Class InvalidJsonException
* *
* @package RetailCrm\Common\Exception * @package RetailCrm\Common\Exception
@ -25,6 +24,6 @@ use DomainException;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class InvalidJsonException extends DomainException class InvalidJsonException extends DomainException implements Throwable
{ {
} }

View File

@ -1,9 +1,9 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* CurlException * LimitException
* *
* @package RetailCrm\Common\Exception * @package RetailCrm\Common\Exception
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
@ -14,10 +14,9 @@
namespace RetailCrm\Common\Exception; namespace RetailCrm\Common\Exception;
use DomainException; use DomainException;
use Throwable;
/** /**
* PHP version 7.0
*
* Class LimitException * Class LimitException
* *
* @package RetailCrm\Common\Exception * @package RetailCrm\Common\Exception
@ -25,6 +24,6 @@ use DomainException;
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class LimitException extends DomainException class LimitException extends DomainException implements Throwable
{ {
} }

View File

@ -0,0 +1,28 @@
<?php
/**
* PHP version 7.1
*
* NotFoundException
*
* @package RetailCrm\Common\Exception
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Common\Exception;
use DomainException;
use Throwable;
/**
* Class NotFoundException
*
* @package RetailCrm\Common\Exception
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class NotFoundException extends DomainException implements Throwable
{
}

View File

@ -0,0 +1,20 @@
<?php
/**
* PHP version 7.1
*
* UnauthorizedException
*
* @package RetailCrm\Common\Exception
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Common\Exception;
use DomainException;
use Throwable;
class UnauthorizedException extends DomainException implements Throwable
{
}

View File

@ -1,9 +1,9 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Register Helper * Register
* *
* @package RetailCrm\Common * @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
@ -19,9 +19,7 @@ use JMS\Serializer\Annotation\Type;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
/** /**
* PHP version 7.0 * Class Register
*
* RequestHelper class
* *
* @package RetailCrm\Common * @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
@ -328,6 +326,7 @@ class Register
* Get configuration as JSON * Get configuration as JSON
* *
* @return array|string * @return array|string
* @todo make exact type
*/ */
public function getJsonConfiguration() public function getJsonConfiguration()
{ {
@ -338,6 +337,7 @@ class Register
* Get configuration as array * Get configuration as array
* *
* @return array|string * @return array|string
* @todo make exact type
*/ */
public function getArrayConfiguration() public function getArrayConfiguration()
{ {

View File

@ -1,14 +1,14 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Serializer * Serializer
* *
* @package RetailCrm\Common * @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
namespace RetailCrm\Common; namespace RetailCrm\Common;
@ -16,16 +16,16 @@ namespace RetailCrm\Common;
use JMS\Serializer\DeserializationContext; use JMS\Serializer\DeserializationContext;
use JMS\Serializer\SerializationContext; use JMS\Serializer\SerializationContext;
use JMS\Serializer\SerializerBuilder; use JMS\Serializer\SerializerBuilder;
use RetailCrm\Mg\Bot\Model\ModelInterface;
use RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse;
/** /**
* PHP version 7.0 * Class Serializer
* *
* Serializer class * @package RetailCrm\Common
* * @author retailCRM <integration@retailcrm.ru>
* @package RetailCrm\Common * @license https://opensource.org/licenses/MIT MIT License
* @author retailCRM <integration@retailcrm.ru> * @link http://help.retailcrm.pro/docs/Developers
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/ */
class Serializer class Serializer
{ {
@ -62,11 +62,11 @@ class Serializer
/** /**
* Deserialize given array or JSON to object * Deserialize given array or JSON to object
* *
* @param mixed $data * @param mixed $data
* @param string $entityType * @param string $entityType
* @param string $from * @param string $from
* *
* @return object|null * @return \RetailCrm\Mg\Bot\Model\ModelInterface
*/ */
public static function deserialize($data, $entityType, $from = self::S_JSON) public static function deserialize($data, $entityType, $from = self::S_JSON)
{ {
@ -76,16 +76,16 @@ class Serializer
switch ($from) { switch ($from) {
case self::S_ARRAY: case self::S_ARRAY:
$deserialized = $deserialized = $serializer
$serializer->fromArray(array_filter($data), self::normalizeNamespace($entityType), $context); ->fromArray(array_filter($data), self::normalizeNamespace($entityType), $context);
break; break;
case self::S_JSON: case self::S_JSON:
$deserialized = $deserialized = $serializer
$serializer->deserialize($data, self::normalizeNamespace($entityType), $from, $context); ->deserialize($data, self::normalizeNamespace($entityType), $from, $context);
break; break;
} }
return is_object($deserialized) ? $deserialized : null; return $deserialized instanceof ModelInterface ? $deserialized : new ErrorOnlyResponse();
} }
/** /**

View File

@ -1,9 +1,9 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Url handler * Url
* *
* @package RetailCrm\Common * @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
@ -14,9 +14,7 @@
namespace RetailCrm\Common; namespace RetailCrm\Common;
/** /**
* PHP version 7.0 * Class Url
*
* Url class
* *
* @package RetailCrm\Common * @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
@ -25,13 +23,6 @@ namespace RetailCrm\Common;
*/ */
class Url class Url
{ {
/**
* This class is used to store normalizeUrl method
* which is used in Client and HttpClient to check
* trailing slash.
*/
private function __construct() {}
/** /**
* Check trailing slash into url * Check trailing slash into url
* *

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 5.4 * PHP version 7.1
* *
* Test case class * Test case class
* *
@ -22,7 +22,6 @@ use RetailCrm\Mg\Bot\Client;
/** /**
* Class TestCase * Class TestCase
* *
* @category RetailCrm
* @package Test * @package Test
* @author RetailCrm <integration@retailcrm.ru> * @author RetailCrm <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
@ -33,10 +32,10 @@ class TestCase extends BaseCase
/** /**
* Return bot api client object * Return bot api client object
* *
* @param string $url (default: null) * @param string $url (default: null)
* @param string $key (default: null) * @param string $key (default: null)
* @param bool $debug (default: false) * @param bool $debug (default: false)
* @param array $response (default: null) * @param array ...$response (default: null)
* *
* @return Client * @return Client
*/ */
@ -62,8 +61,8 @@ class TestCase extends BaseCase
/** /**
* Returns mocked GuzzleHttp response * Returns mocked GuzzleHttp response
* *
* @param string|null $body * @param string|null $body HTTP Body
* @param int $statusCode * @param int $statusCode HTTP status code
* *
* @return Response * @return Response
*/ */
@ -93,8 +92,8 @@ class TestCase extends BaseCase
* Only file name (without extension or any other data) should be provided, * Only file name (without extension or any other data) should be provided,
* e.g. `getJsonResponse('bots', 200)` * e.g. `getJsonResponse('bots', 200)`
* *
* @param string $jsonFile * @param string $jsonFile mocked body
* @param int $statusCode * @param int $statusCode mocked status code
* *
* @return Response|null * @return Response|null
*/ */
@ -120,8 +119,8 @@ class TestCase extends BaseCase
} }
/** /**
* @param int $statusCode * @param int $statusCode response code
* @param array ...$errors * @param array ...$errors response errors
* *
* @return Response * @return Response
*/ */
@ -139,7 +138,7 @@ class TestCase extends BaseCase
/** /**
* Generate and return empty response * Generate and return empty response
* *
* @param int $statusCode * @param int $statusCode HTTP status code
* *
* @return Response|null * @return Response|null
*/ */

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* PHP version 7.0 * PHP version 7.1
* *
* Client Test * Client Test
* *

View File

@ -6,6 +6,7 @@
* Dialogs Test * Dialogs Test
* *
* @package RetailCrm\Mg\Bot\Tests * @package RetailCrm\Mg\Bot\Tests
* @category Test
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
@ -25,9 +26,9 @@ use RetailCrm\Mg\Bot\Test\TestCase;
* Class DialogsTest * Class DialogsTest
* *
* @package RetailCrm\Mg\Bot\Tests * @package RetailCrm\Mg\Bot\Tests
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License * @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers * @link http://help.retailcrm.pro/docs/Developers
*/ */
class DialogsTest extends TestCase class DialogsTest extends TestCase
{ {