class Twilio::REST::Studio::V2::FlowContext::ExecutionList
Public Class Methods
Initialize the ExecutionList
@param [Version] version Version
that contains the resource @param [String] flow_sid The SID of the Flow. @return [ExecutionList] ExecutionList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/studio/v2/flow/execution.rb 20 def initialize(version, flow_sid: nil) 21 super(version) 22 23 # Path Solution 24 @solution = {flow_sid: flow_sid} 25 @uri = "/Flows/#{@solution[:flow_sid]}/Executions" 26 end
Public Instance Methods
Create the ExecutionInstance
@param [String] to The Contact phone number to start a Studio
Flow Execution,
available as variable `{{contact.channel.address}}`.
@param [String] from The Twilio
phone number to send messages or initiate calls
from during the Flow's Execution. Available as variable `{{flow.channel.address}}`. For SMS, this can also be a Messaging Service SID.
@param [Hash] parameters JSON data that will be added to the Flow's context and
that can be accessed as variables inside your Flow. For example, if you pass in `Parameters={"name":"Zeke"}`, a widget in your Flow can reference the variable `{{flow.data.name}}`, which returns "Zeke". Note: the JSON value must explicitly be passed as a string, not as a hash object. Depending on your particular HTTP library, you may need to add quotes or URL encode the JSON string.
@return [ExecutionInstance] Created ExecutionInstance
# File lib/twilio-ruby/rest/studio/v2/flow/execution.rb 151 def create(to: nil, from: nil, parameters: :unset) 152 data = Twilio::Values.of({ 153 'To' => to, 154 'From' => from, 155 'Parameters' => Twilio.serialize_object(parameters), 156 }) 157 158 payload = @version.create('POST', @uri, data: data) 159 160 ExecutionInstance.new(@version, payload, flow_sid: @solution[:flow_sid], ) 161 end
When passed a block, yields ExecutionInstance
records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.
# File lib/twilio-ruby/rest/studio/v2/flow/execution.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 ExecutionInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of ExecutionInstance
# File lib/twilio-ruby/rest/studio/v2/flow/execution.rb 129 def get_page(target_url) 130 response = @version.domain.request( 131 'GET', 132 target_url 133 ) 134 ExecutionPage.new(@version, response, @solution) 135 end
Lists ExecutionInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Time] date_created_from Only show Execution resources starting on or
after this {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] date-time, given as `YYYY-MM-DDThh:mm:ss-hh:mm`.
@param [Time] date_created_to Only show Execution resources starting before this
{ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] date-time, given as `YYYY-MM-DDThh:mm:ss-hh:mm`.
@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/studio/v2/flow/execution.rb 45 def list(date_created_from: :unset, date_created_to: :unset, limit: nil, page_size: nil) 46 self.stream( 47 date_created_from: date_created_from, 48 date_created_to: date_created_to, 49 limit: limit, 50 page_size: page_size 51 ).entries 52 end
Retrieve a single page of ExecutionInstance
records from the API. Request
is executed immediately. @param [Time] date_created_from Only show Execution resources starting on or
after this {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] date-time, given as `YYYY-MM-DDThh:mm:ss-hh:mm`.
@param [Time] date_created_to Only show Execution resources starting before this
{ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] date-time, given as `YYYY-MM-DDThh:mm:ss-hh:mm`.
@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 ExecutionInstance
# File lib/twilio-ruby/rest/studio/v2/flow/execution.rb 110 def page(date_created_from: :unset, date_created_to: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 111 params = Twilio::Values.of({ 112 'DateCreatedFrom' => Twilio.serialize_iso8601_datetime(date_created_from), 113 'DateCreatedTo' => Twilio.serialize_iso8601_datetime(date_created_to), 114 'PageToken' => page_token, 115 'Page' => page_number, 116 'PageSize' => page_size, 117 }) 118 119 response = @version.page('GET', @uri, params: params) 120 121 ExecutionPage.new(@version, response, @solution) 122 end
Streams ExecutionInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Time] date_created_from Only show Execution resources starting on or
after this {ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] date-time, given as `YYYY-MM-DDThh:mm:ss-hh:mm`.
@param [Time] date_created_to Only show Execution resources starting before this
{ISO 8601}[https://en.wikipedia.org/wiki/ISO_8601] date-time, given as `YYYY-MM-DDThh:mm:ss-hh:mm`.
@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/studio/v2/flow/execution.rb 71 def stream(date_created_from: :unset, date_created_to: :unset, limit: nil, page_size: nil) 72 limits = @version.read_limits(limit, page_size) 73 74 page = self.page( 75 date_created_from: date_created_from, 76 date_created_to: date_created_to, 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/studio/v2/flow/execution.rb 165 def to_s 166 '#<Twilio.Studio.V2.ExecutionList>' 167 end