class Twilio::REST::Wireless::V1::UsageRecordList
Public Class Methods
Initialize the UsageRecordList
@param [Version] version Version
that contains the resource @return [UsageRecordList] UsageRecordList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/wireless/v1/usage_record.rb 18 def initialize(version) 19 super(version) 20 21 # Path Solution 22 @solution = {} 23 @uri = "/UsageRecords" 24 end
Public Instance Methods
When passed a block, yields UsageRecordInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/wireless/v1/usage_record.rb 84 def each 85 limits = @version.read_limits 86 87 page = self.page(page_size: limits[:page_size], ) 88 89 @version.stream(page, 90 limit: limits[:limit], 91 page_limit: limits[:page_limit]).each {|x| yield x} 92 end
Retrieve a single page of UsageRecordInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of UsageRecordInstance
# File lib/twilio-ruby/rest/wireless/v1/usage_record.rb 128 def get_page(target_url) 129 response = @version.domain.request( 130 'GET', 131 target_url 132 ) 133 UsageRecordPage.new(@version, response, @solution) 134 end
Lists UsageRecordInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Time] end_ Only include usage that has occurred on or before this date.
Format is {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
@param [Time] start Only include usage that has occurred on or after this date.
Format is {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
@param [usage_record.Granularity] granularity How to summarize the usage by
time. Can be: `daily`, `hourly`, or `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
@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/wireless/v1/usage_record.rb 44 def list(end_: :unset, start: :unset, granularity: :unset, limit: nil, page_size: nil) 45 self.stream( 46 end_: end_, 47 start: start, 48 granularity: granularity, 49 limit: limit, 50 page_size: page_size 51 ).entries 52 end
Retrieve a single page of UsageRecordInstance
records from the API. Request
is executed immediately. @param [Time] end_ Only include usage that has occurred on or before this date.
Format is {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
@param [Time] start Only include usage that has occurred on or after this date.
Format is {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
@param [usage_record.Granularity] granularity How to summarize the usage by
time. Can be: `daily`, `hourly`, or `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
@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 UsageRecordInstance
# File lib/twilio-ruby/rest/wireless/v1/usage_record.rb 108 def page(end_: :unset, start: :unset, granularity: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 109 params = Twilio::Values.of({ 110 'End' => Twilio.serialize_iso8601_datetime(end_), 111 'Start' => Twilio.serialize_iso8601_datetime(start), 112 'Granularity' => granularity, 113 'PageToken' => page_token, 114 'Page' => page_number, 115 'PageSize' => page_size, 116 }) 117 118 response = @version.page('GET', @uri, params: params) 119 120 UsageRecordPage.new(@version, response, @solution) 121 end
Streams UsageRecordInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Time] end_ Only include usage that has occurred on or before this date.
Format is {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
@param [Time] start Only include usage that has occurred on or after this date.
Format is {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
@param [usage_record.Granularity] granularity How to summarize the usage by
time. Can be: `daily`, `hourly`, or `all`. A value of `all` returns one Usage Record that describes the usage for the entire period.
@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/wireless/v1/usage_record.rb 72 def stream(end_: :unset, start: :unset, granularity: :unset, limit: nil, page_size: nil) 73 limits = @version.read_limits(limit, page_size) 74 75 page = self.page(end_: end_, start: start, granularity: granularity, page_size: limits[:page_size], ) 76 77 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 78 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/wireless/v1/usage_record.rb 138 def to_s 139 '#<Twilio.Wireless.V1.UsageRecordList>' 140 end