Hello, I can use some assistance with setting up pagination to access the Bold Advanced v1 subscriptions API. The subscription API documentation states (Bold v1 subscription docs):
GET /api/third_party/v2/subscriptions?shop={myshopifyDomain}&since_id={since_id}
This endpoint retrieves a filtered page of the store's subscriptions. This endpoint is paginated, returning a page with 50 results. To retrieve the next page of results use the greatest subscription id in a subsequent request.
So, in order to paginate I need to populate the since_id parameter with the last subscription id for each API call. Below is the API response body from the above call (since_id would either be empty or 0 for the first call):
{
"subscriptions": [
{
"id": 1122334,
"shopify_customer_id": 9876543210123,
"interval_number": 1,
"interval_type_id": 3,
"first_name": "Aaron",
"last_name": "Test",
"customer_email": "a.test@example.com",
},
{
"id": 1122345,
"shopify_customer_id": 9876543210234,
"interval_number": 1,
"interval_type_id": 3,
"first_name": "Bill",
"last_name": "Person",
"customer_email": "b.person@example.com",
},
{
"id": 1122456,
"shopify_customer_id": 9876543210345,
"interval_number": 1,
"interval_type_id": 3,
"first_name": "Peter",
"last_name": "Bilt",
"customer_email": "p.bilt@example.com",
},
....
{
"id": 1122567,
"shopify_customer_id": 9876543210456,
"interval_number": 5,
"interval_type_id": 3,
"first_name": "Jonathan",
"last_name": "Seagull",
"customer_email": "j.seagull@example.com",
},
{
"id": 1122678,
"shopify_customer_id": 9876543210567,
"interval_number": 5,
"interval_type_id": 3,
"first_name": "Test",
"last_name": "User",
"customer_email": "t.user@example.com",
}
]
}
There is nothing in the response body that tells me anything about how many records there are, how to paginate, etc. As the consumer we're supposed to simply grab the last subscription id in the array and pass it to the since_id param in the next API call.
My question is how do we do this within integrator? I have tried a few approaches, the following is the closest I've gotten to getting something to work:
In the Relative URI builder I've compared @index to '4' because in my test there are only 5 entries, but I would set this to 49 if this were to pull the entire page of 50 subs. So, this is difficult because a) it's not really working for subsequent calls (it's not paging, I'm only pulling the first 50 subs) and b) we never know how many subs there may be so there's no way to know how many the last page may contain and, if the last page has less than 50 sub records, it will always fail on the last page and/or return the first page since the value of since_id would be empty. Testing in my dev env I'm only ever pulling the first 50 subs, it doesn't appear to be making any subsequent calls, and we have around 280 subs so the last page would be less than 50 (the next call would have an empty since_id param and I'd get the first 50 subs again).
I'm really scratching my head on this. I would like to use integrator to schedule and pull this data and not have to write a custom loader to do this for me.
Any help would be appreciated! Thanks!