class Twilio::REST::Insights::V1::CallContext::MetricList

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

new(version, call_sid: nil) click to toggle source

Initialize the MetricList @param [Version] version Version that contains the resource @param [String] call_sid The call_sid @return [MetricList] MetricList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/insights/v1/call/metric.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]}/Metrics"
28 end

Public Instance Methods

each() { |x| ... } click to toggle source

When passed a block, yields MetricInstance 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/metric.rb
72 def each
73   limits = @version.read_limits
74 
75   page = self.page(page_size: limits[:page_size], )
76 
77   @version.stream(page,
78                   limit: limits[:limit],
79                   page_limit: limits[:page_limit]).each {|x| yield x}
80 end
get_page(target_url) click to toggle source

Retrieve a single page of MetricInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of MetricInstance

    # File lib/twilio-ruby/rest/insights/v1/call/metric.rb
110 def get_page(target_url)
111   response = @version.domain.request(
112       'GET',
113       target_url
114   )
115   MetricPage.new(@version, response, @solution)
116 end
list(edge: :unset, direction: :unset, limit: nil, page_size: nil) click to toggle source

Lists MetricInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [metric.TwilioEdge] edge The edge @param [metric.StreamDirection] direction The direction @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/metric.rb
43 def list(edge: :unset, direction: :unset, limit: nil, page_size: nil)
44   self.stream(edge: edge, direction: direction, limit: limit, page_size: page_size).entries
45 end
page(edge: :unset, direction: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of MetricInstance records from the API. Request is executed immediately. @param [metric.TwilioEdge] edge The edge @param [metric.StreamDirection] direction The direction @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 MetricInstance

    # File lib/twilio-ruby/rest/insights/v1/call/metric.rb
 91 def page(edge: :unset, direction: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
 92   params = Twilio::Values.of({
 93       'Edge' => edge,
 94       'Direction' => direction,
 95       'PageToken' => page_token,
 96       'Page' => page_number,
 97       'PageSize' => page_size,
 98   })
 99 
100   response = @version.page('GET', @uri, params: params)
101 
102   MetricPage.new(@version, response, @solution)
103 end
stream(edge: :unset, direction: :unset, limit: nil, page_size: nil) click to toggle source

Streams MetricInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [metric.TwilioEdge] edge The edge @param [metric.StreamDirection] direction The direction @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/metric.rb
60 def stream(edge: :unset, direction: :unset, limit: nil, page_size: nil)
61   limits = @version.read_limits(limit, page_size)
62 
63   page = self.page(edge: edge, direction: direction, page_size: limits[:page_size], )
64 
65   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
66 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/insights/v1/call/metric.rb
120 def to_s
121   '#<Twilio.Insights.V1.MetricList>'
122 end