class Twilio::REST::Preview::Wireless::CommandList
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 CommandList
@param [Version] version Version
that contains the resource @return [CommandList] CommandList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/preview/wireless/command.rb 20 def initialize(version) 21 super(version) 22 23 # Path Solution 24 @solution = {} 25 @uri = "/Commands" 26 end
Public Instance Methods
Create the CommandInstance
@param [String] command The command @param [String] device The device @param [String] sim The sim @param [String] callback_method The callback_method @param [String] callback_url The callback_url @param [String] command_mode The command_mode @param [String] include_sid The include_sid @return [CommandInstance] Created CommandInstance
# File lib/twilio-ruby/rest/preview/wireless/command.rb 147 def create(command: nil, device: :unset, sim: :unset, callback_method: :unset, callback_url: :unset, command_mode: :unset, include_sid: :unset) 148 data = Twilio::Values.of({ 149 'Command' => command, 150 'Device' => device, 151 'Sim' => sim, 152 'CallbackMethod' => callback_method, 153 'CallbackUrl' => callback_url, 154 'CommandMode' => command_mode, 155 'IncludeSid' => include_sid, 156 }) 157 158 payload = @version.create('POST', @uri, data: data) 159 160 CommandInstance.new(@version, payload, ) 161 end
When passed a block, yields CommandInstance
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/command.rb 87 def each 88 limits = @version.read_limits 89 90 page = self.page(page_size: limits[:page_size], ) 91 92 @version.stream(page, 93 limit: limits[:limit], 94 page_limit: limits[:page_limit]).each {|x| yield x} 95 end
Retrieve a single page of CommandInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of CommandInstance
# File lib/twilio-ruby/rest/preview/wireless/command.rb 129 def get_page(target_url) 130 response = @version.domain.request( 131 'GET', 132 target_url 133 ) 134 CommandPage.new(@version, response, @solution) 135 end
Lists CommandInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] device The device @param [String] sim The sim @param [String] status The status @param [String] direction The direction @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/command.rb 43 def list(device: :unset, sim: :unset, status: :unset, direction: :unset, limit: nil, page_size: nil) 44 self.stream( 45 device: device, 46 sim: sim, 47 status: status, 48 direction: direction, 49 limit: limit, 50 page_size: page_size 51 ).entries 52 end
Retrieve a single page of CommandInstance
records from the API. Request
is executed immediately. @param [String] device The device @param [String] sim The sim @param [String] status The status @param [String] direction The direction @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 CommandInstance
# File lib/twilio-ruby/rest/preview/wireless/command.rb 108 def page(device: :unset, sim: :unset, status: :unset, direction: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 109 params = Twilio::Values.of({ 110 'Device' => device, 111 'Sim' => sim, 112 'Status' => status, 113 'Direction' => direction, 114 'PageToken' => page_token, 115 'Page' => page_number, 116 'PageSize' => page_size, 117 }) 118 119 response = @version.page('GET', @uri, params: params) 120 121 CommandPage.new(@version, response, @solution) 122 end
Streams CommandInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] device The device @param [String] sim The sim @param [String] status The status @param [String] direction The direction @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/command.rb 69 def stream(device: :unset, sim: :unset, status: :unset, direction: :unset, limit: nil, page_size: nil) 70 limits = @version.read_limits(limit, page_size) 71 72 page = self.page( 73 device: device, 74 sim: sim, 75 status: status, 76 direction: direction, 77 page_size: limits[:page_size], 78 ) 79 80 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 81 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/preview/wireless/command.rb 165 def to_s 166 '#<Twilio.Preview.Wireless.CommandList>' 167 end