Closed JorikMollie closed 10 months ago
Hi @JorikMollie , thanks for reporting. We'll look into it shortly.
Hi @JorikMollie , we discussed the issue at hand. The problem here is that subscriptions are never 'normal', but nested. All subscriptions are CustomerSubscription
objects one way or another (i.e. when you retrieve a single instance of a subscription, there always is a customer id
in the URL.
So the ObjectList
correctly returns CustomerSubscriptions
on the first pass. But when you call get_next()
on that list, a new ObjectList
is created for the next set of CustomerSubscriptions
, which fails because the generated ObjectList
is missing the required context for creating new CustomerSubscriptions (a Customer
object).
This is, unforunately, a generic issue with the ObjectList
implementation, and it breaks in all places where nested objects are returned by the ObjectList
:
PaymentRefund
objects for multiple payments)PaymentChargeback
objects for multiple payments)PaymentCapture
objects)OrderShipment
objects)CustomerMandate
objects)CustomerSubscription
objects)CustomerSubscription
objects)We are going to see if we can resolve this neatly in a cleaner implementation of the ObjectList
class. For the time being, it could be an option to raise the number of results that a list returns by using client.subscriptions.list(limit=250)
, so no pagination will happen.
This whole issue exists because we need to inject a 'parent' object into the context. The single reason to have this parent in context, is because we need its' ID to inject into the resource path. For objects that don't have a parent (f.i. payments) or objects that have a parent, but are listed outside of a parent context (f.i. client.subscriptions.list()
), this problem simply doesn't exist.
To sum it up:
links
section of parent@JorikMollie I have a working POC that solves this issue in https://github.com/mollie/mollie-api-python/pull/323. It works for Subscriptions AFAICS, and also for Subscription Payments (they nest two levels deep, Subscriptions only one). It needs some work, mostly just refactoring code everywhere.
Issue
When I try to get to the next page of subscriptions, using the function
subscriptions.get_next()
, an error is thrown.What happens
What should happen
The function should retrieve the next page of subscriptions, instead of throwing that error.
Steps to reproduce
Import Mollie API client for python
from mollie.api.client import Client
Initialize client and set API key
mollie_client = Client() mollie_client.set_api_key(API_KEY)
subscriptions = mollie_client.subscriptions.list() subscriptions = subscriptions.get_next() #THIS LINE THROWS ERROR