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

add using limit in requests

This commit is contained in:
Ruslan Efanov 2023-02-07 12:04:37 +03:00
parent 1650ff34aa
commit 58aa909473
8 changed files with 67 additions and 0 deletions

View File

@ -23,6 +23,7 @@ use RetailCrm\Mg\Bot\Model\ModelInterface;
class BotsRequest implements ModelInterface class BotsRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;
use PageLimit;
/** /**
* @Type("int") * @Type("int")

View File

@ -23,6 +23,7 @@ use RetailCrm\Mg\Bot\Model\ModelInterface;
class ChannelsRequest implements ModelInterface class ChannelsRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;
use PageLimit;
/** /**
* @Type("array") * @Type("array")

View File

@ -23,6 +23,7 @@ use RetailCrm\Mg\Bot\Model\ModelInterface;
class CustomersRequest implements ModelInterface class CustomersRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;
use PageLimit;
/** /**
* @Type("string") * @Type("string")

View File

@ -23,6 +23,7 @@ use RetailCrm\Mg\Bot\Model\ModelInterface;
class DialogsRequest implements ModelInterface class DialogsRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;
use PageLimit;
/** /**
* @var int $chatId * @var int $chatId

View File

@ -22,6 +22,8 @@ use RetailCrm\Mg\Bot\Model\ModelInterface;
*/ */
class MembersRequest implements ModelInterface class MembersRequest implements ModelInterface
{ {
use PageLimit;
/** /**
* @var int $chatId * @var int $chatId
* *

View File

@ -23,6 +23,7 @@ use RetailCrm\Mg\Bot\Model\ModelInterface;
class UsersRequest implements ModelInterface class UsersRequest implements ModelInterface
{ {
use CommonFields; use CommonFields;
use PageLimit;
/** /**
* @Type("string") * @Type("string")

View File

@ -10,6 +10,9 @@
namespace RetailCrm\Mg\Bot\Tests; namespace RetailCrm\Mg\Bot\Tests;
use Psr\Http\Message\ResponseInterface;
use RetailCrm\Mg\Bot\Client;
use RetailCrm\Mg\Bot\HttpClient;
use RetailCrm\Mg\Bot\Model\Constants; use RetailCrm\Mg\Bot\Model\Constants;
use RetailCrm\Mg\Bot\Model\Entity\Channel; use RetailCrm\Mg\Bot\Model\Entity\Channel;
use RetailCrm\Mg\Bot\Model\Entity\Chat\Chat; use RetailCrm\Mg\Bot\Model\Entity\Chat\Chat;

View File

@ -0,0 +1,57 @@
<?php
namespace RetailCrm\Mg\Bot\Tests\Model;
use PHPStan\Testing\TestCase;
use RetailCrm\Common\Serializer;
use RetailCrm\Mg\Bot\Model\Request\BotsRequest;
use RetailCrm\Mg\Bot\Model\Request\ChannelsRequest;
use RetailCrm\Mg\Bot\Model\Request\ChatsRequest;
use RetailCrm\Mg\Bot\Model\Request\CustomersRequest;
use RetailCrm\Mg\Bot\Model\Request\DialogsRequest;
use RetailCrm\Mg\Bot\Model\Request\MembersRequest;
use RetailCrm\Mg\Bot\Model\Request\UsersRequest;
class ListEntityRequestTest extends TestCase
{
private const LIMIT = 100;
public function testListRequestsWithLimit(): void
{
$expected = json_encode(['limit' => self::LIMIT]);
$request = new BotsRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new ChannelsRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new ChatsRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new CustomersRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new DialogsRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new MembersRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
$request = new UsersRequest();
$request->setLimit(self::LIMIT);
self::assertEquals($expected, Serializer::serialize($request));
}
}