twilio / twilio-ruby

A Ruby gem for communicating with the Twilio API and generating TwiML
MIT License
1.35k stars 462 forks source link

Conversations REST API: Unable to retrieve last page #562

Closed ngouy closed 3 years ago

ngouy commented 3 years ago

Issue Summary

When querying a list, I am trying to retrieve only the last of something (if I understand it well, every of your REST API resources lists are sorted by updatedDate

As of today in the twilio conversation API, there is no way, when querying multiple resources at once, to:

For the sorting, it is what is it, can't force anyone to implement it. So I can't query the last items (which with a potential sorting would be the first) of a resource index.

As for the last page/resource count, there is a meta attribute that all "index" responses include. But it only includes current/previous/next page links, and the current page size It would be very useful if it also included AT LEAST one of the following:

With that I would be able to at least retrieve the "last" of the list with 2 calls, the first one would include all of the necessary data to retrieve the last page (and so resource)

"fun fact", I'm already able to do that today but it's ugly: In my first call, I'm querying the n'th page (where n is a very large number with no chance of hitting an actual page with resources, like 99_999, and the previous page link leads me to the last page with an actual resource in it

image Notice I'm returned with a PageToken=PT9 which means I have, with current page size, 9 pages. When querying it with exact given params, I'm respond with, as expected, the last item of the given resource list

image

Technical details:

shwetha-manvinkurke commented 3 years ago

@ngouy have you explored the pagination feature the library offers and see if that helps? You could do a list to get the total number of records and if you know the total number of records and the page size, in theory you can figure out what the last page is and query just that page.

shwetha-manvinkurke commented 3 years ago

Closing due to inactivity. Feel free to open another issue if further help is needed.