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

add limit to requests

This commit is contained in:
Pavel 2023-02-07 16:14:01 +03:00 committed by GitHub
commit 6ec1f00df9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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
{
use CommonFields;
use PageLimit;
/**
* @Type("int")

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,6 +10,9 @@
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\Entity\Channel;
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));
}
}