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

Public Class Methods

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

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

resource.

@return [MonthlyList] MonthlyList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb
23 def initialize(version, account_sid: nil)
24   super(version)
25 
26   # Path Solution
27   @solution = {account_sid: account_sid}
28   @uri = "/Accounts/#{@solution[:account_sid]}/Usage/Records/Monthly.json"
29 end

Public Instance Methods

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

When passed a block, yields MonthlyInstance 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/monthly.rb
114 def each
115   limits = @version.read_limits
116 
117   page = self.page(page_size: limits[:page_size], )
118 
119   @version.stream(page,
120                   limit: limits[:limit],
121                   page_limit: limits[:page_limit]).each {|x| yield x}
122 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb
168 def get_page(target_url)
169   response = @version.domain.request(
170       'GET',
171       target_url
172   )
173   MonthlyPage.new(@version, response, @solution)
174 end
list(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) click to toggle source

Lists MonthlyInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [monthly.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/monthly.rb
58 def list(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil)
59   self.stream(
60       category: category,
61       start_date: start_date,
62       end_date: end_date,
63       include_subaccounts: include_subaccounts,
64       limit: limit,
65       page_size: page_size
66   ).entries
67 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 MonthlyInstance records from the API. Request is executed immediately. @param [monthly.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 MonthlyInstance

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb
147 def page(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
148   params = Twilio::Values.of({
149       'Category' => category,
150       'StartDate' => Twilio.serialize_iso8601_date(start_date),
151       'EndDate' => Twilio.serialize_iso8601_date(end_date),
152       'IncludeSubaccounts' => include_subaccounts,
153       'PageToken' => page_token,
154       'Page' => page_number,
155       'PageSize' => page_size,
156   })
157 
158   response = @version.page('GET', @uri, params: params)
159 
160   MonthlyPage.new(@version, response, @solution)
161 end
stream(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil) click to toggle source

Streams MonthlyInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [monthly.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/monthly.rb
 96 def stream(category: :unset, start_date: :unset, end_date: :unset, include_subaccounts: :unset, limit: nil, page_size: nil)
 97   limits = @version.read_limits(limit, page_size)
 98 
 99   page = self.page(
100       category: category,
101       start_date: start_date,
102       end_date: end_date,
103       include_subaccounts: include_subaccounts,
104       page_size: limits[:page_size],
105   )
106 
107   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
108 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/api/v2010/account/usage/record/monthly.rb
178 def to_s
179   '#<Twilio.Api.V2010.MonthlyList>'
180 end