1
0
mirror of synced 2024-11-21 19:36:02 +03:00

Add note to SendMessageRequest

This commit is contained in:
Pavel 2024-06-21 14:02:54 +03:00 committed by GitHub
commit a05cf2cc09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 60 additions and 0 deletions

View File

@ -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
*/

View File

@ -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());
}
}
}