class Twilio::REST::Insights::V1::CallContext::EventList
PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
Public Class Methods
Initialize the EventList
@param [Version] version Version
that contains the resource @param [String] call_sid The call_sid @return [EventList] EventList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/insights/v1/call/event.rb 22 def initialize(version, call_sid: nil) 23 super(version) 24 25 # Path Solution 26 @solution = {call_sid: call_sid} 27 @uri = "/Voice/#{@solution[:call_sid]}/Events" 28 end
Public Instance Methods
When passed a block, yields EventInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/insights/v1/call/event.rb 70 def each 71 limits = @version.read_limits 72 73 page = self.page(page_size: limits[:page_size], ) 74 75 @version.stream(page, 76 limit: limits[:limit], 77 page_limit: limits[:page_limit]).each {|x| yield x} 78 end
Retrieve a single page of EventInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of EventInstance
# File lib/twilio-ruby/rest/insights/v1/call/event.rb 106 def get_page(target_url) 107 response = @version.domain.request( 108 'GET', 109 target_url 110 ) 111 EventPage.new(@version, response, @solution) 112 end
Lists EventInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [event.TwilioEdge] edge The edge @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Array] Array of up to limit results
# File lib/twilio-ruby/rest/insights/v1/call/event.rb 42 def list(edge: :unset, limit: nil, page_size: nil) 43 self.stream(edge: edge, limit: limit, page_size: page_size).entries 44 end
Retrieve a single page of EventInstance
records from the API. Request
is executed immediately. @param [event.TwilioEdge] edge The edge @param [String] page_token PageToken provided by the API @param [Integer] page_number Page
Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page
of EventInstance
# File lib/twilio-ruby/rest/insights/v1/call/event.rb 88 def page(edge: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 89 params = Twilio::Values.of({ 90 'Edge' => edge, 91 'PageToken' => page_token, 92 'Page' => page_number, 93 'PageSize' => page_size, 94 }) 95 96 response = @version.page('GET', @uri, params: params) 97 98 EventPage.new(@version, response, @solution) 99 end
Streams EventInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [event.TwilioEdge] edge The edge @param [Integer] limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no limit.
@param [Integer] page_size Number of records to fetch per request, when
not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)
@return [Enumerable] Enumerable that will yield up to limit results
# File lib/twilio-ruby/rest/insights/v1/call/event.rb 58 def stream(edge: :unset, limit: nil, page_size: nil) 59 limits = @version.read_limits(limit, page_size) 60 61 page = self.page(edge: edge, page_size: limits[:page_size], ) 62 63 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 64 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/insights/v1/call/event.rb 116 def to_s 117 '#<Twilio.Insights.V1.EventList>' 118 end