class Twilio::REST::Preview::Wireless::SimList
PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact help@twilio.com.
Public Class Methods
Initialize the SimList
@param [Version] version Version
that contains the resource @return [SimList] SimList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/preview/wireless/sim.rb 20 def initialize(version) 21 super(version) 22 23 # Path Solution 24 @solution = {} 25 @uri = "/Sims" 26 end
Public Instance Methods
When passed a block, yields SimInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/preview/wireless/sim.rb 91 def each 92 limits = @version.read_limits 93 94 page = self.page(page_size: limits[:page_size], ) 95 96 @version.stream(page, 97 limit: limits[:limit], 98 page_limit: limits[:page_limit]).each {|x| yield x} 99 end
Retrieve a single page of SimInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of SimInstance
# File lib/twilio-ruby/rest/preview/wireless/sim.rb 135 def get_page(target_url) 136 response = @version.domain.request( 137 'GET', 138 target_url 139 ) 140 SimPage.new(@version, response, @solution) 141 end
Lists SimInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] status The status @param [String] iccid The iccid @param [String] rate_plan The rate_plan @param [String] e_id The e_id @param [String] sim_registration_code The sim_registration_code @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/preview/wireless/sim.rb 44 def list(status: :unset, iccid: :unset, rate_plan: :unset, e_id: :unset, sim_registration_code: :unset, limit: nil, page_size: nil) 45 self.stream( 46 status: status, 47 iccid: iccid, 48 rate_plan: rate_plan, 49 e_id: e_id, 50 sim_registration_code: sim_registration_code, 51 limit: limit, 52 page_size: page_size 53 ).entries 54 end
Retrieve a single page of SimInstance
records from the API. Request
is executed immediately. @param [String] status The status @param [String] iccid The iccid @param [String] rate_plan The rate_plan @param [String] e_id The e_id @param [String] sim_registration_code The sim_registration_code @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 SimInstance
# File lib/twilio-ruby/rest/preview/wireless/sim.rb 113 def page(status: :unset, iccid: :unset, rate_plan: :unset, e_id: :unset, sim_registration_code: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 114 params = Twilio::Values.of({ 115 'Status' => status, 116 'Iccid' => iccid, 117 'RatePlan' => rate_plan, 118 'EId' => e_id, 119 'SimRegistrationCode' => sim_registration_code, 120 'PageToken' => page_token, 121 'Page' => page_number, 122 'PageSize' => page_size, 123 }) 124 125 response = @version.page('GET', @uri, params: params) 126 127 SimPage.new(@version, response, @solution) 128 end
Streams SimInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] status The status @param [String] iccid The iccid @param [String] rate_plan The rate_plan @param [String] e_id The e_id @param [String] sim_registration_code The sim_registration_code @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/preview/wireless/sim.rb 72 def stream(status: :unset, iccid: :unset, rate_plan: :unset, e_id: :unset, sim_registration_code: :unset, limit: nil, page_size: nil) 73 limits = @version.read_limits(limit, page_size) 74 75 page = self.page( 76 status: status, 77 iccid: iccid, 78 rate_plan: rate_plan, 79 e_id: e_id, 80 sim_registration_code: sim_registration_code, 81 page_size: limits[:page_size], 82 ) 83 84 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 85 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/preview/wireless/sim.rb 145 def to_s 146 '#<Twilio.Preview.Wireless.SimList>' 147 end