twilio / twilio-ruby

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

request for `From` pagination parameter #251

Closed cainlevy closed 4 years ago

cainlevy commented 7 years ago

Version: 5.0.0.rc17 API Subdomain (api/taskrouter/ip_messaging): ip_messaging

Feature Request

The JavaScript SDK appears to support a From pagination parameter on Messages, allowing the client to send a Message SID for resuming pagination from a point in time. This cursor-based pagination would also be helpful on the REST API (and in the Ruby client). Without it, the pagination method used by list and stream has the potential to miss messages if other messages are deleted during an enumeration.

For example, suppose messages with indexes 0, 1, 2, 3, and 4 and a page size of 3. The first page would return [0, 1, 2]. If 2 is deleted before pagination continues, then page 2 will only contain [4].

Additionally, exposing a From parameter through the Ruby client would allow developers to efficiently implement batched email notifications by querying for all messages since a horizon. Without From, I must stream through the whole list (from the beginning, unless #250 may be fixed) until finding the horizon.

jingming commented 6 years ago

@carlsolivier Is this something that we plan on supporting in the future for the API?

childish-sambino commented 4 years ago

The message list API now contains a few filters, including date filtering, and is included in the Ruby helper lib. As far as I know, there is no plan to support skipping to a particular page in the result set. Each page of results contains a key that is used to fetch the next page of results. If an item is deleted mid-paging, I don't think it affects the rest of the result set as the page key is based on the last record returned and is not a simple index, but I've not tested this. If you've seen this happening and can provide some samples code which illustrates the problem (in a post-RC release), then I can investigate further. Closing for now as I don't think this is an issue and additional filtering capability should meet your use case. Feel free to open if it's still an issue.