Skip to content

Commit

Permalink
Merge pull request #702 from mollie/feature/add-auto-pagination-helpe…
Browse files Browse the repository at this point in the history
…r-methods

Feature/add auto pagination helper methods
  • Loading branch information
Naoray authored Nov 6, 2023
2 parents b2934d7 + 657fbad commit 642f1b8
Show file tree
Hide file tree
Showing 28 changed files with 622 additions and 103 deletions.
6 changes: 3 additions & 3 deletions src/Endpoints/BalanceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Balance;
use Mollie\Api\Resources\BalanceCollection;
use Mollie\Api\Resources\BaseCollection;
use Mollie\Api\Resources\LazyCollection;

class BalanceEndpoint extends CollectionEndpointAbstract
{
Expand Down Expand Up @@ -89,9 +89,9 @@ public function page(?string $from = null, ?int $limit = null, array $parameters
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
14 changes: 7 additions & 7 deletions src/Endpoints/BalanceTransactionEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\Balance;
use Mollie\Api\Resources\BalanceTransaction;
use Mollie\Api\Resources\BalanceTransactionCollection;
use Mollie\Api\Resources\LazyCollection;

class BalanceTransactionEndpoint extends CollectionEndpointAbstract
{
Expand Down Expand Up @@ -58,9 +58,9 @@ public function listFor(Balance $balance, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Balance $balance, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Balance $balance, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($balance->id, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -88,9 +88,9 @@ public function listForId(string $balanceId, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $balanceId, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $balanceId, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $balanceId;

Expand Down Expand Up @@ -118,9 +118,9 @@ public function listForPrimary(array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForPrimary(array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForPrimary(array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = "primary";

Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/ChargebackEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Chargeback;
use Mollie\Api\Resources\ChargebackCollection;
use Mollie\Api\Resources\LazyCollection;

class ChargebackEndpoint extends CollectionEndpointAbstract
{
Expand Down Expand Up @@ -57,9 +57,9 @@ public function page(?string $from = null, ?int $limit = null, array $parameters
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/ClientEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Client;
use Mollie\Api\Resources\ClientCollection;
use Mollie\Api\Resources\LazyCollection;

class ClientEndpoint extends CollectionEndpointAbstract
{
Expand Down Expand Up @@ -76,9 +76,9 @@ public function page(?string $from = null, ?int $limit = null, array $parameters
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/CollectionEndpointAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\BaseCollection;
use Mollie\Api\Resources\CursorCollection;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\ResourceFactory;

abstract class CollectionEndpointAbstract extends EndpointAbstract
Expand Down Expand Up @@ -49,9 +49,9 @@ protected function rest_list(?string $from = null, ?int $limit = null, array $fi
* @param int $limit
* @param array $filters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
* @return Generator
* @return LazyCollection
*/
protected function rest_iterator(?string $from = null, ?int $limit = null, array $filters = [], bool $iterateBackwards = false): Generator
protected function rest_iterator(?string $from = null, ?int $limit = null, array $filters = [], bool $iterateBackwards = false): LazyCollection
{
/** @var CursorCollection $page */
$page = $this->rest_list($from, $limit, $filters);
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/CustomerEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Customer;
use Mollie\Api\Resources\CustomerCollection;
use Mollie\Api\Resources\LazyCollection;

class CustomerEndpoint extends CollectionEndpointAbstract
{
Expand Down Expand Up @@ -128,9 +128,9 @@ public function page(?string $from = null, ?int $limit = null, array $parameters
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Endpoints/CustomerPaymentsEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\Customer;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentCollection;

Expand Down Expand Up @@ -89,9 +89,9 @@ public function listFor(Customer $customer, ?string $from = null, ?int $limit =
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($customer->id, $from, $limit, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -121,9 +121,9 @@ public function listForId($customerId, ?string $from = null, ?int $limit = null,
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $customerId;

Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/InvoiceEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\Invoice;
use Mollie\Api\Resources\InvoiceCollection;
use Mollie\Api\Resources\LazyCollection;

class InvoiceEndpoint extends CollectionEndpointAbstract
{
Expand Down Expand Up @@ -86,9 +86,9 @@ public function all(array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Endpoints/MandateEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\Customer;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Mandate;
use Mollie\Api\Resources\MandateCollection;

Expand Down Expand Up @@ -113,9 +113,9 @@ public function listFor(Customer $customer, $from = null, $limit = null, array $
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Customer $customer, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($customer->id, $from, $limit, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -145,9 +145,9 @@ public function listForId($customerId, $from = null, $limit = null, array $param
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $customerId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $customerId;

Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/OrderEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Order;
use Mollie\Api\Resources\OrderCollection;

Expand Down Expand Up @@ -137,9 +137,9 @@ public function page(?string $from = null, ?int $limit = null, array $parameters
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Endpoints/PaymentCaptureEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\Capture;
use Mollie\Api\Resources\CaptureCollection;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;

class PaymentCaptureEndpoint extends CollectionEndpointAbstract
Expand Down Expand Up @@ -115,9 +115,9 @@ public function listFor(Payment $payment, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($payment->id, $from, $limit, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -145,9 +145,9 @@ public function listForId($paymentId, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $paymentId;

Expand Down
10 changes: 5 additions & 5 deletions src/Endpoints/PaymentChargebackEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Resources\Chargeback;
use Mollie\Api\Resources\ChargebackCollection;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;

class PaymentChargebackEndpoint extends CollectionEndpointAbstract
Expand Down Expand Up @@ -83,9 +83,9 @@ public function listFor(Payment $payment, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorFor(Payment $payment, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->iteratorForId($payment->id, $from, $limit, $parameters, $iterateBackwards);
}
Expand Down Expand Up @@ -113,9 +113,9 @@ public function listForId($paymentId, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iteratorForId(string $paymentId, ?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
$this->parentId = $paymentId;

Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/PaymentEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentCollection;
use Mollie\Api\Resources\Refund;
Expand Down Expand Up @@ -149,9 +149,9 @@ public function page($from = null, $limit = null, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
6 changes: 3 additions & 3 deletions src/Endpoints/PaymentLinkEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Mollie\Api\Endpoints;

use Generator;
use Mollie\Api\Exceptions\ApiException;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentLink;
use Mollie\Api\Resources\PaymentLinkCollection;
Expand Down Expand Up @@ -94,9 +94,9 @@ public function page($from = null, $limit = null, array $parameters = [])
* @param array $parameters
* @param bool $iterateBackwards Set to true for reverse order iteration (default is false).
*
* @return Generator
* @return LazyCollection
*/
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): Generator
public function iterator(?string $from = null, ?int $limit = null, array $parameters = [], bool $iterateBackwards = false): LazyCollection
{
return $this->rest_iterator($from, $limit, $parameters, $iterateBackwards);
}
Expand Down
Loading

0 comments on commit 642f1b8

Please sign in to comment.