mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2024-11-21 20:16:03 +03:00
Mailgun-461: Validate limits (#565)
* Check limit for paginated domains * Check limit for paginated events * Check limit for paginated rotues * Check limit for paginated tags * Check limit for paginated mailing lists * Replace unexpected Assert
This commit is contained in:
parent
7e438f4b4e
commit
abf2a0ae55
@ -40,6 +40,8 @@ class Domain extends HttpApi
|
||||
*/
|
||||
public function index(int $limit = 100, int $skip = 0)
|
||||
{
|
||||
Assert::range($limit, 1, 1000);
|
||||
|
||||
$params = [
|
||||
'limit' => $limit,
|
||||
'skip' => $skip,
|
||||
|
@ -30,6 +30,10 @@ class Event extends HttpApi
|
||||
{
|
||||
Assert::stringNotEmpty($domain);
|
||||
|
||||
if (array_key_exists('limit', $params)) {
|
||||
Assert::range($params['limit'], 1, 300);
|
||||
}
|
||||
|
||||
$response = $this->httpGet(sprintf('/v3/%s/events', $domain), $params);
|
||||
|
||||
return $this->hydrateResponse($response, EventResponse::class);
|
||||
|
@ -40,8 +40,7 @@ class MailingList extends HttpApi
|
||||
*/
|
||||
public function pages(int $limit = 100)
|
||||
{
|
||||
Assert::integer($limit);
|
||||
Assert::greaterThan($limit, 0);
|
||||
Assert::range($limit, 1, 1000);
|
||||
|
||||
$params = [
|
||||
'limit' => $limit,
|
||||
|
@ -37,6 +37,7 @@ class Route extends HttpApi
|
||||
{
|
||||
Assert::greaterThan($limit, 0);
|
||||
Assert::greaterThanEq($skip, 0);
|
||||
Assert::range($limit, 1, 1000);
|
||||
|
||||
$params = [
|
||||
'limit' => $limit,
|
||||
|
@ -38,6 +38,8 @@ class Tag extends HttpApi
|
||||
public function index(string $domain, int $limit = 100)
|
||||
{
|
||||
Assert::stringNotEmpty($domain);
|
||||
Assert::range($limit, 1, 1000);
|
||||
|
||||
$params = [
|
||||
'limit' => $limit,
|
||||
];
|
||||
|
Loading…
Reference in New Issue
Block a user