1
0
mirror of synced 2024-11-22 03:46:02 +03:00

Better structure

This commit is contained in:
Pavel 2019-06-14 12:48:13 +03:00
parent 1a07ae9fe8
commit 78f1675080
52 changed files with 1499 additions and 2824 deletions

View File

@ -19,7 +19,8 @@
"symfony/validator": "^4.2", "symfony/validator": "^4.2",
"doctrine/annotations": "^1.6", "doctrine/annotations": "^1.6",
"doctrine/cache": "^1.8", "doctrine/cache": "^1.8",
"guzzlehttp/guzzle": "6.0" "guzzlehttp/guzzle": "6.0",
"lazyjsonmapper/lazyjsonmapper": "^1.6"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "6.5.*", "phpunit/phpunit": "6.5.*",

94
composer.lock generated
View File

@ -4,8 +4,50 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "eecd765e939fea19d4d181bafd7384a2", "content-hash": "acac73ae68db3b7df3284c70aa591bbd",
"packages": [ "packages": [
{
"name": "corneltek/getoptionkit",
"version": "2.6.0",
"source": {
"type": "git",
"url": "https://github.com/c9s/GetOptionKit.git",
"reference": "995607ddf4fc90ebdb4a7d58fe972d581ad8495f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/c9s/GetOptionKit/zipball/995607ddf4fc90ebdb4a7d58fe972d581ad8495f",
"reference": "995607ddf4fc90ebdb4a7d58fe972d581ad8495f",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.6.x-dev"
}
},
"autoload": {
"psr-4": {
"GetOptionKit\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Yo-An Lin",
"email": "yoanlin93@gmail.com"
}
],
"description": "Powerful command-line option toolkit",
"homepage": "http://github.com/c9s/GetOptionKit",
"time": "2017-06-30T14:54:48+00:00"
},
{ {
"name": "doctrine/annotations", "name": "doctrine/annotations",
"version": "v1.6.1", "version": "v1.6.1",
@ -613,6 +655,56 @@
], ],
"time": "2018-07-25T13:58:54+00:00" "time": "2018-07-25T13:58:54+00:00"
}, },
{
"name": "lazyjsonmapper/lazyjsonmapper",
"version": "v1.6.3",
"source": {
"type": "git",
"url": "https://github.com/lazyjsonmapper/lazyjsonmapper.git",
"reference": "51e093b50f4de15d2d64548b3ca743713eed6ee9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/lazyjsonmapper/lazyjsonmapper/zipball/51e093b50f4de15d2d64548b3ca743713eed6ee9",
"reference": "51e093b50f4de15d2d64548b3ca743713eed6ee9",
"shasum": ""
},
"require": {
"corneltek/getoptionkit": "2.*",
"php": ">=5.6"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.7.1",
"phpunit/phpunit": "6.*"
},
"bin": [
"bin/lazydoctor"
],
"type": "library",
"autoload": {
"psr-4": {
"LazyJsonMapper\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"authors": [
{
"name": "SteveJobzniak",
"homepage": "https://github.com/SteveJobzniak",
"role": "Developer"
}
],
"description": "Advanced, intelligent & automatic object-oriented JSON containers for PHP.",
"homepage": "https://github.com/SteveJobzniak/LazyJsonMapper",
"keywords": [
"development",
"json"
],
"time": "2018-05-02T16:57:09+00:00"
},
{ {
"name": "phpcollection/phpcollection", "name": "phpcollection/phpcollection",
"version": "0.5.0", "version": "0.5.0",

View File

@ -13,16 +13,12 @@
namespace RetailCrm\Mg\Bot; namespace RetailCrm\Mg\Bot;
use RetailCrm\Common\Deserializer;
use RetailCrm\Common\Exception\CurlException;
use RetailCrm\Common\Exception\InvalidJsonException; 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\Model\Response\AssignResponse; use RetailCrm\Mg\Bot\Model\Response\AssignResponse;
use RetailCrm\Mg\Bot\Model\Response\GenericListResponse;
use RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse; use RetailCrm\Mg\Bot\Model\Response\ErrorOnlyResponse;
use Exception; use RetailCrm\Mg\Bot\Model\Response\ListResponse;
use InvalidArgumentException;
use RetailCrm\Mg\Bot\Model\Response\MessageSendResponse; use RetailCrm\Mg\Bot\Model\Response\MessageSendResponse;
/** /**
@ -38,12 +34,11 @@ use RetailCrm\Mg\Bot\Model\Response\MessageSendResponse;
class Client class Client
{ {
const VERSION = 'v1'; const VERSION = 'v1';
const ERROR_ONLY_RESPONSE = 'ErrorOnlyResponse';
const ENTITY_CLASSPATH = 'RetailCrm\\Mg\\Bot\\Model\\Entity\\'; /**
const RESPONSE_MODEL_CLASSPATH = 'RetailCrm\\Mg\\Bot\\Model\\Response\\'; * @var HttpClient
const GENERIC_LIST_RESPONSE = self::RESPONSE_MODEL_CLASSPATH . 'GenericListResponse'; */
const ERROR_ONLY_RESPONSE = self::RESPONSE_MODEL_CLASSPATH . 'ErrorOnlyResponse';
protected $client; protected $client;
/** /**
@ -65,18 +60,18 @@ class Client
* @param object $request * @param object $request
* @param string $responseType * @param string $responseType
* @param int $serializeTo * @param int $serializeTo
* @param string $deserializeType * @param bool $arrayOfObjects
* *
* @return object|null * @return object|array|null
* @throws \Exception * @throws \Exception
*/ */
private function getData( private function getData(
$path, $path,
$method, $method,
$request, $request,
$responseType = self::GENERIC_LIST_RESPONSE, $responseType,
$serializeTo = Serializer::S_JSON, $serializeTo = Serializer::S_JSON,
$deserializeType = Deserializer::DS_JSON $arrayOfObjects = false
) { ) {
$response = $this->client->makeRequest( $response = $this->client->makeRequest(
$path, $path,
@ -85,11 +80,54 @@ class Client
$serializeTo $serializeTo
); );
return Deserializer::deserialize( $data = json_decode((string) $response->getBody(), true);
(string) $response->getBody(),
$responseType, if (json_last_error() == JSON_ERROR_NONE) {
$deserializeType if ($arrayOfObjects) {
); return new ListResponse($responseType, $data);
} else {
return new $responseType($data);
}
} else {
throw new InvalidJsonException('Received invalid JSON', 1);
}
}
/**
* @param bool $fromRoot
* @param string ...$classes
*
* @return string
*/
private static function concatClasspath($fromRoot, ...$classes)
{
$path = $fromRoot ? '\\' : '';
foreach($classes as $class) {
$path .= '\\' . $class;
}
return str_replace('\\\\', '\\', $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);
} }
/** /**
@ -97,12 +135,8 @@ class Client
* *
* @param Model\Request\BotsRequest $request * @param Model\Request\BotsRequest $request
* *
* @throws InvalidArgumentException * @return ListResponse|object|null
* @throws CurlException * @throws \Exception
* @throws InvalidJsonException
* @throws Exception
*
* @return array
*/ */
public function bots(Model\Request\BotsRequest $request) public function bots(Model\Request\BotsRequest $request)
{ {
@ -110,8 +144,9 @@ class Client
'/bots', '/bots',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
self::GENERIC_LIST_RESPONSE, static::getEntityClass('Bot', 'Bot'),
Serializer::S_ARRAY Serializer::S_ARRAY,
true
); );
} }
@ -120,16 +155,17 @@ class Client
* *
* @param Model\Request\InfoRequest $request * @param Model\Request\InfoRequest $request
* *
* @throws InvalidArgumentException
* @throws CurlException
* @throws CurlException
* @throws Exception
*
* @return ErrorOnlyResponse|object|null * @return ErrorOnlyResponse|object|null
* @throws \Exception
*/ */
public function info(Model\Request\InfoRequest $request) public function info(Model\Request\InfoRequest $request)
{ {
return $this->getData('/my/info', HttpClient::METHOD_PATCH, $request, self::ERROR_ONLY_RESPONSE); return $this->getData(
'/my/info',
HttpClient::METHOD_PATCH,
$request,
static::getResponseClass(self::ERROR_ONLY_RESPONSE)
);
} }
/** /**
@ -137,16 +173,18 @@ class Client
* *
* @param Model\Request\ChannelsRequest $request * @param Model\Request\ChannelsRequest $request
* *
* @return array|object|null * @return ListResponse|object|null
* @throws \Exception * @throws \Exception
*/ */
public function channels(Model\Request\ChannelsRequest $request) public function channels(Model\Request\ChannelsRequest $request)
{ {
return $this->getData( return $this->getData(
'/channels', '/channels',
HttpClient::METHOD_GET, $request, HttpClient::METHOD_GET,
\sprintf("array<%s%s>", self::ENTITY_CLASSPATH, 'Channel\\Channel'), $request,
Serializer::S_ARRAY static::getEntityClass('Channel', 'Channel'),
Serializer::S_ARRAY,
true
); );
} }
@ -155,12 +193,8 @@ class Client
* *
* @param Model\Request\ChatsRequest $request * @param Model\Request\ChatsRequest $request
* *
* @throws InvalidArgumentException * @return ListResponse|object|null
* @throws CurlException * @throws \Exception
* @throws InvalidJsonException
* @throws Exception
*
* @return GenericListResponse|object|null
*/ */
public function chats(Model\Request\ChatsRequest $request) public function chats(Model\Request\ChatsRequest $request)
{ {
@ -168,8 +202,9 @@ class Client
'/chats', '/chats',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
self::GENERIC_LIST_RESPONSE, static::getEntityClass('Chat', 'Chat'),
Serializer::S_ARRAY Serializer::S_ARRAY,
true
); );
} }
@ -178,20 +213,18 @@ class Client
* *
* @param Model\Request\CommandsRequest $request * @param Model\Request\CommandsRequest $request
* *
* @throws InvalidArgumentException * @return ListResponse|object|null
* @throws CurlException * @throws \Exception
* @throws InvalidJsonException
* @throws Exception
*
* @return GenericListResponse|object|null
*/ */
public function commands(Model\Request\CommandsRequest $request) public function commands(Model\Request\CommandsRequest $request)
{ {
return $this->getData( return $this->getData(
'/my/commands', '/my/commands',
HttpClient::METHOD_GET, $request, HttpClient::METHOD_GET,
self::GENERIC_LIST_RESPONSE, $request,
Serializer::S_ARRAY static::getEntityClass('Command'),
Serializer::S_ARRAY,
true
); );
} }
@ -200,12 +233,8 @@ class Client
* *
* @param Model\Request\CommandEditRequest $request * @param Model\Request\CommandEditRequest $request
* *
* @throws InvalidArgumentException
* @throws CurlException
* @throws InvalidJsonException
* @throws Exception
*
* @return ErrorOnlyResponse|object|null * @return ErrorOnlyResponse|object|null
* @throws \Exception
*/ */
public function commandEdit(Model\Request\CommandEditRequest $request) public function commandEdit(Model\Request\CommandEditRequest $request)
{ {
@ -213,7 +242,8 @@ class Client
sprintf("/my/commands/%s", $request->getName()), sprintf("/my/commands/%s", $request->getName()),
HttpClient::METHOD_PUT, HttpClient::METHOD_PUT,
$request, $request,
self::ERROR_ONLY_RESPONSE static::getResponseClass(self::ERROR_ONLY_RESPONSE),
true
); );
} }
@ -222,21 +252,17 @@ class Client
* *
* @param string $request * @param string $request
* *
* @throws InvalidArgumentException
* @throws CurlException
* @throws InvalidJsonException
* @throws Exception
*
* @return ErrorOnlyResponse|object|null * @return ErrorOnlyResponse|object|null
* @throws \Exception
*/ */
public function commandDelete(string $request) public function commandDelete(string $request)
{ {
$response = $this->client->makeRequest(sprintf("/my/commands/%s", $request), HttpClient::METHOD_DELETE); return $this->getData(
sprintf("/my/commands/%s", $request),
return Deserializer::deserialize( HttpClient::METHOD_DELETE,
$response->getResponse(), null,
self::ERROR_ONLY_RESPONSE, static::getResponseClass(self::ERROR_ONLY_RESPONSE),
Deserializer::DS_ARRAY Serializer::S_JSON
); );
} }
@ -245,12 +271,8 @@ class Client
* *
* @param Model\Request\CustomersRequest $request * @param Model\Request\CustomersRequest $request
* *
* @throws InvalidArgumentException * @return ListResponse|object|null
* @throws CurlException * @throws \Exception
* @throws InvalidJsonException
* @throws Exception
*
* @return GenericListResponse|object|null
*/ */
public function customers(Model\Request\CustomersRequest $request) public function customers(Model\Request\CustomersRequest $request)
{ {
@ -258,8 +280,9 @@ class Client
'/customers', '/customers',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
self::GENERIC_LIST_RESPONSE, static::getEntityClass('Customer'),
Serializer::S_ARRAY Serializer::S_ARRAY,
true
); );
} }
@ -268,12 +291,8 @@ class Client
* *
* @param Model\Request\DialogsRequest $request * @param Model\Request\DialogsRequest $request
* *
* @throws InvalidArgumentException * @return ListResponse|object|null
* @throws CurlException * @throws \Exception
* @throws InvalidJsonException
* @throws Exception
*
* @return GenericListResponse|object|null
*/ */
public function dialogs(Model\Request\DialogsRequest $request) public function dialogs(Model\Request\DialogsRequest $request)
{ {
@ -281,8 +300,9 @@ class Client
'/dialogs', '/dialogs',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
self::GENERIC_LIST_RESPONSE, static::getEntityClass('Dialog'),
Serializer::S_ARRAY Serializer::S_ARRAY,
true
); );
} }
@ -291,12 +311,8 @@ class Client
* *
* @param Model\Request\DialogAssignRequest $request * @param Model\Request\DialogAssignRequest $request
* *
* @throws InvalidArgumentException
* @throws CurlException
* @throws InvalidJsonException
* @throws Exception
*
* @return AssignResponse|object|null * @return AssignResponse|object|null
* @throws \Exception
*/ */
public function dialogAssign(Model\Request\DialogAssignRequest $request) public function dialogAssign(Model\Request\DialogAssignRequest $request)
{ {
@ -304,7 +320,8 @@ class Client
sprintf("/dialogs/%d/assign", $request->getDialogId()), sprintf("/dialogs/%d/assign", $request->getDialogId()),
HttpClient::METHOD_PATCH, HttpClient::METHOD_PATCH,
$request, $request,
self::RESPONSE_MODEL_CLASSPATH . 'AssignResponse' static::getResponseClass('AssignResponse'),
Serializer::S_JSON
); );
} }
@ -313,12 +330,8 @@ class Client
* *
* @param string $request * @param string $request
* *
* @throws InvalidArgumentException
* @throws CurlException
* @throws InvalidJsonException
* @throws Exception
*
* @return ErrorOnlyResponse|object|null * @return ErrorOnlyResponse|object|null
* @throws \Exception
*/ */
public function dialogClose(string $request) public function dialogClose(string $request)
{ {
@ -326,7 +339,7 @@ class Client
sprintf("/dialogs/%d/close", $request), sprintf("/dialogs/%d/close", $request),
HttpClient::METHOD_DELETE, HttpClient::METHOD_DELETE,
null, null,
self::ERROR_ONLY_RESPONSE static::getResponseClass(self::ERROR_ONLY_RESPONSE)
); );
} }
@ -335,12 +348,8 @@ class Client
* *
* @param Model\Request\MembersRequest $request * @param Model\Request\MembersRequest $request
* *
* @throws InvalidArgumentException * @return ListResponse|object|null
* @throws CurlException * @throws \Exception
* @throws InvalidJsonException
* @throws Exception
*
* @return GenericListResponse|object|null
*/ */
public function members(Model\Request\MembersRequest $request) public function members(Model\Request\MembersRequest $request)
{ {
@ -348,8 +357,9 @@ class Client
'/members', '/members',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
self::GENERIC_LIST_RESPONSE, static::getEntityClass('Chat', 'ChatMember'),
Serializer::S_ARRAY Serializer::S_ARRAY,
true
); );
} }
@ -358,12 +368,8 @@ class Client
* *
* @param Model\Request\MessagesRequest $request * @param Model\Request\MessagesRequest $request
* *
* @throws InvalidArgumentException * @return ListResponse|object|null
* @throws CurlException * @throws \Exception
* @throws InvalidJsonException
* @throws Exception
*
* @return GenericListResponse|object|null
*/ */
public function messages(Model\Request\MessagesRequest $request) public function messages(Model\Request\MessagesRequest $request)
{ {
@ -371,8 +377,9 @@ class Client
'/messages', '/messages',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
self::GENERIC_LIST_RESPONSE, self::getEntityClass('Message', 'Message'),
Serializer::S_ARRAY Serializer::S_ARRAY,
true
); );
} }
@ -381,12 +388,8 @@ class Client
* *
* @param Model\Request\MessageSendRequest $request * @param Model\Request\MessageSendRequest $request
* *
* @throws InvalidArgumentException
* @throws CurlException
* @throws InvalidJsonException
* @throws Exception
*
* @return MessageSendResponse|object|null * @return MessageSendResponse|object|null
* @throws \Exception
*/ */
public function messageSend(Model\Request\MessageSendRequest $request) public function messageSend(Model\Request\MessageSendRequest $request)
{ {
@ -394,7 +397,7 @@ class Client
'/messages', '/messages',
HttpClient::METHOD_POST, HttpClient::METHOD_POST,
$request, $request,
self::RESPONSE_MODEL_CLASSPATH . 'MessageSendResponse' static::getResponseClass('MessageSendResponse')
); );
} }
@ -403,12 +406,8 @@ class Client
* *
* @param Model\Request\MessageEditRequest $request * @param Model\Request\MessageEditRequest $request
* *
* @throws InvalidArgumentException
* @throws CurlException
* @throws InvalidJsonException
* @throws Exception
*
* @return MessageSendResponse|object|null * @return MessageSendResponse|object|null
* @throws \Exception
*/ */
public function messageEdit(Model\Request\MessageEditRequest $request) public function messageEdit(Model\Request\MessageEditRequest $request)
{ {
@ -416,7 +415,7 @@ class Client
sprintf("/messages/%d", $request->getId()), sprintf("/messages/%d", $request->getId()),
HttpClient::METHOD_PATCH, HttpClient::METHOD_PATCH,
$request, $request,
self::RESPONSE_MODEL_CLASSPATH . 'MessageSendResponse' static::getResponseClass('MessageSendResponse')
); );
} }
@ -425,12 +424,8 @@ class Client
* *
* @param string $request * @param string $request
* *
* @throws InvalidArgumentException
* @throws CurlException
* @throws InvalidJsonException
* @throws Exception
*
* @return ErrorOnlyResponse|object|null * @return ErrorOnlyResponse|object|null
* @throws \Exception
*/ */
public function messageDelete(string $request) public function messageDelete(string $request)
{ {
@ -438,7 +433,7 @@ class Client
sprintf("/messages/%d", $request), sprintf("/messages/%d", $request),
HttpClient::METHOD_DELETE, HttpClient::METHOD_DELETE,
null, null,
self::ERROR_ONLY_RESPONSE static::getResponseClass(self::ERROR_ONLY_RESPONSE)
); );
} }
@ -447,12 +442,8 @@ class Client
* *
* @param Model\Request\UsersRequest $request * @param Model\Request\UsersRequest $request
* *
* @throws InvalidArgumentException * @return ListResponse|object|null
* @throws CurlException * @throws \Exception
* @throws InvalidJsonException
* @throws Exception
*
* @return GenericListResponse|object|null
*/ */
public function users(Model\Request\UsersRequest $request) public function users(Model\Request\UsersRequest $request)
{ {
@ -460,8 +451,9 @@ class Client
'/users', '/users',
HttpClient::METHOD_GET, HttpClient::METHOD_GET,
$request, $request,
self::GENERIC_LIST_RESPONSE, self::getEntityClass('User'),
Serializer::S_ARRAY Serializer::S_ARRAY,
true
); );
} }
} }

View File

@ -0,0 +1,60 @@
<?php
/**
* PHP version 7.0
*
* Bot entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Bot
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity\Bot;
use RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/**
* PHP version 7.0
*
* Bot class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Bot
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method string getName()
* @method $this setName(string $value)
* @method array getEvents()
* @method $this setEvents(array $value)
* @method string getClientId()
* @method $this setClientId(string $value)
* @method string getAvatarUrl()
* @method $this setAvatarUrl(string $value)
* @method array getRoles()
* @method $this setRoles(array $value)
* @method string getDeactivatedAt()
* @method $this setDeactivatedAt(string $value)
* @method bool getIsActive()
* @method $this setIsActive(bool $value)
* @method bool getIsSelf()
* @method $this setIsSelf(bool $value)
* @method bool getIsSystem()
* @method $this setIsSystem(bool $value)
*/
class Bot extends CommonFields
{
const JSON_PROPERTY_MAP = [
'name' => 'string',
'events' => '[]',
'client_id' => 'string',
'avatar_url' => 'string',
'roles' => '[]',
'deactivated_at' => 'string',
'is_active' => 'bool',
'is_self' => 'bool',
'is_system' => 'bool'
];
}

View File

@ -5,7 +5,7 @@
* *
* Channel entity * Channel entity
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @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
@ -13,12 +13,6 @@
namespace RetailCrm\Mg\Bot\Model\Entity\Channel; namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\SerializedName;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelSettings;
use RetailCrm\Mg\Bot\Model\Entity\CommonFields; use RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/** /**
@ -26,159 +20,32 @@ use RetailCrm\Mg\Bot\Model\Entity\CommonFields;
* *
* Channel class * Channel class
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @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
*
* @method string getActivatedAt()
* @method $this setActivatedAt(string $value)
* @method string getDeactivatedAt()
* @method $this setDeactivatedAt(string $value)
* @method bool getIsActive(bool $value)
* @method $this setIsActive()
* @method ChannelSettings getChannelSettings()
* @method $this setChannelSettings(ChannelSettings $value)
* @method string getType()
* @method $this setType(string $value)
* @method string getName()
* @method $this setName(string $value)
*/ */
class Channel class Channel extends CommonFields
{ {
use CommonFields; const JSON_PROPERTY_MAP = [
'activated_at' => 'string',
/** 'deactivated_at' => 'string',
* @var \DateTime 'is_active' => 'bool',
* 'settings' => 'ChannelSettings',
* @Type("DateTime<'Y-m-d\TH:i:s.u\Z'>") 'type' => 'string',
* @Accessor(setter="setActivatedAt", getter="getActivatedAt") 'name' => 'string'
*/ ];
private $activatedAt;
/**
* @var \DateTime
*
* @Type("DateTime<'Y-m-d\TH:i:s.u\Z'>")
* @Accessor(setter="setDeactivatedAt", getter="getDeactivatedAt")
* @SkipWhenEmpty()
*/
private $deactivatedAt;
/**
* @var bool
*
* @Type("bool")
* @Accessor(setter="getIsActive", getter="setIsActive")
* @SerializedName("is_active")
*/
private $isActive;
/**
* @var array
*
* @Type("array")
* @Accessor(setter="setSettings", getter="getSettings")
*/
private $settings;
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setType", getter="getType")
*/
private $type;
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setName", getter="getName")
* @SkipWhenEmpty()
*/
private $name;
/**
* @return \DateTime
*/
public function getActivatedAt(): \DateTime
{
return $this->activatedAt;
}
/**
* @param \DateTime $activatedAt
*/
public function setActivatedAt(\DateTime $activatedAt)
{
$this->activatedAt = $activatedAt;
}
/**
* @return \DateTime
*/
public function getDeactivatedAt(): \DateTime
{
return $this->deactivatedAt;
}
/**
* @param \DateTime $deactivatedAt
*/
public function setDeactivatedAt($deactivatedAt)
{
$this->deactivatedAt = $deactivatedAt;
}
/**
* @return bool
*/
public function getIsActive()
{
return $this->isActive;
}
/**
* @param bool $isActive
*/
public function setIsActive(bool $isActive)
{
$this->isActive = $isActive;
}
/**
* @return array
*/
public function getSettings(): array
{
return $this->settings;
}
/**
* @param array $settings
*/
public function setSettings(array $settings)
{
$this->settings = $settings;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName($name)
{
$this->name = $name;
}
} }

View File

@ -1,126 +0,0 @@
<?php
/**
* PHP version 7.0
*
* ChannelProductSettings 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\Channel;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* ChannelProductSettings 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 ChannelProductSettings
{
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setCreating", getter="getCreating")
*/
private $creating;
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setEditing", getter="getEditing")
*/
private $editing;
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setDeleting", getter="getDeleting")
*/
private $deleting;
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setQuoting", getter="getQuoting")
*/
private $quoting;
/**
* @return string
*/
public function getCreating(): string
{
return $this->creating;
}
/**
* @param string $creating
*/
public function setCreating(string $creating)
{
$this->creating = $creating;
}
/**
* @return string
*/
public function getEditing(): string
{
return $this->editing;
}
/**
* @param string $editing
*/
public function setEditing(string $editing)
{
$this->editing = $editing;
}
/**
* @return string
*/
public function getDeleting(): string
{
return $this->deleting;
}
/**
* @param string $deleting
*/
public function setDeleting(string $deleting)
{
$this->deleting = $deleting;
}
/**
* @return string
*/
public function getQuoting(): string
{
return $this->quoting;
}
/**
* @param string $quoting
*/
public function setQuoting(string $quoting)
{
$this->quoting = $quoting;
}
}

View File

@ -5,7 +5,7 @@
* *
* ChannelSettings entity * ChannelSettings entity
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @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
@ -13,92 +13,39 @@
namespace RetailCrm\Mg\Bot\Model\Entity\Channel; namespace RetailCrm\Mg\Bot\Model\Entity\Channel;
use JMS\Serializer\Annotation as Serializer; use LazyJsonMapper\LazyJsonMapper;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/** /**
* PHP version 7.0 * PHP version 7.0
* *
* ChannelSettings class * ChannelSettings class
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @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
*
* @method ChannelSettingsItem getStatus()
* @method $this setStatus(ChannelSettingsItem $value)
* @method ChannelSettingsItem getText()
* @method $this setText(ChannelSettingsItem $value)
* @method ChannelSettingsItem getProduct()
* @method $this setProduct(ChannelSettingsItem $value)
* @method ChannelSettingsItem getOrder()
* @method $this setOrder(ChannelSettingsItem $value)
* @method ChannelSettingsItem getImage()
* @method $this setImage(ChannelSettingsItem $value)
* @method ChannelSettingsItem getFile()
* @method $this setFile(ChannelSettingsItem $value)
*/ */
class ChannelSettings class ChannelSettings extends LazyJsonMapper
{ {
/** const JSON_PROPERTY_MAP = [
* @var int 'status' => 'ChannelSettingsItem',
* 'text' => 'ChannelSettingsItem',
* @Type("int") 'product' => 'ChannelSettingsItem',
* @Accessor(setter="setSpamAllowed", getter="getSpamAllowed") 'order' => 'ChannelSettingsItem',
*/ 'image' => 'ChannelSettingsItem',
private $spamAllowed; 'file' => 'ChannelSettingsItem'
];
/**
* @var ChannelSettingsStatus
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelSettingsStatus")
* @Accessor(setter="setStatus", getter="getStatus")
*/
private $status;
/**
* @var ChannelTextSettings
*
* @Type("RetailCrm\Mg\Bot\Model\Entity\Channel\ChannelTextSettings")
* @Accessor(setter="setText", getter="getText")
*/
private $text;
/**
* @return int
*/
public function getSpamAllowed(): int
{
return $this->spamAllowed;
}
/**
* @param int $spamAllowed
*/
public function setSpamAllowed(int $spamAllowed)
{
$this->spamAllowed = $spamAllowed;
}
/**
* @return ChannelSettingsStatus
*/
public function getStatus(): ChannelSettingsStatus
{
return $this->status;
}
/**
* @param ChannelSettingsStatus $status
*/
public function setStatus(ChannelSettingsStatus $status)
{
$this->status = $status;
}
/**
* @return ChannelTextSettings
*/
public function getText(): ChannelTextSettings
{
return $this->text;
}
/**
* @param ChannelTextSettings $text
*/
public function setText(ChannelTextSettings $text)
{
$this->text = $text;
}
} }

View File

@ -0,0 +1,55 @@
<?php
/**
* PHP version 7.0
*
* ChannelSettingsItem entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @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\Channel;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use LazyJsonMapper\LazyJsonMapper;
/**
* PHP version 7.0
*
* ChannelSettingsItem class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Channel
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method string getCreating()
* @method $this setCreating(string $value)
* @method string getEditing()
* @method $this setEditing(string $value)
* @method string getQuoting()
* @method $this setQuoting(string $value)
* @method string getDeleting()
* @method $this setDeleting(string $value)
* @method string getDelivered()
* @method $this setDelivered(string $value)
* @method int getMaxItemsCount()
* @method $this setMaxItemsCount(int $value)
*/
class ChannelSettingsItem extends LazyJsonMapper
{
const JSON_PROPERTY_MAP = [
'creating' => 'string',
'editing' => 'string',
'quoting' => 'string',
'deleting' => 'string',
'delivered' => 'string',
'max_items_count' => 'int'
];
}

View File

@ -1,78 +0,0 @@
<?php
/**
* PHP version 7.0
*
* ChannelSettingsStatus 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\Channel;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* ChannelSettingsStatus 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 ChannelSettingsStatus
{
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setDelivered", getter="getDelivered")
*/
private $delivered;
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setRead", getter="getRead")
*/
private $read;
/**
* @return string
*/
public function getDelivered(): string
{
return $this->delivered;
}
/**
* @param string $delivered
*/
public function setDelivered(string $delivered)
{
$this->delivered = $delivered;
}
/**
* @return string
*/
public function getRead(): string
{
return $this->read;
}
/**
* @param string $read
*/
public function setRead(string $read)
{
$this->read = $read;
}
}

View File

@ -1,126 +0,0 @@
<?php
/**
* PHP version 7.0
*
* ChannelTextSettings 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\Channel;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* ChannelTextSettings 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 ChannelTextSettings
{
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setCreating", getter="getCreating")
*/
private $creating;
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setEditing", getter="getEditing")
*/
private $editing;
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setDeleting", getter="getDeleting")
*/
private $deleting;
/**
* @var string
*
* @Type("string")
* @Accessor(setter="setQuoting", getter="getQuoting")
*/
private $quoting;
/**
* @return string
*/
public function getCreating(): string
{
return $this->creating;
}
/**
* @param string $creating
*/
public function setCreating(string $creating)
{
$this->creating = $creating;
}
/**
* @return string
*/
public function getEditing(): string
{
return $this->editing;
}
/**
* @param string $editing
*/
public function setEditing(string $editing)
{
$this->editing = $editing;
}
/**
* @return string
*/
public function getDeleting(): string
{
return $this->deleting;
}
/**
* @param string $deleting
*/
public function setDeleting(string $deleting)
{
$this->deleting = $deleting;
}
/**
* @return string
*/
public function getQuoting(): string
{
return $this->quoting;
}
/**
* @param string $quoting
*/
public function setQuoting(string $quoting)
{
$this->quoting = $quoting;
}
}

View File

@ -0,0 +1,41 @@
<?php
/**
* PHP version 7.0
*
* Chat entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @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\Chat;
use RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/**
* PHP version 7.0
*
* Chat class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
*/
class Chat extends CommonFields
{
const JSON_PROPERTY_MAP = [
'avatar' => 'string',
'name' => 'string',
'channel' => '\RetailCrm\Mg\Bot\Model\Entity\Channel\Channel',
'members' => 'ChatMember[]',
'customer' => '\RetailCrm\Mg\Bot\Model\Entity\Customer',
'author_id' => 'int',
'last_message' => 'ChatLastMessage',
'last_activity' => 'string'
];
}

View File

@ -0,0 +1,43 @@
<?php
/**
* PHP version 7.0
*
* ChatLastMessage entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @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\Chat;
use LazyJsonMapper\LazyJsonMapper;
/**
* PHP version 7.0
*
* ChatLastMessage class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method int getId()
* @method $this setId(int $value)
* @method string getTime()
* @method $this setTime(string $value)
* @method string getType()
* @method $this setType(string $value)
*/
class ChatLastMessage extends LazyJsonMapper
{
const JSON_PROPERTY_MAP = [
'id' => 'int',
'time' => 'string',
'type' => 'string'
];
}

View File

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.0
*
* ChatMember entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @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\Chat;
use RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/**
* PHP version 7.0
*
* ChatMember class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Chat
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method int getChatId()
* @method $this setChatId(int $value)
* @method int getUserId()
* @method $this setUserId(int $value)
* @method bool getIsAuthor()
* @method $this setIsAuthor(bool $value)
* @method string getState()
* @method $this setState(string $value)
*/
class ChatMember extends CommonFields
{
const JSON_PROPERTY_MAP = [
'chat_id' => 'int',
'user_id' => 'int',
'is_author' => 'bool',
'state' => 'string'
];
}

View File

@ -0,0 +1,37 @@
<?php
/**
* PHP version 7.0
*
* Command 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;
/**
* PHP version 7.0
*
* Command 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
*
* @method string getName()
* @method $this setName(string $value)
* @method string getDescription()
* @method $this setDescription(string $value)
*/
class Command extends CommonFields
{
const JSON_PROPERTY_MAP = [
'name' => 'string',
'description' => 'string'
];
}

View File

@ -16,6 +16,7 @@ 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 LazyJsonMapper\LazyJsonMapper;
/** /**
* PHP version 7.0 * PHP version 7.0
@ -27,80 +28,11 @@ 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
*/ */
trait CommonFields class CommonFields extends LazyJsonMapper
{ {
/** const JSON_PROPERTY_MAP = [
* @var int 'id' => 'int',
* 'created_at' => 'string',
* @Type("int") 'updated_at' => 'string'
* @Accessor(setter="setId", getter="getId") ];
* @SkipWhenEmpty()
*/
private $id;
/**
* @var DateTime
*
* @Type("DateTime<'Y-m-d\TH:i:s.u\Z'>")
* @Accessor(setter="setCreatedAt", getter="getCreatedAt")
* @SkipWhenEmpty()
*/
private $createdAt;
/**
* @var string
*
* @Type("DateTime<'Y-m-d\TH:i:s.u\Z'>")
* @Accessor(setter="setUpdatedAt", getter="getUpdatedAt")
* @SkipWhenEmpty()
*/
private $updatedAt;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id)
{
$this->id = $id;
}
/**
* @return \DateTime
*/
public function getCreatedAt(): \DateTime
{
return $this->createdAt;
}
/**
* @param \DateTime $createdAt
*/
public function setCreatedAt(\DateTime $createdAt)
{
$this->createdAt = $createdAt;
}
/**
* @return \DateTime
*/
public function getUpdatedAt(): \DateTime
{
return $this->updatedAt;
}
/**
* @param \DateTime $updatedAt
*/
public function setUpdatedAt(\DateTime $updatedAt)
{
$this->updatedAt = $updatedAt;
}
} }

View File

@ -1,82 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Cost entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* Cost class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Cost
{
/**
* @var float $value
*
* @Type("float")
* @Accessor(getter="getValue",setter="setValue")
* @SkipWhenEmpty()
*/
private $value;
/**
* @var string $currency
*
* @Type("string")
* @Accessor(getter="getCurrency",setter="setCurrency")
*
* @Assert\Currency
*/
private $currency;
/**
* @return float
*/
public function getValue()
{
return $this->value;
}
/**
* @param float $value
*/
public function setValue(float $value)
{
$this->value = $value;
}
/**
* @return string
*/
public function getCurrency()
{
return $this->currency;
}
/**
* @param string $currency
*/
public function setCurrency(string $currency)
{
$this->currency = $currency;
}
}

View File

@ -0,0 +1,69 @@
<?php
/**
* PHP version 7.0
*
* Customer 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 RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/**
* PHP version 7.0
*
* Customer 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
*
* @method string getExternalId()
* @method $this setExternalId(string $value)
* @method int getChannelId()
* @method $this setChannelId(int $value)
* @method string getUsername()
* @method $this setUsername(string $value)
* @method string getFirstName()
* @method $this setFirstName(string $value)
* @method string getLastName()
* @method $this setLastName(string $value)
* @method string getAvatarUrl()
* @method $this setAvatarUrl(string $value)
* @method string getProfileUrl()
* @method $this setProfileUrl(string $value)
* @method string getRevokedAt()
* @method $this setRevokedAt(string $value)
* @method string getCountry()
* @method $this setCountry(string $value)
* @method string getLanguage()
* @method $this setLanguage(string $value)
* @method string getPhone()
* @method $this setPhone(string $value)
* @method string getEmail()
* @method $this setEmail(string $value)
*/
class Customer extends CommonFields
{
const JSON_PROPERTY_MAP = [
'external_id' => 'string',
'channel_id' => 'int',
'username' => 'string',
'first_name' => 'string',
'last_name' => 'string',
'avatar_url' => 'string',
'profile_url' => 'string',
'revoked_at' => 'string',
'country' => 'string',
'language' => 'string',
'phone' => 'string',
'email' => 'string'
];
}

View File

@ -1,133 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Delivery entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* Delivery class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Delivery
{
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
*
* @Assert\NotBlank
*/
private $name;
/**
* @var 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

@ -0,0 +1,57 @@
<?php
/**
* PHP version 7.0
*
* Dialog 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 RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/**
* PHP version 7.0
*
* Dialog 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
*
* @method int getBotId()
* @method $this setBotId(int $value)
* @method int getChatId()
* @method $this setChatId(int $value)
* @method int getBeginMessageId()
* @method $this setBeginMessageId(int $value)
* @method int getEndingMessageId()
* @method $this setEndingMessageId(int $value)
* @method string getClosedAt()
* @method $this setClosedAt(string $value)
* @method bool getIsAssigned()
* @method $this setIsAssigned(bool $value)
* @method Responsible getResponsible()
* @method $this setResponsible(Responsible $value)
* @method bool getIsActive()
* @method $this setIsActive(bool $value)
*/
class Dialog extends CommonFields
{
const JSON_PROPERTY_MAP = [
'bot_id' => 'int',
'chat_id' => 'int',
'begin_message_id' => 'int',
'ending_message_id' => 'int',
'closed_at' => 'string',
'is_assigned' => 'bool',
'responsible' => 'Responsible',
'is_active' => 'bool'
];
}

View File

@ -1,56 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Error 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 as Serializer;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* Error 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 Error
{
/**
* @var array $messages
*
* @Type("array")
* @Accessor(getter="getMessages",setter="setMessages")
* @Serializer\SkipWhenEmpty()
*/
private $messages;
/**
* @return array
*/
public function getMessages(): array
{
return $this->messages;
}
/**
* @param array $messages
*/
public function setMessages(array $messages)
{
$this->messages = $messages;
}
}

View File

@ -3,7 +3,7 @@
/** /**
* PHP version 7.0 * PHP version 7.0
* *
* Responsible entity * FileMeta entity
* *
* @package RetailCrm\Mg\Bot\Model\Entity * @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru> * @author retailCRM <integration@retailcrm.ru>
@ -13,69 +13,22 @@
namespace RetailCrm\Mg\Bot\Model\Entity; namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\SkipWhenEmpty; use LazyJsonMapper\LazyJsonMapper;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type;
/** /**
* PHP version 7.0 * PHP version 7.0
* *
* Responsible class * FileMeta class
* *
* @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 FileMeta class FileMeta extends LazyJsonMapper
{ {
/** const JSON_PROPERTY_MAP = [
* @var int $height 'height' => 'int',
* 'width' => 'int'
* @Type("int") ];
* @Accessor(setter="setHeight", getter="getHeight")
* @SkipWhenEmpty()
*/
private $height;
/**
* @var int $width
*
* @Type("int")
* @Accessor(setter="setWidth", getter="getWidth")
* @SkipWhenEmpty()
*/
private $width;
/**
* @return int
*/
public function getHeight(): int
{
return $this->height;
}
/**
* @param int $height
*/
public function setHeight(int $height)
{
$this->height = $height;
}
/**
* @return int
*/
public function getWidth(): int
{
return $this->width;
}
/**
* @param int $width
*/
public function setWidth(int $width)
{
$this->width = $width;
}
} }

View File

@ -1,81 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Item entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* Item class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Item
{
/**
* @var string $id
*
* @Type("string")
* @Accessor(getter="getId",setter="setId")
* @SkipWhenEmpty()
*/
private $id;
/**
* @var string $caption
*
* @Type("string")
* @Accessor(getter="getCaption",setter="setCaption")
* @SkipWhenEmpty()
*/
private $caption;
/**
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string $id
*/
public function setId(string $id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getCaption()
{
return $this->caption;
}
/**
* @param string $caption
*/
public function setCaption(string $caption)
{
$this->caption = $caption;
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* PHP version 7.0
*
* Item entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/**
* PHP version 7.0
*
* Item class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method int getId()
* @method $this setId(int $value)
* @method int getSize()
* @method $this setSize(int $value)
* @method string getCaption()
* @method $this setCaption(string $value)
*/
class Item extends CommonFields
{
const JSON_PROPERTY_MAP = [
'id' => 'int',
'size' => 'int',
'caption' => 'string'
];
}

View File

@ -0,0 +1,76 @@
<?php
/**
* PHP version 7.0
*
* Message entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/**
* PHP version 7.0
*
* Message class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method string getTime()
* @method $this setTime(string $value)
* @method string getType()
* @method $this setType(string $value)
* @method string getScope()
* @method $this setScope(string $value)
* @method int getChatId()
* @method $this setChatId(int $value)
* @method string getContent()
* @method $this setContent(string $value)
* @method bool getIsRead()
* @method $this setIsRead(bool $value)
* @method bool getIsEdit()
* @method $this setIsEdit(bool $value)
* @method string getStatus()
* @method $this setStatus(string $value)
* @method string getAction()
* @method $this setAction(string $value)
* @method int getChannelId()
* @method $this setChannelId(int $value)
* @method string getChannelSentAt()
* @method $this setChannelSentAt(string $value)
* @method MessageOrder getOrder()
* @method $this setOrder(MessageOrder $value)
* @method MessageProduct getProduct()
* @method $this setProduct(MessageProduct $value)
*/
class Message extends CommonFields
{
const JSON_PROPERTY_MAP = [
'actions' => '[]',
'items' => 'Item[]',
'from' => '\RetailCrm\Mg\Bot\Model\Entity\User',
'time' => 'string',
'type' => 'string',
'scope' => 'string',
'chat_id' => 'int',
'content' => 'string',
'is_read' => 'bool',
'is_edit' => 'bool',
'status' => 'string',
'action' => 'string',
'dialog' => '\RetailCrm\Mg\Bot\Model\Entity\Dialog',
'channel_id' => 'int',
'channel_sent_at' => 'string',
'order' => 'MessageOrder',
'product' => 'MessageProduct',
];
}

View File

@ -0,0 +1,39 @@
<?php
/**
* PHP version 7.0
*
* MessageCost entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use LazyJsonMapper\LazyJsonMapper;
/**
* PHP version 7.0
*
* MessageCost class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method string getCurrency()
* @method $this setCurrency(string $value)
* @method float getValue()
* @method $this setValue(float $value)
*/
class MessageCost extends LazyJsonMapper
{
const JSON_PROPERTY_MAP = [
'currency' => 'string',
'value' => 'float'
];
}

View File

@ -0,0 +1,45 @@
<?php
/**
* PHP version 7.0
*
* MessageDelivery entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use LazyJsonMapper\LazyJsonMapper;
/**
* PHP version 7.0
*
* MessageDelivery class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method string getAddress()
* @method $this setAddress(string $value)
* @method string getComment()
* @method $this setComment(string $value)
* @method string getName()
* @method $this setName(string $value)
* @method MessageCost getPrice()
* @method $this setPrice(MessageCost $value)
*/
class MessageDelivery extends LazyJsonMapper
{
const JSON_PROPERTY_MAP = [
'address' => 'string',
'comment' => 'string',
'name' => 'string',
'price' => 'MessageCost'
];
}

View File

@ -0,0 +1,50 @@
<?php
/**
* PHP version 7.0
*
* MessageOrder entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use LazyJsonMapper\LazyJsonMapper;
/**
* PHP version 7.0
*
* MessageOrder class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method MessageCost getCost()
* @method $this setCost(MessageCost $value)
* @method string getDate()
* @method $this setDate(string $value)
* @method MessageDelivery getDelivery()
* @method $this setDelivery(MessageDelivery $value)
* @method string getNumber()
* @method $this setNumber(string $value)
* @method MessageStatus getStatus()
* @method $this setStatus(MessageStatus $value)
*/
class MessageOrder extends LazyJsonMapper
{
const JSON_PROPERTY_MAP = [
'cost' => 'MessageCost',
'date' => 'string',
'delivery' => 'MessageDelivery',
'items' => 'MessageOrderItem[]',
'number' => 'string',
'payments' => 'MessagePayment[]',
'status' => 'MessageStatus'
];
}

View File

@ -0,0 +1,48 @@
<?php
/**
* PHP version 7.0
*
* MessageOrderItem entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use LazyJsonMapper\LazyJsonMapper;
/**
* PHP version 7.0
*
* MessageOrderItem class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method string getImg()
* @method $this setImg(string $value)
* @method string getName()
* @method $this setName(string $value)
* @method MessageCost getPrice()
* @method $this setPrice(MessageCost $value)
* @method MessageQuantity getQuantity()
* @method $this setQuantity(MessageQuantity $value)
* @method string getUrl()
* @method $this setUrl(string $value)
*/
class MessageOrderItem extends LazyJsonMapper
{
const JSON_PROPERTY_MAP = [
'img' => 'string',
'name' => 'string',
'price' => 'MessageCost',
'quantity' => 'MessageQuantity',
'url' => 'string'
];
}

View File

@ -0,0 +1,39 @@
<?php
/**
* PHP version 7.0
*
* MessageOrderPaymentStatus entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/**
* PHP version 7.0
*
* MessageOrderPaymentStatus class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method string getName()
* @method $this setName(string $value)
* @method bool getPayed()
* @method $this setPayed(bool $value)
*/
class MessageOrderPaymentStatus extends CommonFields
{
const JSON_PROPERTY_MAP = [
'name' => 'string',
'payed' => 'bool'
];
}

View File

@ -0,0 +1,42 @@
<?php
/**
* PHP version 7.0
*
* MessagePayment entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/**
* PHP version 7.0
*
* MessagePayment class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method MessageCost getAmount()
* @method $this setAmount(MessageCost $value)
* @method string getName()
* @method $this setName(string $value)
* @method MessageOrderPaymentStatus getStatus()
* @method $this setStatus(MessageOrderPaymentStatus $value)
*/
class MessagePayment extends CommonFields
{
const JSON_PROPERTY_MAP = [
'amount' => 'MessageCost',
'name' => 'string',
'status' => 'MessageOrderPaymentStatus'
];
}

View File

@ -0,0 +1,54 @@
<?php
/**
* PHP version 7.0
*
* MessageProduct entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use LazyJsonMapper\LazyJsonMapper;
/**
* PHP version 7.0
*
* MessageProduct class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method string getArticle()
* @method $this setArticle(string $value)
* @method MessageCost getCost()
* @method $this setCost(MessageCost $value)
* @method int getId()
* @method $this setId(int $value)
* @method string getImg()
* @method $this setImg(string $value)
* @method string getName()
* @method $this setName(string $value)
* @method MessageQuantity getQuantity()
* @method $this setQuantity(MessageQuantity $value)
* @method string getUrl()
* @method $this setUrl(string $value)
*/
class MessageProduct extends LazyJsonMapper
{
const JSON_PROPERTY_MAP = [
'article' => 'string',
'cost' => 'MessageCost',
'id' => 'int',
'img' => 'string',
'name' => 'string',
'quantity' => 'MessageQuantity',
'url' => 'string'
];
}

View File

@ -0,0 +1,39 @@
<?php
/**
* PHP version 7.0
*
* MessageQuantity entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use RetailCrm\Mg\Bot\Model\Entity\CommonFields;
/**
* PHP version 7.0
*
* MessageQuantity class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method string getUnit()
* @method $this setUnit(string $value)
* @method float getValue()
* @method $this setValue(float $value)
*/
class MessageQuantity extends CommonFields
{
const JSON_PROPERTY_MAP = [
'unit' => 'string',
'value' => 'float'
];
}

View File

@ -0,0 +1,39 @@
<?php
/**
* PHP version 7.0
*
* MessageStatus entity
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @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\Message;
use LazyJsonMapper\LazyJsonMapper;
/**
* PHP version 7.0
*
* MessageStatus class
*
* @package RetailCrm\Mg\Bot\Model\Entity\Message
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*
* @method string getCode()
* @method $this setCode(string $value)
* @method float getName()
* @method $this setName(float $value)
*/
class MessageStatus extends LazyJsonMapper
{
const JSON_PROPERTY_MAP = [
'code' => 'string',
'name' => 'string'
];
}

View File

@ -1,231 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Order entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* Order class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Order
{
/**
* @var string $number
*
* @Type("string")
* @Accessor(getter="getNumber",setter="setNumber")
* @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

@ -1,156 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Order item entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* OrderItem class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class OrderItem
{
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
* @SkipWhenEmpty()
*/
private $name;
/**
* @var string $url
*
* @Type("string")
* @Accessor(getter="getUrl",setter="setUrl")
* @SkipWhenEmpty()
*/
private $url;
/**
* @var string $img
*
* @Type("string")
* @Accessor(getter="getImg",setter="setImg")
* @SkipWhenEmpty()
*/
private $img;
/**
* @var 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

@ -1,106 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Payment entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* Payment class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Payment
{
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
* @SkipWhenEmpty()
*/
private $name;
/**
* @var 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

@ -1,81 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Payment status entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* PaymentStatus class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class PaymentStatus
{
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
* @SkipWhenEmpty()
*/
private $name;
/**
* @var bool $payed
*
* @Type("bool")
* @Accessor(getter="getPayed",setter="setPayed")
* @SkipWhenEmpty()
*/
private $payed;
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name)
{
$this->name = $name;
}
/**
* @return bool
*/
public function isPayed()
{
return $this->payed;
}
/**
* @param bool $payed
*/
public function setPayed(bool $payed)
{
$this->payed = $payed;
}
}

View File

@ -1,206 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Product entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* Product class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Product
{
/**
* @var int $id
*
* @Type("int")
* @Accessor(getter="getId",setter="setId")
* @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

@ -1,82 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Quantity entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* Quantity class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Quantity
{
/**
* @var float $value
*
* @Type("float")
* @Accessor(getter="getValue",setter="setValue")
* @SkipWhenEmpty()
*/
private $value;
/**
* @var string $unit
*
* @Type("string")
* @Accessor(getter="getUnit",setter="setUnit")
*
* @Assert\Currency
*/
private $unit;
/**
* @return float
*/
public function getValue()
{
return $this->value;
}
/**
* @param float $value
*/
public function setValue(float $value)
{
$this->value = $value;
}
/**
* @return string
*/
public function getUnit()
{
return $this->unit;
}
/**
* @param string $unit
*/
public function setUnit(string $unit)
{
$this->unit = $unit;
}
}

View File

@ -15,6 +15,7 @@ namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type; use JMS\Serializer\Annotation\Type;
use LazyJsonMapper\LazyJsonMapper;
/** /**
* PHP version 7.0 * PHP version 7.0
@ -26,77 +27,11 @@ 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 extends LazyJsonMapper
{ {
/** const JSON_PROPERTY_MAP = [
* @var string $assignedAt 'assigned_at' => 'string',
* 'id' => 'int',
* @Type("string") 'type' => 'string'
* @Accessor(getter="getAssignedAt",setter="setAssignedAt") ];
*/
private $assignedAt;
/**
* @var int $id
*
* @Type("int")
* @Accessor(getter="getId",setter="setId")
*/
private $id;
/**
* @var string $type
*
* @Type("string")
* @Accessor(getter="getType",setter="setType")
*/
private $type;
/**
* @return string
*/
public function getAssignedAt()
{
return $this->assignedAt;
}
/**
* @param string $assignedAt
*/
public function setAssignedAt(string $assignedAt)
{
$this->assignedAt = $assignedAt;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id)
{
$this->id = $id;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type)
{
$this->type = $type;
}
} }

View File

@ -1,81 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Status entity
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Mg\Bot\Model\Entity;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
/**
* PHP version 7.0
*
* Status class
*
* @package RetailCrm\Mg\Bot\Model\Entity
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Status
{
/**
* @var string $code
*
* @Type("string")
* @Accessor(getter="getCode",setter="setCode")
* @SkipWhenEmpty()
*/
private $code;
/**
* @var string $name
*
* @Type("string")
* @Accessor(getter="getName",setter="setName")
* @SkipWhenEmpty()
*/
private $name;
/**
* @return string
*/
public function getCode()
{
return $this->code;
}
/**
* @param string $code
*/
public function setCode(string $code)
{
$this->code = $code;
}
/**
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name)
{
$this->name = $name;
}
}

View File

@ -0,0 +1,55 @@
<?php
/**
* PHP version 7.0
*
* User 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;
/**
* PHP version 7.0
*
* User 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
*
* @method int getId()
* @method $this setId(int $value)
* @method string getType()
* @method $this setType(string $value)
* @method string getAvatar()
* @method $this setAvatar(string $value)
* @method string getName()
* @method $this setName(string $value)
* @method string getUsername()
* @method $this setUsername(string $value)
* @method string getFirstName()
* @method $this setFirstName(string $value)
* @method string getLastName()
* @method $this setLastName(string $value)
*/
class User extends CommonFields
{
const JSON_PROPERTY_MAP = [
'external_id' => 'string',
'type' => 'string',
'avatar' => 'string',
'name' => 'string',
'username' => 'string',
'first_name' => 'string',
'last_name' => 'string',
'is_active' => 'bool',
'is_online' => 'bool',
'revoked_at' => 'string'
];
}

View File

@ -13,11 +13,7 @@
namespace RetailCrm\Mg\Bot\Model\Response; namespace RetailCrm\Mg\Bot\Model\Response;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Entity\Responsible; use RetailCrm\Mg\Bot\Model\Entity\Responsible;
use RetailCrm\Mg\Bot\Model\Response\ErrorTrait;
/** /**
* PHP version 7.0 * PHP version 7.0
@ -28,104 +24,22 @@ use RetailCrm\Mg\Bot\Model\Response\ErrorTrait;
* @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
*
* @method bool getIsReassign()
* @method $this setIsReassign(bool $value)
* @method int getLeftManagerId()
* @method $this setLeftManagerId(int $value)
* @method Responsible getPreviousResponsible()
* @method $this setPreviousResponsible(Responsible $value)
* @method Responsible getResponsible()
* @method $this setResponsible(Responsible $value)
*/ */
class AssignResponse class AssignResponse extends CommonFields
{ {
use ErrorTrait; const JSON_PROPERTY_MAP = [
'is_reassign' => 'bool',
/** 'left_manager_id' => 'int',
* @var bool 'previous_responsible' => 'Responsible',
* 'responsible' => 'Responsible'
* @Type("bool") ];
* @Accessor(setter="setIsReassign", getter="getIsReassign")
*/
private $isReassign;
/**
* @var int
*
* @Type("int")
* @Accessor(setter="setLeftManagerId", getter="getLeftManagerId")
* @SkipWhenEmpty()
*/
private $leftManagerId;
/**
* @var Responsible $previousResponsible
*
* @Accessor(setter="setPreviousResponsible", getter="getPreviousResponsible")
* @SkipWhenEmpty()
*/
private $previousResponsible;
/**
* @var Responsible $responsible
*
* @Accessor(setter="setResponsible", getter="getResponsible")
*/
private $responsible;
/**
* @return bool
*/
public function getIsReassign()
{
return $this->isReassign;
}
/**
* @param bool $isReassign
*/
public function setIsReassign(bool $isReassign)
{
$this->isReassign = $isReassign;
}
/**
* @return int
*/
public function getLeftManagerId(): int
{
return $this->leftManagerId;
}
/**
* @param int $leftManagerId
*/
public function setLeftManagerId(int $leftManagerId)
{
$this->leftManagerId = $leftManagerId;
}
/**
* @return Responsible
*/
public function getPreviousResponsible(): Responsible
{
return $this->previousResponsible;
}
/**
* @param Responsible $previousResponsible
*/
public function setPreviousResponsible(Responsible $previousResponsible)
{
$this->previousResponsible = $previousResponsible;
}
/**
* @return Responsible
*/
public function getResponsible(): Responsible
{
return $this->responsible;
}
/**
* @param Responsible $responsible
*/
public function setResponsible(Responsible $responsible)
{
$this->responsible = $responsible;
}
} }

View File

@ -16,6 +16,7 @@ namespace RetailCrm\Mg\Bot\Model\Response;
use JMS\Serializer\Annotation as Serializer; 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 LazyJsonMapper\LazyJsonMapper;
use RetailCrm\Mg\Bot\Model\Entity\Error; use RetailCrm\Mg\Bot\Model\Entity\Error;
/** /**
@ -27,40 +28,21 @@ use RetailCrm\Mg\Bot\Model\Entity\Error;
* @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
*
* @method array getErrors()
* @method $this setErrors(array $value)
*/ */
trait ErrorTrait class CommonFields extends LazyJsonMapper
{ {
/** const JSON_PROPERTY_MAP = [
* @var array $error 'errors' => 'string[]'
* ];
* @Serializer\Type("array<string>")
* @Accessor(setter="getError", setter="setError")
* @Serializer\SerializedName("errors")
* @SkipWhenEmpty()
*/
private $error;
/**
* @return array
*/
public function getError()
{
return $this->error;
}
/**
* @param array $error
*/
public function setError(array $error)
{
$this->error = $error;
}
/** /**
* @return bool * @return bool
*/ */
public function isError() public function isError()
{ {
return !empty($this->error); return !empty($this->getErrors());
} }
} }

View File

@ -13,8 +13,6 @@
namespace RetailCrm\Mg\Bot\Model\Response; namespace RetailCrm\Mg\Bot\Model\Response;
use RetailCrm\Mg\Bot\Model\Response\ErrorTrait;
/** /**
* PHP version 7.0 * PHP version 7.0
* *
@ -25,7 +23,4 @@ use RetailCrm\Mg\Bot\Model\Response\ErrorTrait;
* @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 extends CommonFields {}
{
use ErrorTrait;
}

View File

@ -13,11 +13,6 @@
namespace RetailCrm\Mg\Bot\Model\Response; namespace RetailCrm\Mg\Bot\Model\Response;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Response\ErrorTrait;
/** /**
* PHP version 7.0 * PHP version 7.0
* *
@ -27,108 +22,22 @@ use RetailCrm\Mg\Bot\Model\Response\ErrorTrait;
* @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
*
* @method string getId()
* @method $this setId(string $value)
* @method int getSize()
* @method $this setSize(int $value)
* @method string getType()
* @method $this setType(string $value)
* @method string getUrl()
* @method $this setUrl(string $value)
*/ */
class FullFileResponse class FullFileResponse extends CommonFields
{ {
use ErrorTrait; const JSON_PROPERTY_MAP = [
'id' => 'string',
/** 'size' => 'int',
* @var string $id 'type' => 'string',
* 'url' => 'string'
* @Type("string") ];
* @Accessor(setter="setId", getter="getId")
* @SkipWhenEmpty()
*/
private $id;
/**
* @var int $size
*
* @Type("int")
* @Accessor(setter="setSize", getter="getSize")
* @SkipWhenEmpty()
*/
private $size;
/**
* @var string $type
*
* @Type("string")
* @Accessor(setter="setType", getter="getType")
* @SkipWhenEmpty()
*/
private $type;
/**
* @var string $url
*
* @Type("string")
* @Accessor(setter="setUrl", getter="getUrl")
* @SkipWhenEmpty()
*/
private $url;
/**
* @return string
*/
public function getId(): string
{
return $this->id;
}
/**
* @param string $id
*/
public function setId(string $id)
{
$this->id = $id;
}
/**
* @return int
*/
public function getSize(): int
{
return $this->size;
}
/**
* @param int $size
*/
public function setSize(int $size)
{
$this->size = $size;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type)
{
$this->type = $type;
}
/**
* @return string
*/
public function getUrl(): string
{
return $this->url;
}
/**
* @param string $url
*/
public function setUrl(string $url)
{
$this->url = $url;
}
} }

View File

@ -1,57 +0,0 @@
<?php
/**
* PHP version 7.0
*
* GenericListResponse
*
* @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 JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Response\ErrorTrait;
/**
* PHP version 7.0
*
* GenericListResponse class
*
* @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 GenericListResponse
{
use ErrorTrait;
/**
* @var array $result
*
* @Type("array")
* @Accessor(setter="setResult", getter="getResult")
*/
private $result;
/**
* @return array
*/
public function getResult()
{
return $this->result;
}
/**
* @param array $result
*/
public function setResult(array $result)
{
$this->result = $result;
}
}

View File

@ -0,0 +1,135 @@
<?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;
/**
* PHP version 7.0
*
* ListResponse class
*
* @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 {
/**
* @var array
*/
private $items = [];
/**
* @var array
*/
private $errors = [];
/**
* @var int
*/
private $position = 0;
/**
* ListResponse constructor.
*
* @param $responseType
* @param $data
*/
public function __construct($responseType, $data)
{
if (isset($data['errors'])) {
$this->errors = $data['errors'];
} else {
foreach($data as $item) {
$this->items[] = new $responseType($item);
}
}
}
/**
* @return bool
*/
public function isSuccessful()
{
return empty($this->errors);
}
/**
* @return array
*/
public function getErrors()
{
return $this->errors;
}
/**
* @param $name
*
* @return mixed
*/
public function get($name)
{
return $this->items[$name];
}
/**
* @param $name
*
* @return mixed
*/
public function __get($name)
{
return $this->items[$name];
}
/**
* Implements rewind() for Iterable
*/
public function rewind() {
$this->position = 0;
}
/**
* Implements current() for Iterable
*
* @return mixed
*/
public function current() {
return $this->items[$this->position];
}
/**
* Implements key() for Iterable
*
* @return int|mixed
*/
public function key() {
return $this->position;
}
/**
* Implements next() for Iterable
*/
public function next() {
++$this->position;
}
/**
* Implements valid() for Iterable
*
* @return bool
*/
public function valid() {
return isset($this->items[$this->position]);
}
}

View File

@ -13,12 +13,6 @@
namespace RetailCrm\Mg\Bot\Model\Response; namespace RetailCrm\Mg\Bot\Model\Response;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\SkipWhenEmpty;
use JMS\Serializer\Annotation\Accessor;
use JMS\Serializer\Annotation\Type;
use RetailCrm\Mg\Bot\Model\Response\ErrorTrait;
/** /**
* PHP version 7.0 * PHP version 7.0
* *
@ -28,56 +22,16 @@ use RetailCrm\Mg\Bot\Model\Response\ErrorTrait;
* @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
*
* @method int getMessageId()
* @method $this setMessageId(int $value)
* @method string getTime()
* @method $this setTime(string $value)
*/ */
class MessageSendResponse class MessageSendResponse extends CommonFields
{ {
/** const JSON_PROPERTY_MAP = [
* @var int $messageId 'message_id' => 'int',
* 'time' => 'string'
* @Type("int") ];
* @Accessor(setter="setMessageId", getter="getMessageId")
* @SkipWhenEmpty()
*/
private $messageId;
/**
* @var string $time
*
* @Type("string")
* @Accessor(setter="setTime", getter="getTime")
* @SkipWhenEmpty()
*/
private $time;
/**
* @return int
*/
public function getMessageId(): int
{
return $this->messageId;
}
/**
* @param int $messageId
*/
public function setMessageId(int $messageId)
{
$this->messageId = $messageId;
}
/**
* @return string
*/
public function getTime(): string
{
return $this->time;
}
/**
* @param string $time
*/
public function setTime(string $time)
{
$this->time = $time;
}
} }

View File

@ -15,7 +15,7 @@ namespace RetailCrm\Mg\Bot\Model\Response;
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\Response\ErrorTrait; use RetailCrm\Mg\Bot\Model\Response\CommonFields;
use RetailCrm\Mg\Bot\Model\Entity\FileMeta; use RetailCrm\Mg\Bot\Model\Entity\FileMeta;
/** /**
@ -27,199 +27,34 @@ use RetailCrm\Mg\Bot\Model\Entity\FileMeta;
* @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
*
* @method string getCreatedAt()
* @method $this setCreatedAt(string $value)
* @method string getHash()
* @method $this setHash(string $value)
* @method string getId()
* @method $this setId(string $value)
* @method FileMeta getMeta()
* @method $this setMeta(FileMeta $value)
* @method string getMimeType()
* @method $this setMimeType(string $value)
* @method int getSize()
* @method $this setSize(int $value)
* @method string getSourceUrl()
* @method $this setSourceUrl(string $value)
* @method string getType()
* @method $this setType(string $value)
*/ */
class UploadFileResponse class UploadFileResponse extends CommonFields
{ {
use ErrorTrait; const JSON_PROPERTY_MAP = [
'created_at' => 'string',
/** 'hash' => 'string',
* @var string $createdAt 'id' => 'string',
* 'meta' => 'FileMeta',
* @Type("string") 'mime_type' => 'string',
* @Accessor(setter="setCreatedAt", getter="getCreatedAt") 'size' => 'int',
*/ 'source_url' => 'string',
private $createdAt; 'type' => 'string'
];
/**
* @var string $hash
*
* @Type("string")
* @Accessor(setter="setHash", getter="getHash")
*/
private $hash;
/**
* @var string $id
*
* @Type("string")
* @Accessor(setter="setId", getter="getId")
*/
private $id;
/**
* @var FileMeta
*
* @Accessor(setter="setMeta", getter="getMeta")
*/
private $meta;
/**
* @var string $mimeType
*
* @Type("string")
* @Accessor(setter="setMimeType", getter="getMimeType")
*/
private $mimeType;
/**
* @var int $size
*
* @Type("string")
* @Accessor(setter="setSize", getter="getSize")
*/
private $size;
/**
* @var string $sourceUrl
*
* @Type("string")
* @Accessor(setter="setSourceUrl", getter="getSourceUrl")
*/
private $sourceUrl;
/**
* @var string $type
*
* @Type("string")
* @Accessor(setter="setType", getter="getType")
*/
private $type;
/**
* @return string
*/
public function getCreatedAt(): string
{
return $this->createdAt;
}
/**
* @param string $createdAt
*/
public function setCreatedAt(string $createdAt)
{
$this->createdAt = $createdAt;
}
/**
* @return string
*/
public function getHash(): string
{
return $this->hash;
}
/**
* @param string $hash
*/
public function setHash(string $hash)
{
$this->hash = $hash;
}
/**
* @return string
*/
public function getId(): string
{
return $this->id;
}
/**
* @param string $id
*/
public function setId(string $id)
{
$this->id = $id;
}
/**
* @return FileMeta
*/
public function getMeta(): FileMeta
{
return $this->meta;
}
/**
* @param FileMeta $meta
*/
public function setMeta(FileMeta $meta)
{
$this->meta = $meta;
}
/**
* @return string
*/
public function getMimeType(): string
{
return $this->mimeType;
}
/**
* @param string $mimeType
*/
public function setMimeType(string $mimeType)
{
$this->mimeType = $mimeType;
}
/**
* @return int
*/
public function getSize(): int
{
return $this->size;
}
/**
* @param int $size
*/
public function setSize(int $size)
{
$this->size = $size;
}
/**
* @return string
*/
public function getSourceUrl(): string
{
return $this->sourceUrl;
}
/**
* @param string $sourceUrl
*/
public function setSourceUrl(string $sourceUrl)
{
$this->sourceUrl = $sourceUrl;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type)
{
$this->type = $type;
}
} }

View File

@ -1,59 +0,0 @@
<?php
/**
* PHP version 7.0
*
* Deserializer
*
* @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
namespace RetailCrm\Common;
use JMS\Serializer\SerializerBuilder;
/**
* PHP version 7.0
*
* Deserializer class
*
* @package RetailCrm\Common
* @author retailCRM <integration@retailcrm.ru>
* @license https://opensource.org/licenses/MIT MIT License
* @link http://help.retailcrm.pro/docs/Developers
*/
class Deserializer
{
const DS_JSON = "json";
const DS_XML = "xml";
const DS_ARRAY = "array";
/**
* Serialize given object to JSON or Array
*
* @param array|string $data
* @param string $deserialize
*
* @return object
*/
public static function deserialize($data, $type, $deserialize = self::S_JSON)
{
$deserialized = null;
$serializer = SerializerBuilder::create()->build();
switch ($deserialize) {
case self::DS_ARRAY:
$deserialized = $serializer->fromArray($data, $type);
break;
case self::DS_JSON:
case self::DS_XML:
$deserialized = $serializer->deserialize($data, $type, $deserialize);
break;
}
return $deserialized;
}
}

View File

@ -14,6 +14,7 @@
namespace RetailCrm\Mg\Bot\Tests; namespace RetailCrm\Mg\Bot\Tests;
use RetailCrm\Mg\Bot\Model\Constants; use RetailCrm\Mg\Bot\Model\Constants;
use RetailCrm\Mg\Bot\Model\Entity\Dialog;
use RetailCrm\Mg\Bot\Model\Request; use RetailCrm\Mg\Bot\Model\Request;
use RetailCrm\Mg\Bot\Model\Response; use RetailCrm\Mg\Bot\Model\Response;
use RetailCrm\Mg\Bot\Test\TestCase; use RetailCrm\Mg\Bot\Test\TestCase;
@ -44,9 +45,8 @@ class ClientListTest extends TestCase
$request->setTypes([Constants::CHANNEL_TYPE_FACEBOOK, Constants::CHANNEL_TYPE_INSTAGRAM]); $request->setTypes([Constants::CHANNEL_TYPE_FACEBOOK, Constants::CHANNEL_TYPE_INSTAGRAM]);
$response = $client->channels($request); $response = $client->channels($request);
var_dump($response[0]);
//self::assertTrue($response->isSuccessful() == true); print_r($response->get(0));
} }
/** /**
@ -62,7 +62,7 @@ class ClientListTest extends TestCase
$response = $client->chats($request); $response = $client->chats($request);
self::assertTrue($response->isSuccessful() == true); print_r($response);
} }
/** /**
@ -77,7 +77,7 @@ class ClientListTest extends TestCase
$response = $client->members($request); $response = $client->members($request);
self::assertTrue($response->isSuccessful() == true); print_r($response);
} }
/** /**
@ -94,7 +94,7 @@ class ClientListTest extends TestCase
$response = $client->messages($request); $response = $client->messages($request);
self::assertTrue($response->isSuccessful() == true); print_r($response);
} }
/** /**
@ -109,7 +109,7 @@ class ClientListTest extends TestCase
$response = $client->commands($request); $response = $client->commands($request);
self::assertTrue($response->isSuccessful() == true); print_r($response);
} }
/** /**
@ -126,7 +126,7 @@ class ClientListTest extends TestCase
$data = $client->bots($request); $data = $client->bots($request);
self::assertTrue($data instanceof \RetailCrm\Mg\Bot\Model\Response\GenericListResponse); print_r($data);
} }
/** /**
@ -143,7 +143,7 @@ class ClientListTest extends TestCase
$response = $client->users($request); $response = $client->users($request);
self::assertTrue($response->isSuccessful() == true); print_r($response);
} }
/** /**
@ -159,8 +159,6 @@ class ClientListTest extends TestCase
$request->setAssign(1); $request->setAssign(1);
$response = $client->dialogs($request); $response = $client->dialogs($request);
self::assertTrue($response->isSuccessful() == true);
} }
/** /**
@ -175,6 +173,6 @@ class ClientListTest extends TestCase
$response = $client->customers($request); $response = $client->customers($request);
self::assertTrue($response->isSuccessful() == true); print_r($response);
} }
} }