1: <?php declare(strict_types=1);
2:
3: namespace Salient\Contract\Curler;
4:
5: use Psr\Http\Message\RequestInterface as PsrRequestInterface;
6: use Salient\Contract\Http\Message\ResponseInterface;
7: use Salient\Contract\Http\HasHttpHeader;
8:
9: /**
10: * @api
11: */
12: interface CurlerPagerInterface extends HasHttpHeader
13: {
14: /**
15: * Get a request to retrieve the first page of data from the endpoint
16: *
17: * Return `$request` if no special handling is required.
18: *
19: * Return a {@see CurlerPageRequestInterface} to propagate `$query` changes
20: * to {@see CurlerPagerInterface::getPage()} in array form.
21: *
22: * @param mixed[]|null $query The query applied to `$request`.
23: * @return CurlerPageRequestInterface|PsrRequestInterface
24: */
25: public function getFirstRequest(
26: PsrRequestInterface $request,
27: CurlerInterface $curler,
28: ?array $query = null
29: );
30:
31: /**
32: * Convert data returned by the endpoint to a new page object
33: *
34: * @template TPage of CurlerPageInterface|null
35: *
36: * @param mixed $data
37: * @param TPage $previousPage
38: * @param mixed[]|null $query The query applied to `$request` or returned by
39: * {@see CurlerPageRequestInterface::getQuery()}, if applicable.
40: * @return (TPage is null ? CurlerPageInterface : TPage)
41: */
42: public function getPage(
43: $data,
44: PsrRequestInterface $request,
45: ResponseInterface $response,
46: CurlerInterface $curler,
47: ?CurlerPageInterface $previousPage = null,
48: ?array $query = null
49: ): CurlerPageInterface;
50: }
51: