class Twilio::REST::Api::V2010::AccountContext::UsageList::RecordList

Public Class Methods

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

Initialize the RecordList @param [Version] version Version that contains the resource @param [String] account_sid A 34 character string that uniquely identifies this

resource.

@return [RecordList] RecordList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
22 def initialize(version, account_sid: nil)
23   super(version)
24 
25   # Path Solution
26   @solution = {account_sid: account_sid}
27   @uri = "/Accounts/#{@solution[:account_sid]}/Usage/Records.json"
28 
29   # Components
30   @all_time = nil
31   @daily = nil
32   @last_month = nil
33   @monthly = nil
34   @this_month = nil
35   @today = nil
36   @yearly = nil
37   @yesterday = nil
38 end

Public Instance Methods

all_time() click to toggle source

Access the all_time @return [AllTimeList] @return [AllTimeContext]

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
189 def all_time
190   @all_time ||= AllTimeList.new(@version, account_sid: @solution[:account_sid], )
191 end
daily() click to toggle source

Access the daily @return [DailyList] @return [DailyContext]

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
197 def daily
198   @daily ||= DailyList.new(@version, account_sid: @solution[:account_sid], )
199 end
each() { |x| ... } click to toggle source

When passed a block, yields RecordInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
123 def each
124   limits = @version.read_limits
125 
126   page = self.page(page_size: limits[:page_size], )
127 
128   @version.stream(page,
129                   limit: limits[:limit],
130                   page_limit: limits[:page_limit]).each {|x| yield x}
131 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
177 def get_page(target_url)
178   response = @version.domain.request(
179       'GET',
180       target_url
181   )
182   RecordPage.new(@version, response, @solution)
183 end
last_month() click to toggle source

Access the last_month @return [LastMonthList] @return [LastMonthContext]

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
205 def last_month
206   @last_month ||= LastMonthList.new(@version, account_sid: @solution[:account_sid], )
207 end
list(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) click to toggle source

Lists RecordInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [record.Category] category The {usage

category}[https://www.twilio.com/docs/usage/api/usage-record#usage-categories]
of the UsageRecord resources to read. Only UsageRecord resources in the
specified category are retrieved.

@param [Date] start_date Only include usage that has occurred on or after this

date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify
offsets from the current date, such as: `-30days`, which will set the start date
to be 30 days before the current date.

@param [Date] end_date Only include usage that occurred on or before this date.

Specify the date in GMT and format as `YYYY-MM-DD`.  You can also specify
offsets from the current date, such as: `+30days`, which will set the end date
to 30 days from the current date.

@param [Boolean] include_subaccounts Whether to include usage from the master

account and all its subaccounts. Can be: `true` (the default) to include usage
from the master account and all subaccounts or `false` to retrieve usage from
only the specified account.

@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/api/v2010/account/usage/record.rb
67 def list(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil)
68   self.stream(
69       category: category,
70       start_date: start_date,
71       end_date: end_date,
72       include_subaccounts: include_subaccounts,
73       limit: limit,
74       page_size: page_size
75   ).entries
76 end
monthly() click to toggle source

Access the monthly @return [MonthlyList] @return [MonthlyContext]

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
213 def monthly
214   @monthly ||= MonthlyList.new(@version, account_sid: @solution[:account_sid], )
215 end
page(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of RecordInstance records from the API. Request is executed immediately. @param [record.Category] category The {usage

category}[https://www.twilio.com/docs/usage/api/usage-record#usage-categories]
of the UsageRecord resources to read. Only UsageRecord resources in the
specified category are retrieved.

@param [Date] start_date Only include usage that has occurred on or after this

date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify
offsets from the current date, such as: `-30days`, which will set the start date
to be 30 days before the current date.

@param [Date] end_date Only include usage that occurred on or before this date.

Specify the date in GMT and format as `YYYY-MM-DD`.  You can also specify
offsets from the current date, such as: `+30days`, which will set the end date
to 30 days from the current date.

@param [Boolean] include_subaccounts Whether to include usage from the master

account and all its subaccounts. Can be: `true` (the default) to include usage
from the master account and all subaccounts or `false` to retrieve usage from
only the specified account.

@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 RecordInstance

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
156 def page(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
157   params = Twilio::Values.of({
158       'Category' => category,
159       'StartDate' => Twilio.serialize_iso8601_date(start_date),
160       'EndDate' => Twilio.serialize_iso8601_date(end_date),
161       'IncludeSubaccounts' => include_subaccounts,
162       'PageToken' => page_token,
163       'Page' => page_number,
164       'PageSize' => page_size,
165   })
166 
167   response = @version.page('GET', @uri, params: params)
168 
169   RecordPage.new(@version, response, @solution)
170 end
stream(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) click to toggle source

Streams RecordInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [record.Category] category The {usage

category}[https://www.twilio.com/docs/usage/api/usage-record#usage-categories]
of the UsageRecord resources to read. Only UsageRecord resources in the
specified category are retrieved.

@param [Date] start_date Only include usage that has occurred on or after this

date. Specify the date in GMT and format as `YYYY-MM-DD`. You can also specify
offsets from the current date, such as: `-30days`, which will set the start date
to be 30 days before the current date.

@param [Date] end_date Only include usage that occurred on or before this date.

Specify the date in GMT and format as `YYYY-MM-DD`.  You can also specify
offsets from the current date, such as: `+30days`, which will set the end date
to 30 days from the current date.

@param [Boolean] include_subaccounts Whether to include usage from the master

account and all its subaccounts. Can be: `true` (the default) to include usage
from the master account and all subaccounts or `false` to retrieve usage from
only the specified account.

@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/api/v2010/account/usage/record.rb
105 def stream(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil)
106   limits = @version.read_limits(limit, page_size)
107 
108   page = self.page(
109       category: category,
110       start_date: start_date,
111       end_date: end_date,
112       include_subaccounts: include_subaccounts,
113       page_size: limits[:page_size],
114   )
115 
116   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
117 end
this_month() click to toggle source

Access the this_month @return [ThisMonthList] @return [ThisMonthContext]

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
221 def this_month
222   @this_month ||= ThisMonthList.new(@version, account_sid: @solution[:account_sid], )
223 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
251 def to_s
252   '#<Twilio.Api.V2010.RecordList>'
253 end
today() click to toggle source

Access the today @return [TodayList] @return [TodayContext]

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
229 def today
230   @today ||= TodayList.new(@version, account_sid: @solution[:account_sid], )
231 end
yearly() click to toggle source

Access the yearly @return [YearlyList] @return [YearlyContext]

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
237 def yearly
238   @yearly ||= YearlyList.new(@version, account_sid: @solution[:account_sid], )
239 end
yesterday() click to toggle source

Access the yesterday @return [YesterdayList] @return [YesterdayContext]

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record.rb
245 def yesterday
246   @yesterday ||= YesterdayList.new(@version, account_sid: @solution[:account_sid], )
247 end