mirror of
https://github.com/retailcrm/mailgun-php.git
synced 2025-02-16 04:53:14 +03:00
43 lines
898 B
PHP
43 lines
898 B
PHP
|
<?php
|
||
|
|
||
|
/*
|
||
|
* Copyright (C) 2013-2016 Mailgun
|
||
|
*
|
||
|
* This software may be modified and distributed under the terms
|
||
|
* of the MIT license. See the LICENSE file for details.
|
||
|
*/
|
||
|
|
||
|
namespace Mailgun\Api;
|
||
|
|
||
|
use Mailgun\Assert;
|
||
|
use Psr\Http\Message\ResponseInterface;
|
||
|
|
||
|
/**
|
||
|
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
|
||
|
*/
|
||
|
trait Pagination
|
||
|
{
|
||
|
abstract protected function httpGet($path, array $parameters = [], array $requestHeaders = []);
|
||
|
|
||
|
abstract protected function safeDeserialize(ResponseInterface $response, $className);
|
||
|
|
||
|
/**
|
||
|
* @param string $url
|
||
|
* @param string $class
|
||
|
*
|
||
|
* @return mixed|null
|
||
|
*/
|
||
|
public function getPaginationUrl($url, $class)
|
||
|
{
|
||
|
Assert::stringNotEmpty($class);
|
||
|
|
||
|
if (empty($url)) {
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
$response = $this->httpGet($url);
|
||
|
|
||
|
return $this->safeDeserialize($response, $class);
|
||
|
}
|
||
|
}
|