class Twilio::REST::Supersim::V1::CommandList
PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.
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/supersim/v1/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] sim The `sid` or `unique_name` of the
{SIM}[https://www.twilio.com/docs/wireless/api/sim-resource] to send the Command to.
@param [String] command The message body of the command. @param [String] callback_method The HTTP
method we should use to call
`callback_url`. Can be: `GET` or `POST` and the default is POST.
@param [String] callback_url The URL we should call using the `callback_method`
after we have sent the command.
@return [CommandInstance] Created CommandInstance
# File lib/twilio-ruby/rest/supersim/v1/command.rb 39 def create(sim: nil, command: nil, callback_method: :unset, callback_url: :unset) 40 data = Twilio::Values.of({ 41 'Sim' => sim, 42 'Command' => command, 43 'CallbackMethod' => callback_method, 44 'CallbackUrl' => callback_url, 45 }) 46 47 payload = @version.create('POST', @uri, data: data) 48 49 CommandInstance.new(@version, payload, ) 50 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/supersim/v1/command.rb 116 def each 117 limits = @version.read_limits 118 119 page = self.page(page_size: limits[:page_size], ) 120 121 @version.stream(page, 122 limit: limits[:limit], 123 page_limit: limits[:page_limit]).each {|x| yield x} 124 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/supersim/v1/command.rb 163 def get_page(target_url) 164 response = @version.domain.request( 165 'GET', 166 target_url 167 ) 168 CommandPage.new(@version, response, @solution) 169 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] sim The SID or unique name of the Sim that Command was sent to
or from.
@param [command.Status] status The status of the Command. Can be: `queued`,
`sent`, `delivered`, `received` or `failed`. See the {Command Status Values}[https://www.twilio.com/docs/wireless/api/command-resource#status-values] for a description of each.
@param [command.Direction] direction The direction of the Command. Can be
`to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
@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/supersim/v1/command.rb 73 def list(sim: :unset, status: :unset, direction: :unset, limit: nil, page_size: nil) 74 self.stream( 75 sim: sim, 76 status: status, 77 direction: direction, 78 limit: limit, 79 page_size: page_size 80 ).entries 81 end
Retrieve a single page of CommandInstance
records from the API. Request
is executed immediately. @param [String] sim The SID or unique name of the Sim that Command was sent to
or from.
@param [command.Status] status The status of the Command. Can be: `queued`,
`sent`, `delivered`, `received` or `failed`. See the {Command Status Values}[https://www.twilio.com/docs/wireless/api/command-resource#status-values] for a description of each.
@param [command.Direction] direction The direction of the Command. Can be
`to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
@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/supersim/v1/command.rb 143 def page(sim: :unset, status: :unset, direction: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 144 params = Twilio::Values.of({ 145 'Sim' => sim, 146 'Status' => status, 147 'Direction' => direction, 148 'PageToken' => page_token, 149 'Page' => page_number, 150 'PageSize' => page_size, 151 }) 152 153 response = @version.page('GET', @uri, params: params) 154 155 CommandPage.new(@version, response, @solution) 156 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] sim The SID or unique name of the Sim that Command was sent to
or from.
@param [command.Status] status The status of the Command. Can be: `queued`,
`sent`, `delivered`, `received` or `failed`. See the {Command Status Values}[https://www.twilio.com/docs/wireless/api/command-resource#status-values] for a description of each.
@param [command.Direction] direction The direction of the Command. Can be
`to_sim` or `from_sim`. The value of `to_sim` is synonymous with the term `mobile terminated`, and `from_sim` is synonymous with the term `mobile originated`.
@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/supersim/v1/command.rb 104 def stream(sim: :unset, status: :unset, direction: :unset, limit: nil, page_size: nil) 105 limits = @version.read_limits(limit, page_size) 106 107 page = self.page(sim: sim, status: status, direction: direction, page_size: limits[:page_size], ) 108 109 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 110 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/supersim/v1/command.rb 173 def to_s 174 '#<Twilio.Supersim.V1.CommandList>' 175 end