Class: Twilio::REST::Studio::V1::FlowContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/studio/v1/flow.rb,
lib/twilio-ruby/rest/studio/v1/flow/execution.rb,
lib/twilio-ruby/rest/studio/v1/flow/engagement.rb,
lib/twilio-ruby/rest/studio/v1/flow/engagement/step.rb,
lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step.rb,
lib/twilio-ruby/rest/studio/v1/flow/execution/execution_context.rb,
lib/twilio-ruby/rest/studio/v1/flow/engagement/step/step_context.rb,
lib/twilio-ruby/rest/studio/v1/flow/engagement/engagement_context.rb,
lib/twilio-ruby/rest/studio/v1/flow/execution/execution_step/execution_step_context.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Defined Under Namespace

Classes: EngagementContext, EngagementInstance, EngagementList, EngagementPage, ExecutionContext, ExecutionInstance, ExecutionList, ExecutionPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ FlowContext

Initialize the FlowContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    A 34 character string that uniquely identifies this Flow.



156
157
158
159
160
161
162
163
164
165
166
# File 'lib/twilio-ruby/rest/studio/v1/flow.rb', line 156

def initialize(version, sid)
  super(version)

  # Path Solution
  @solution = {sid: sid, }
  @uri = "/Flows/#{@solution[:sid]}"

  # Dependents
  @engagements = nil
  @executions = nil
end

Instance Method Details

#deleteBoolean

Deletes the FlowInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



186
187
188
# File 'lib/twilio-ruby/rest/studio/v1/flow.rb', line 186

def delete
  @version.delete('delete', @uri)
end

#engagements(sid = :unset) ⇒ EngagementList, EngagementContext

Access the engagements

Returns:

Raises:

  • (ArgumentError)


194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/twilio-ruby/rest/studio/v1/flow.rb', line 194

def engagements(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return EngagementContext.new(@version, @solution[:sid], sid, )
  end

  unless @engagements
    @engagements = EngagementList.new(@version, flow_sid: @solution[:sid], )
  end

  @engagements
end

#executions(sid = :unset) ⇒ ExecutionList, ExecutionContext

Access the executions

Returns:

Raises:

  • (ArgumentError)


212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/twilio-ruby/rest/studio/v1/flow.rb', line 212

def executions(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return ExecutionContext.new(@version, @solution[:sid], sid, )
  end

  unless @executions
    @executions = ExecutionList.new(@version, flow_sid: @solution[:sid], )
  end

  @executions
end

#fetchFlowInstance

Fetch a FlowInstance

Returns:



171
172
173
174
175
176
177
178
179
180
181
# File 'lib/twilio-ruby/rest/studio/v1/flow.rb', line 171

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  FlowInstance.new(@version, payload, sid: @solution[:sid], )
end

#to_sObject

Provide a user friendly representation



228
229
230
231
# File 'lib/twilio-ruby/rest/studio/v1/flow.rb', line 228

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Studio.V1.FlowContext #{context}>"
end