class Twilio::REST::Api::V2010::AccountList

Public Class Methods

new(version) click to toggle source

Initialize the AccountList @param [Version] version Version that contains the resource @return [AccountList] AccountList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/api/v2010/account.rb
18 def initialize(version)
19   super(version)
20 
21   # Path Solution
22   @solution = {}
23   @uri = "/Accounts.json"
24 end

Public Instance Methods

create(friendly_name: :unset) click to toggle source

Create the AccountInstance @param [String] friendly_name A human readable description of the account to

create, defaults to `SubAccount Created at {YYYY-MM-DD HH:MM meridian}`

@return [AccountInstance] Created AccountInstance

   # File lib/twilio-ruby/rest/api/v2010/account.rb
31 def create(friendly_name: :unset)
32   data = Twilio::Values.of({'FriendlyName' => friendly_name, })
33 
34   payload = @version.create('POST', @uri, data: data)
35 
36   AccountInstance.new(@version, payload, )
37 end
each() { |x| ... } click to toggle source

When passed a block, yields AccountInstance 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.rb
90 def each
91   limits = @version.read_limits
92 
93   page = self.page(page_size: limits[:page_size], )
94 
95   @version.stream(page,
96                   limit: limits[:limit],
97                   page_limit: limits[:page_limit]).each {|x| yield x}
98 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/api/v2010/account.rb
130 def get_page(target_url)
131   response = @version.domain.request(
132       'GET',
133       target_url
134   )
135   AccountPage.new(@version, response, @solution)
136 end
list(friendly_name: :unset, status: :unset, limit: nil, page_size: nil) click to toggle source

Lists AccountInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] friendly_name Only return the Account resources with friendly

names that exactly match this name.

@param [account.Status] status Only return Account resources with the given

status. Can be `closed`, `suspended` or `active`.

@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.rb
54 def list(friendly_name: :unset, status: :unset, limit: nil, page_size: nil)
55   self.stream(
56       friendly_name: friendly_name,
57       status: status,
58       limit: limit,
59       page_size: page_size
60   ).entries
61 end
page(friendly_name: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of AccountInstance records from the API. Request is executed immediately. @param [String] friendly_name Only return the Account resources with friendly

names that exactly match this name.

@param [account.Status] status Only return Account resources with the given

status. Can be `closed`, `suspended` or `active`.

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

    # File lib/twilio-ruby/rest/api/v2010/account.rb
111 def page(friendly_name: :unset, status: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
112   params = Twilio::Values.of({
113       'FriendlyName' => friendly_name,
114       'Status' => status,
115       'PageToken' => page_token,
116       'Page' => page_number,
117       'PageSize' => page_size,
118   })
119 
120   response = @version.page('GET', @uri, params: params)
121 
122   AccountPage.new(@version, response, @solution)
123 end
stream(friendly_name: :unset, status: :unset, limit: nil, page_size: nil) click to toggle source

Streams AccountInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] friendly_name Only return the Account resources with friendly

names that exactly match this name.

@param [account.Status] status Only return Account resources with the given

status. Can be `closed`, `suspended` or `active`.

@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.rb
78 def stream(friendly_name: :unset, status: :unset, limit: nil, page_size: nil)
79   limits = @version.read_limits(limit, page_size)
80 
81   page = self.page(friendly_name: friendly_name, status: status, page_size: limits[:page_size], )
82 
83   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
84 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/api/v2010/account.rb
140 def to_s
141   '#<Twilio.Api.V2010.AccountList>'
142 end