Closed advil0 closed 1 year ago
Hmm you could extend the Paginator class you’re currently using and then overwrite the “isFinished” logic to check for your properties instead? Let me know how you get on!
You could also use the total / page count calculation, you'd have to change the isFinished slightly...
class CustomPaginator extends PagedPaginator
{
protected function isFinished(): bool
{
return $this->getCurrentPage() > $this->totalPages();
}
}
public function paginate(Request $request, mixed ...$additionalArguments): PagedPaginator;
{
$paginator = new PagedPaginator($this, $request, perPage: 50, ...$additionalArguments);
$paginator->setTotalKeyName('pagination.totalAvailable');
$paginator->setPageKeyName('pagination.pageNumber');
return $paginator;
}
I have the same issue, I've tried your custompagintor and it returns the correct number of paginations, but all the n+1 paginations repeat page 1, instead of moving onto page 2/3/4 etc.
My connector code looks like:
public function paginate(Request $request, mixed ...$additionalArguments): CRMSPaginator
{
$paginator = new CRMSPaginator($this, $request, 25, ...$additionalArguments);
$paginator->setLimitKeyName('meta.per_page');
$paginator->setTotalKeyName('meta.total_row_count');
$paginator->setPageKeyName('meta.page');
return $paginator;
}
My pagination code looks like:
$paginator = $current->paginate(new GetOpportunityRequest);
foreach($paginator->json() as $opportunities) {
$pageData[] = $opportunities;
}
@advil0 have you had any joy with this at all?
Hey both, just wanted to let you know this is still on my radar. I'll do some testing on my end and see if I can replicate the issue.
I would also recommend adding the AlwaysThrowOnErrors
trait to your connector so it throws an exception if a page errors, that might help with debugging. You can also use Guzzle's debug
option in your connector/requests config.
$request->config()->add('debug', true);
or
$request->config()->add('debug', fopen('somefile', 'w+'));
@advil0 Did you manage to fix this?
I'm going to close this issue for now.
Hello!
Was wondering if it's possible to use the built-in pagination without supplying a
next_page_url
? The API I'm using only supplies the below for pagination."pagination": { "pageNumber": "1", "pageSize": "100", "totalAvailable": "640" }