TOKU: payments loop through pages
This commit is contained in:
@ -76,6 +76,13 @@ class Invoice extends AbstractEndPoint
|
||||
}
|
||||
public function resetPayments(): array
|
||||
{
|
||||
$page = 1;
|
||||
$pageSize = 1000;
|
||||
$totalPayments = [];
|
||||
while (true) {
|
||||
if ($page > 100) {
|
||||
break;
|
||||
}
|
||||
try {
|
||||
$request_uri = "/organization/payments?page=1&page_size=1000";
|
||||
$payments = $this->sendGet($request_uri, [200], [404, 422]);
|
||||
@ -83,6 +90,9 @@ class Invoice extends AbstractEndPoint
|
||||
$this->logger->warning($exception, ['request_uri' => $request_uri]);
|
||||
return [];
|
||||
}
|
||||
if (array_key_exists('message', $payments)) {
|
||||
break;
|
||||
}
|
||||
$this->altLogger->info('Reset Payments', ['count' => count($payments), 'payments' => $payments]);
|
||||
$query = [];
|
||||
/*
|
||||
@ -124,7 +134,13 @@ class Invoice extends AbstractEndPoint
|
||||
return [];
|
||||
}
|
||||
$this->altLogger->info('Reset Payments Payload', ['count' => count($payments), 'payments' => $query]);
|
||||
return $payments;
|
||||
$totalPayments = array_merge($totalPayments, $payments);
|
||||
if (count($payments) < $pageSize) {
|
||||
break;
|
||||
}
|
||||
$page++;
|
||||
}
|
||||
return $totalPayments;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user