Skip to content

Commit

Permalink
Add note to SendMessageRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
Chupocabra committed Jun 20, 2024
1 parent 90b90c0 commit be857dd
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Bot/Model/Request/MessageSendRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -241,6 +250,22 @@ public function setItems(array $items)
$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
*/
Expand Down
35 changes: 35 additions & 0 deletions tests/Bot/Tests/MessagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -361,4 +362,38 @@ public function testMessageSendSuggestions()
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());
}
}
}

0 comments on commit be857dd

Please sign in to comment.