Class: Twilio::REST::Studio::V2::FlowContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/studio/v2/flow.rb,
lib/twilio-ruby/rest/studio/v2/flow/execution.rb,
lib/twilio-ruby/rest/studio/v2/flow/test_user.rb,
lib/twilio-ruby/rest/studio/v2/flow/flow_revision.rb,
lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step.rb,
lib/twilio-ruby/rest/studio/v2/flow/execution/execution_context.rb,
lib/twilio-ruby/rest/studio/v2/flow/execution/execution_step/execution_step_context.rb

Defined Under Namespace

Classes: ExecutionContext, ExecutionInstance, ExecutionList, ExecutionPage, FlowRevisionContext, FlowRevisionInstance, FlowRevisionList, FlowRevisionPage, FlowTestUserContext, FlowTestUserInstance, FlowTestUserList, FlowTestUserPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ FlowContext

Initialize the FlowContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the Flow resource to fetch.


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

def initialize(version, sid)
  super(version)

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

  # Dependents
  @revisions = nil
  @test_users = nil
  @executions = nil
end

Instance Method Details

#deleteBoolean

Delete the FlowInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


215
216
217
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 215

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

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

Access the executions

Returns:

Raises:

  • (ArgumentError)

249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 249

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 the FlowInstance

Returns:


206
207
208
209
210
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 206

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

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

#inspectObject

Provide a detailed, user friendly representation


272
273
274
275
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 272

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

#revisions(revision = :unset) ⇒ FlowRevisionList, FlowRevisionContext

Access the revisions

Returns:

Raises:

  • (ArgumentError)

223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 223

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

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

  unless @revisions
    @revisions = FlowRevisionList.new(@version, sid: @solution[:sid], )
  end

  @revisions
end

#test_usersFlowTestUserList, FlowTestUserContext

Access the test_users


241
242
243
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 241

def test_users
  FlowTestUserContext.new(@version, @solution[:sid], )
end

#to_sObject

Provide a user friendly representation


265
266
267
268
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 265

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

#update(status: nil, friendly_name: :unset, definition: :unset, commit_message: :unset) ⇒ FlowInstance

Update the FlowInstance

Parameters:

  • status (flow.Status) (defaults to: nil)

    The status of the Flow. Can be: `draft` or `published`.

  • friendly_name (String) (defaults to: :unset)

    The string that you assigned to describe the Flow.

  • definition (Hash) (defaults to: :unset)

    JSON representation of flow definition.

  • commit_message (String) (defaults to: :unset)

    Description of change made in the revision.

Returns:


190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 190

def update(status: nil, friendly_name: :unset, definition: :unset, commit_message: :unset)
  data = Twilio::Values.of({
      'Status' => status,
      'FriendlyName' => friendly_name,
      'Definition' => Twilio.serialize_object(definition),
      'CommitMessage' => commit_message,
  })

  payload = @version.update('POST', @uri, data: data)

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