class Twilio::REST::Wireless::V1::SimContext::UsageRecordList

Public Class Methods

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

Initialize the UsageRecordList @param [Version] version Version that contains the resource @param [String] sim_sid The SID of the {Sim

resource}[https://www.twilio.com/docs/wireless/api/sim-resource] that this Usage
Record is for.

@return [UsageRecordList] UsageRecordList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/wireless/v1/sim/usage_record.rb
22 def initialize(version, sim_sid: nil)
23   super(version)
24 
25   # Path Solution
26   @solution = {sim_sid: sim_sid}
27   @uri = "/Sims/#{@solution[:sim_sid]}/UsageRecords"
28 end

Public Instance Methods

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

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/sim/usage_record.rb
 92 def each
 93   limits = @version.read_limits
 94 
 95   page = self.page(page_size: limits[:page_size], )
 96 
 97   @version.stream(page,
 98                   limit: limits[:limit],
 99                   page_limit: limits[:page_limit]).each {|x| yield x}
100 end
get_page(target_url) click to toggle source

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/sim/usage_record.rb
138 def get_page(target_url)
139   response = @version.domain.request(
140       'GET',
141       target_url
142   )
143   UsageRecordPage.new(@version, response, @solution)
144 end
list(end_: :unset, start: :unset, granularity: :unset, limit: nil, page_size: nil) click to toggle source

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 occurred on or before this date,

specified in {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
The default is the current time.

@param [Time] start Only include usage that has occurred on or after this date,

specified in {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
The default is one month before the `end` parameter value.

@param [usage_record.Granularity] granularity How to summarize the usage by

time. Can be: `daily`, `hourly`, or `all`. The default is `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/sim/usage_record.rb
50 def list(end_: :unset, start: :unset, granularity: :unset, limit: nil, page_size: nil)
51   self.stream(
52       end_: end_,
53       start: start,
54       granularity: granularity,
55       limit: limit,
56       page_size: page_size
57   ).entries
58 end
page(end_: :unset, start: :unset, granularity: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of UsageRecordInstance records from the API. Request is executed immediately. @param [Time] end_ Only include usage that occurred on or before this date,

specified in {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
The default is the current time.

@param [Time] start Only include usage that has occurred on or after this date,

specified in {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
The default is one month before the `end` parameter value.

@param [usage_record.Granularity] granularity How to summarize the usage by

time. Can be: `daily`, `hourly`, or `all`. The default is `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/sim/usage_record.rb
118 def page(end_: :unset, start: :unset, granularity: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
119   params = Twilio::Values.of({
120       'End' => Twilio.serialize_iso8601_datetime(end_),
121       'Start' => Twilio.serialize_iso8601_datetime(start),
122       'Granularity' => granularity,
123       'PageToken' => page_token,
124       'Page' => page_number,
125       'PageSize' => page_size,
126   })
127 
128   response = @version.page('GET', @uri, params: params)
129 
130   UsageRecordPage.new(@version, response, @solution)
131 end
stream(end_: :unset, start: :unset, granularity: :unset, limit: nil, page_size: nil) click to toggle source

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 occurred on or before this date,

specified in {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
The default is the current time.

@param [Time] start Only include usage that has occurred on or after this date,

specified in {ISO 8601}[https://www.iso.org/iso-8601-date-and-time-format.html].
The default is one month before the `end` parameter value.

@param [usage_record.Granularity] granularity How to summarize the usage by

time. Can be: `daily`, `hourly`, or `all`. The default is `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/sim/usage_record.rb
80 def stream(end_: :unset, start: :unset, granularity: :unset, limit: nil, page_size: nil)
81   limits = @version.read_limits(limit, page_size)
82 
83   page = self.page(end_: end_, start: start, granularity: granularity, page_size: limits[:page_size], )
84 
85   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
86 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/wireless/v1/sim/usage_record.rb
148 def to_s
149   '#<Twilio.Wireless.V1.UsageRecordList>'
150 end