How paging works with list and stream
mainThe library automatically handles pagination for collections like calls and messages.
list: Eagerly fetches all records (up to the specifiedlimit) and returns them as an array.stream: Returns an enumerator that lazily retrieves pages of records as you iterate over the collection.
You can control the number of records retrieved via limit and the size of each individual page fetch via page_size.
Example of iterating through records using list:
@client.calls.list.each do |call|
puts call.direction
endrequire 'twilio-ruby'
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'
@client = Twilio::REST::Client.new(account_sid, auth_token)
@client.calls.list
.each do |call|
puts call.direction
end