From c931b2622c529c392878b50171a8ccb2ebd38fc1 Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Thu, 22 Dec 2022 13:46:12 +0300 Subject: [PATCH 1/2] fix for `/chats` request --- src/Bot/Model/Entity/Chat/Chat.php | 2 +- src/Bot/Model/Entity/Chat/ChatLastMessage.php | 202 +++++++++++++++++- src/Bot/Model/Entity/Message/MessageQuote.php | 172 +++++++++++++++ tests/Resources/chats.json | 23 +- 4 files changed, 395 insertions(+), 4 deletions(-) create mode 100644 src/Bot/Model/Entity/Message/MessageQuote.php diff --git a/src/Bot/Model/Entity/Chat/Chat.php b/src/Bot/Model/Entity/Chat/Chat.php index ff59a90..8282729 100644 --- a/src/Bot/Model/Entity/Chat/Chat.php +++ b/src/Bot/Model/Entity/Chat/Chat.php @@ -100,7 +100,7 @@ class Chat implements ModelInterface /** * @var ChatLastMessage $lastMessage * - * @Type("ChatLastMessage") + * @Type("RetailCrm\Mg\Bot\Model\Entity\Chat\ChatLastMessage") * @Accessor(getter="getLastMessage",setter="setLastMessage") */ private $lastMessage; diff --git a/src/Bot/Model/Entity/Chat/ChatLastMessage.php b/src/Bot/Model/Entity/Chat/ChatLastMessage.php index 7089b6c..ea8eeeb 100644 --- a/src/Bot/Model/Entity/Chat/ChatLastMessage.php +++ b/src/Bot/Model/Entity/Chat/ChatLastMessage.php @@ -13,6 +13,7 @@ namespace RetailCrm\Mg\Bot\Model\Entity\Chat; use JMS\Serializer\Annotation\Accessor; use JMS\Serializer\Annotation\SkipWhenEmpty; use JMS\Serializer\Annotation\Type; +use RetailCrm\Mg\Bot\Model\Entity\Customer; use RetailCrm\Mg\Bot\Model\ModelInterface; /** @@ -34,7 +35,7 @@ class ChatLastMessage implements ModelInterface /** * @var \DateTime $time * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:sP'>") * @Accessor(getter="getTime",setter="setTime") * @SkipWhenEmpty() */ @@ -49,6 +50,77 @@ class ChatLastMessage implements ModelInterface */ private $type; + /** + * @var string $scope + * + * @Type("string") + * @Accessor(getter="getScope",setter="setScope") + * @SkipWhenEmpty() + */ + private $scope; + + /** + * @var int $chatId + * + * @Type("int") + * @Accessor(getter="getChatId",setter="setChatId") + * @SkipWhenEmpty() + */ + private $chatId; + + /** + * @var bool $isRead + * + * @Type("bool") + * @Accessor(getter="getIsRead",setter="setIsRead") + * @SkipWhenEmpty() + */ + private $isRead; + + /** + * @var bool $isEdit + * + * @Type("bool") + * @Accessor(getter="getIsEdit",setter="setIsEdit") + * @SkipWhenEmpty() + */ + private $isEdit; + + /** + * @var string $status + * + * @Type("string") + * @Accessor(getter="getStatus",setter="setStatus") + * @SkipWhenEmpty() + */ + private $status; + + /** + * @var Customer $from + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Customer") + * @Accessor(getter="getFrom",setter="setFrom") + */ + private $from; + + /** + * @var string $content + * + * @Type("string") + * @Accessor(getter="getContent",setter="setContent") + * @SkipWhenEmpty() + */ + private $content; + + /** + * @var \RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuote $quote + * + * @Type("RetailCrm\Mg\Bot\Model\Entity\Message\MessageQuote") + * @Accessor(getter="getQuote",setter="setQuote") + * @SkipWhenEmpty() + */ + private $quote; + /** * @return int|null */ @@ -96,4 +168,132 @@ class ChatLastMessage implements ModelInterface { $this->type = $type; } + + /** + * @return mixed + */ + public function getScope() + { + return $this->scope; + } + + /** + * @param mixed $scope + */ + public function setScope($scope): void + { + $this->scope = $scope; + } + + /** + * @return mixed + */ + public function getChatId() + { + return $this->chatId; + } + + /** + * @param mixed $chatId + */ + public function setChatId($chatId): void + { + $this->chatId = $chatId; + } + + /** + * @return mixed + */ + public function getIsRead() + { + return $this->isRead; + } + + /** + * @param mixed $isRead + */ + public function setIsRead($isRead): void + { + $this->isRead = $isRead; + } + + /** + * @return mixed + */ + public function getIsEdit() + { + return $this->isEdit; + } + + /** + * @param mixed $isEdit + */ + public function setIsEdit($isEdit): void + { + $this->isEdit = $isEdit; + } + + /** + * @return mixed + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param mixed $status + */ + public function setStatus($status): void + { + $this->status = $status; + } + + /** + * @return mixed + */ + public function getFrom() + { + return $this->from; + } + + /** + * @param mixed $from + */ + public function setFrom($from): void + { + $this->from = $from; + } + + /** + * @return mixed + */ + public function getContent() + { + return $this->content; + } + + /** + * @param mixed $content + */ + public function setContent($content): void + { + $this->content = $content; + } + + /** + * @return mixed + */ + public function getQuote() + { + return $this->quote; + } + + /** + * @param mixed $quote + */ + public function setQuote($quote): void + { + $this->quote = $quote; + } } diff --git a/src/Bot/Model/Entity/Message/MessageQuote.php b/src/Bot/Model/Entity/Message/MessageQuote.php new file mode 100644 index 0000000..d014ee5 --- /dev/null +++ b/src/Bot/Model/Entity/Message/MessageQuote.php @@ -0,0 +1,172 @@ +") + * @Accessor(getter="getTime",setter="setTime") + */ + private $time; + + /** + * @var string $content + * + * @Type("string") + * @Accessor(getter="getContent",setter="setContent") + */ + private $content; + + /** + * @var array $items + * + * @Type("array") + * @Accessor(getter="getItems",setter="setItems") + * @SkipWhenEmpty() + */ + private $items; + + /** + * @return string|null + */ + public function getId(): ?string + { + return $this->id; + } + + /** + * @param string $id + */ + public function setId(string $id) + { + $this->id = $id; + } + + /** + * @return string|null + */ + public function getType(): ?string + { + return $this->type; + } + + /** + * @param string $type + */ + public function setType(string $type) + { + $this->type = $type; + } + + /** + * @return User|null + */ + public function getFrom(): ?User + { + return $this->from; + } + + /** + * @param User $from + */ + public function setFrom(User $from) + { + $this->from = $from; + } + + /** + * @return \DateTime + */ + public function getTime(): ?\DateTime + { + return $this->time; + } + + /** + * @param \DateTime $time + */ + public function setTime(\DateTime $time) + { + $this->time = $time; + } + + /** + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * @param string $content + */ + public function setContent(string $content): void + { + $this->content = $content; + } + + /** + * @return array|null + */ + public function getItems(): ?array + { + return $this->items; + } + + /** + * @param array $items + */ + public function setItems(array $items) + { + $this->items = $items; + } +} diff --git a/tests/Resources/chats.json b/tests/Resources/chats.json index 1bd6785..44c0d74 100644 --- a/tests/Resources/chats.json +++ b/tests/Resources/chats.json @@ -108,9 +108,28 @@ "last_name": "Петрович" }, "author_id": 0, - "last_message": null, + "last_message": { + "id": 1, + "time": "2022-12-21T17:15:54+01:00", + "type": "command", + "scope": "private", + "chat_id": 1053, + "is_read": false, + "is_edit": false, + "status": "received", + "from": { + "id": 2, + "external_id": "12", + "type": "user", + "avatar": null, + "name": "Cuenta Soporte", + "first_name": "Cuenta", + "last_name": "Soporte", + "is_technical_account": true + } + }, "last_activity": "2019-06-13T11:07:14+03:00", "created_at": "2019-06-11T07:34:16.082957Z", "updated_at": "2019-06-16T08:10:28.657972Z" } -] \ No newline at end of file +] From 0631c80ebb7937605ccc46e40b40e27d354cb37f Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Thu, 22 Dec 2022 14:03:10 +0300 Subject: [PATCH 2/2] fix for typos --- src/Bot/Model/Entity/Message/MessageQuote.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Bot/Model/Entity/Message/MessageQuote.php b/src/Bot/Model/Entity/Message/MessageQuote.php index d014ee5..9e379fc 100644 --- a/src/Bot/Model/Entity/Message/MessageQuote.php +++ b/src/Bot/Model/Entity/Message/MessageQuote.php @@ -23,7 +23,7 @@ use RetailCrm\Mg\Bot\Model\Entity\User; class MessageQuote { /** - * @var int $creating + * @var int $id * * @Type("int") * @Accessor(getter="getId",setter="setId") @@ -66,7 +66,7 @@ class MessageQuote private $content; /** - * @var array $items + * @var object[] $items * * @Type("array") * @Accessor(getter="getItems",setter="setItems") @@ -75,17 +75,17 @@ class MessageQuote private $items; /** - * @return string|null + * @return int */ - public function getId(): ?string + public function getId(): int { return $this->id; } /** - * @param string $id + * @param int $id */ - public function setId(string $id) + public function setId(int $id): void { $this->id = $id; } @@ -101,7 +101,7 @@ class MessageQuote /** * @param string $type */ - public function setType(string $type) + public function setType(string $type): void { $this->type = $type; } @@ -117,7 +117,7 @@ class MessageQuote /** * @param User $from */ - public function setFrom(User $from) + public function setFrom(User $from): void { $this->from = $from; } @@ -133,7 +133,7 @@ class MessageQuote /** * @param \DateTime $time */ - public function setTime(\DateTime $time) + public function setTime(\DateTime $time): void { $this->time = $time; } @@ -141,7 +141,7 @@ class MessageQuote /** * @return string */ - public function getContent() + public function getContent(): string { return $this->content; } @@ -155,7 +155,7 @@ class MessageQuote } /** - * @return array|null + * @return object[]|null */ public function getItems(): ?array { @@ -163,9 +163,9 @@ class MessageQuote } /** - * @param array $items + * @param object[] $items */ - public function setItems(array $items) + public function setItems(array $items): void { $this->items = $items; }