sdk-php-shop icon indicating copy to clipboard operation
sdk-php-shop copied to clipboard

Token-based pagination for /api/mms/orders is available but not implemented

Open gio-vlasov opened this issue 6 months ago • 1 comments

The doc for this endpoint says it has token-based seek pagination available, but this library only allows offset-based pagination for $client->getOrders().

Is there a way to implement that? I tried something like this, by analogy with other endpoints:

namespace App\MiraklApi\Requests;

use Mirakl\Core\Response\Decorator\SeekableCollection;
use Mirakl\MMP\Shop\Domain\Collection\Order\ShopOrderCollection;
use Mirakl\MMP\Shop\Request\Order\Get\GetOrdersRequest;

class GetOrdersRequest_Seekable extends GetOrdersRequest
{
    public function getResponseDecorator()
    {
        return new SeekableCollection(ShopOrderCollection::class, 'data');
    }

}

but had no success.

My use case for this is fetching long order histories over extended period of time in separate processes, as such fetching can produce "429 Too many requests" so it will have to finish later, but store the point up until which it had already fetched the orders. Offset pagination doesn't seem to fit for that use case, as there seem to be no guarantees on the sorting order, so unfetched orders may change position during subsequent requests to lower offset if new orders are created. And token-based pagination is supposed to preserve ordering.

gio-vlasov avatar Aug 13 '24 10:08 gio-vlasov