SquareConnect V1 documentation indicates that pagination is supported using the Link
, as shown below, in response header.
Link:<https://connect.squareup.com/v1/LOCATION_ID/payments?batch_token=BATCH_TOKEN>;rel='next'
How do I list all payments for a location, in the given date range, say 6 months, using JavaSDK? listPayments
method does not provide a return value with access to pagination.
List<V1Payment> result = apiInstance.listPayments(locationId, order, beginTime, endTime, limit);
Is the only way to paginate is by slicing the date range? If so, depending on the slice size,
limit
is 200, if the time slice is too large
Appreciate any help.
If you have a time based segment (such as all transactions for the last six months) you should use the the time segment in the request and then paginate through all the responses.
The issue you are running into here is that the header based pagination tokens are not exposed in the SDK for the v1 endpoints, (nor would you be able to easily override the url with their results). You can either:
InvokeAPI
which would be a blend between using the SDK and calling the endpoints directly.