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/flow_revision.rb,
lib/twilio-ruby/rest/studio/v2/flow/flow_test_user.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, ExecutionInstanceMetadata, ExecutionList, ExecutionListResponse, ExecutionPage, ExecutionPageMetadata, FlowRevisionContext, FlowRevisionInstance, FlowRevisionInstanceMetadata, FlowRevisionList, FlowRevisionListResponse, FlowRevisionPage, FlowRevisionPageMetadata, FlowTestUserContext, FlowTestUserInstance, FlowTestUserInstanceMetadata, FlowTestUserList, FlowTestUserListResponse, FlowTestUserPage, FlowTestUserPageMetadata

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.



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

def initialize(version, sid)
    super(version)
    

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

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

Instance Method Details

#deleteBoolean

Delete the FlowInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the FlowInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 276

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      flow_instance = FlowInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      FlowInstanceMetadata.new(@version, flow_instance, response.headers, response.status_code)
end

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

Access the executions

Returns:

Raises:

  • (ArgumentError)


422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 422

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:



295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 295

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    FlowInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#fetch_with_metadataFlowInstance

Fetch the FlowInstanceMetadata

Returns:



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 314

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    flow_instance = FlowInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    FlowInstanceMetadata.new(
        @version,
        flow_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



476
477
478
479
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 476

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)


451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 451

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



441
442
443
444
445
446
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 441

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

#to_sObject

Provide a user friendly representation



469
470
471
472
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 469

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, author_sid: :unset) ⇒ FlowInstance

Update the FlowInstance

Parameters:

  • status (Status) (defaults to: nil)
  • friendly_name (String) (defaults to: :unset)

    The string that you assigned to describe the Flow.

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

    JSON representation of flow definition.

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

    Description of change made in the revision.

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

    The SID of the User that created or last updated the Flow.

Returns:



344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 344

def update(
  status: nil, 
  friendly_name: :unset, 
  definition: :unset, 
  commit_message: :unset, 
  author_sid: :unset
)

    data = Twilio::Values.of({
        'Status' => status,
        'FriendlyName' => friendly_name,
        'Definition' => Twilio.serialize_object(definition),
        'CommitMessage' => commit_message,
        'AuthorSid' => author_sid,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    FlowInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

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

Update the FlowInstanceMetadata

Parameters:

  • status (Status) (defaults to: nil)
  • friendly_name (String) (defaults to: :unset)

    The string that you assigned to describe the Flow.

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

    JSON representation of flow definition.

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

    Description of change made in the revision.

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

    The SID of the User that created or last updated the Flow.

Returns:



382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/twilio-ruby/rest/studio/v2/flow.rb', line 382

def (
  status: nil, 
  friendly_name: :unset, 
  definition: :unset, 
  commit_message: :unset, 
  author_sid: :unset
)

    data = Twilio::Values.of({
        'Status' => status,
        'FriendlyName' => friendly_name,
        'Definition' => Twilio.serialize_object(definition),
        'CommitMessage' => commit_message,
        'AuthorSid' => author_sid,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    flow_instance = FlowInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    FlowInstanceMetadata.new(
        @version,
        flow_instance,
        response.headers,
        response.status_code
    )
end