diff --git a/src/Bot/Model/Request/MessageSendRequest.php b/src/Bot/Model/Request/MessageSendRequest.php index 2bf4c4c..26c6bdc 100644 --- a/src/Bot/Model/Request/MessageSendRequest.php +++ b/src/Bot/Model/Request/MessageSendRequest.php @@ -72,6 +72,15 @@ class MessageSendRequest implements ModelInterface */ private $items; + /** + * @var string $note + * + * @Type("string") + * @Accessor(getter="getNote",setter="setNote") + * @SkipWhenEmpty() + */ + private $note; + /** * @var string $scope * @@ -241,6 +250,22 @@ class MessageSendRequest implements ModelInterface $this->items = $items; } + /** + * @return null|string + */ + public function getNote(): ?string + { + return $this->note; + } + + /** + * @param string $note + */ + public function setNote(string $note): void + { + $this->note = $note; + } + /** * @return int */ diff --git a/tests/Bot/Tests/MessagesTest.php b/tests/Bot/Tests/MessagesTest.php index 2926a1c..07be258 100644 --- a/tests/Bot/Tests/MessagesTest.php +++ b/tests/Bot/Tests/MessagesTest.php @@ -11,6 +11,7 @@ namespace RetailCrm\Mg\Bot\Tests; use RetailCrm\Mg\Bot\Model\Constants; +use RetailCrm\Mg\Bot\Model\Entity\Message\Item; use RetailCrm\Mg\Bot\Model\Entity\Message\MessageCost; use RetailCrm\Mg\Bot\Model\Entity\Message\MessageDelivery; use RetailCrm\Mg\Bot\Model\Entity\Message\MessageOrder; @@ -361,4 +362,38 @@ class MessagesTest extends TestCase self::assertEquals(3636, $response->getMessageId()); } } + + public function testMessageSendItems() + { + $client = self::getApiClient( + null, + null, + false, + $this->getResponse( + '{"message_id":4242,"time":"2019-06-24T06:02:04.434291791Z"}', + 201 + ) + ); + + $item = new Item(); + $item->setCaption('demo caption'); + $item->setId('e33e5398-814a-47d6-902a-466ba120ce45'); + + $request = new MessageSendRequest(); + $request->setChatId(28); + $request->setScope(Constants::MESSAGE_SCOPE_PUBLIC); + $request->setContent("Hello"); + $request->setItems([$item]); + $request->setNote('demo note'); + + $response = $client->messageSend($request); + + self::assertInstanceOf(MessageSendResponse::class, $response); + + if ($response instanceof MessageSendResponse) { + self::assertTrue($response->isSuccessful()); + self::assertCount(0, $response->getErrors()); + self::assertEquals(4242, $response->getMessageId()); + } + } }