class Twilio::REST::Wireless::V1::CommandList

Public Class Methods

new(version) click to toggle source

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

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

Public Instance Methods

create(command: nil, sim: :unset, callback_method: :unset, callback_url: :unset, command_mode: :unset, include_sid: :unset, delivery_receipt_requested: :unset) click to toggle source

Create the CommandInstance @param [String] command The message body of the Command. Can be plain text in

text mode or a Base64 encoded byte string in binary mode.

@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] callback_method The HTTP method we use to call `callback_url`.

Can be: `POST` or `GET`, and the default is `POST`.

@param [String] callback_url The URL we call using the `callback_url` when the

Command has finished sending, whether the command was delivered or it failed.

@param [command.CommandMode] command_mode The mode to use when sending the SMS

message. Can be: `text` or `binary`. The default SMS mode is `text`.

@param [String] include_sid Whether to include the SID of the command in the

message body. Can be: `none`, `start`, or `end`, and the default behavior is
`none`. When sending a Command to a SIM in text mode, we can automatically
include the SID of the Command in the message body, which could be used to
ensure that the device does not process the same Command more than once.  A
value of `start` will prepend the message with the Command SID, and `end` will
append it to the end, separating the Command SID from the message body with a
space. The length of the Command SID is included in the 160 character limit so
the SMS body must be 128 characters or less before the Command SID is included.

@param [Boolean] delivery_receipt_requested Whether to request delivery receipt

from the recipient. For Commands that request delivery receipt, the Command
state transitions to 'delivered' once the server has received a delivery receipt
from the device. The default value is `true`.

@return [CommandInstance] Created CommandInstance

    # File lib/twilio-ruby/rest/wireless/v1/command.rb
174 def create(command: nil, sim: :unset, callback_method: :unset, callback_url: :unset, command_mode: :unset, include_sid: :unset, delivery_receipt_requested: :unset)
175   data = Twilio::Values.of({
176       'Command' => command,
177       'Sim' => sim,
178       'CallbackMethod' => callback_method,
179       'CallbackUrl' => callback_url,
180       'CommandMode' => command_mode,
181       'IncludeSid' => include_sid,
182       'DeliveryReceiptRequested' => delivery_receipt_requested,
183   })
184 
185   payload = @version.create('POST', @uri, data: data)
186 
187   CommandInstance.new(@version, payload, )
188 end
each() { |x| ... } click to toggle source

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/wireless/v1/command.rb
 93 def each
 94   limits = @version.read_limits
 95 
 96   page = self.page(page_size: limits[:page_size], )
 97 
 98   @version.stream(page,
 99                   limit: limits[:limit],
100                   page_limit: limits[:page_limit]).each {|x| yield x}
101 end
get_page(target_url) click to toggle source

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/wireless/v1/command.rb
139 def get_page(target_url)
140   response = @version.domain.request(
141       'GET',
142       target_url
143   )
144   CommandPage.new(@version, response, @solution)
145 end
list(sim: :unset, status: :unset, direction: :unset, transport: :unset, limit: nil, page_size: nil) click to toggle source

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

resources}[https://www.twilio.com/docs/wireless/api/sim-resource] to read.

@param [command.Status] status The status of the resources to read. Can be:

`queued`, `sent`, `delivered`, `received`, or `failed`.

@param [command.Direction] direction Only return Commands with this direction

value.

@param [command.Transport] transport Only return Commands with this transport

value. Can be: `sms` or `ip`.

@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/wireless/v1/command.rb
45 def list(sim: :unset, status: :unset, direction: :unset, transport: :unset, limit: nil, page_size: nil)
46   self.stream(
47       sim: sim,
48       status: status,
49       direction: direction,
50       transport: transport,
51       limit: limit,
52       page_size: page_size
53   ).entries
54 end
page(sim: :unset, status: :unset, direction: :unset, transport: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

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

resources}[https://www.twilio.com/docs/wireless/api/sim-resource] to read.

@param [command.Status] status The status of the resources to read. Can be:

`queued`, `sent`, `delivered`, `received`, or `failed`.

@param [command.Direction] direction Only return Commands with this direction

value.

@param [command.Transport] transport Only return Commands with this transport

value. Can be: `sms` or `ip`.

@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/wireless/v1/command.rb
118 def page(sim: :unset, status: :unset, direction: :unset, transport: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
119   params = Twilio::Values.of({
120       'Sim' => sim,
121       'Status' => status,
122       'Direction' => direction,
123       'Transport' => transport,
124       'PageToken' => page_token,
125       'Page' => page_number,
126       'PageSize' => page_size,
127   })
128 
129   response = @version.page('GET', @uri, params: params)
130 
131   CommandPage.new(@version, response, @solution)
132 end
stream(sim: :unset, status: :unset, direction: :unset, transport: :unset, limit: nil, page_size: nil) click to toggle source

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

resources}[https://www.twilio.com/docs/wireless/api/sim-resource] to read.

@param [command.Status] status The status of the resources to read. Can be:

`queued`, `sent`, `delivered`, `received`, or `failed`.

@param [command.Direction] direction Only return Commands with this direction

value.

@param [command.Transport] transport Only return Commands with this transport

value. Can be: `sms` or `ip`.

@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/wireless/v1/command.rb
75 def stream(sim: :unset, status: :unset, direction: :unset, transport: :unset, limit: nil, page_size: nil)
76   limits = @version.read_limits(limit, page_size)
77 
78   page = self.page(
79       sim: sim,
80       status: status,
81       direction: direction,
82       transport: transport,
83       page_size: limits[:page_size],
84   )
85 
86   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
87 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/wireless/v1/command.rb
192 def to_s
193   '#<Twilio.Wireless.V1.CommandList>'
194 end