Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::WorkflowContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_real_time_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_cumulative_statistics.rb

Defined Under Namespace

Classes: WorkflowCumulativeStatisticsContext, WorkflowCumulativeStatisticsInstance, WorkflowCumulativeStatisticsInstanceMetadata, WorkflowCumulativeStatisticsList, WorkflowCumulativeStatisticsListResponse, WorkflowCumulativeStatisticsPage, WorkflowCumulativeStatisticsPageMetadata, WorkflowRealTimeStatisticsContext, WorkflowRealTimeStatisticsInstance, WorkflowRealTimeStatisticsInstanceMetadata, WorkflowRealTimeStatisticsList, WorkflowRealTimeStatisticsListResponse, WorkflowRealTimeStatisticsPage, WorkflowRealTimeStatisticsPageMetadata, WorkflowStatisticsContext, WorkflowStatisticsInstance, WorkflowStatisticsInstanceMetadata, WorkflowStatisticsList, WorkflowStatisticsListResponse, WorkflowStatisticsPage, WorkflowStatisticsPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, workspace_sid, sid) ⇒ WorkflowContext

Initialize the WorkflowContext

Parameters:

  • version (Version)

    Version that contains the resource

  • workspace_sid (String)

    The SID of the Workspace with the Workflow to update.

  • sid (String)

    The SID of the Workflow resource to update.



260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 260

def initialize(version, workspace_sid, sid)
    super(version)
    

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

    # Dependents
    @statistics = nil
    @cumulative_statistics = nil
    @real_time_statistics = nil
end

Instance Method Details

#cumulative_statisticsWorkflowCumulativeStatisticsList, WorkflowCumulativeStatisticsContext

Access the cumulative_statistics



456
457
458
459
460
461
462
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 456

def cumulative_statistics
    WorkflowCumulativeStatisticsContext.new(
            @version,
            @solution[:workspace_sid],
            @solution[:sid]
            )
end

#deleteBoolean

Delete the WorkflowInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



276
277
278
279
280
281
282
283
284
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 276

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 WorkflowInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 289

def 

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

#fetchWorkflowInstance

Fetch the WorkflowInstance

Returns:



308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 308

def fetch

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

#fetch_with_metadataWorkflowInstance

Fetch the WorkflowInstanceMetadata

Returns:



328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 328

def 

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

#inspectObject

Provide a detailed, user friendly representation



484
485
486
487
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 484

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

#real_time_statisticsWorkflowRealTimeStatisticsList, WorkflowRealTimeStatisticsContext

Access the real_time_statistics



467
468
469
470
471
472
473
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 467

def real_time_statistics
    WorkflowRealTimeStatisticsContext.new(
            @version,
            @solution[:workspace_sid],
            @solution[:sid]
            )
end

#statisticsWorkflowStatisticsList, WorkflowStatisticsContext

Access the statistics



445
446
447
448
449
450
451
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 445

def statistics
    WorkflowStatisticsContext.new(
            @version,
            @solution[:workspace_sid],
            @solution[:sid]
            )
end

#to_sObject

Provide a user friendly representation



477
478
479
480
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 477

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

#update(friendly_name: :unset, assignment_callback_url: :unset, fallback_assignment_callback_url: :unset, configuration: :unset, task_reservation_timeout: :unset, re_evaluate_tasks: :unset) ⇒ WorkflowInstance

Update the WorkflowInstance

Parameters:

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

    A descriptive string that you create to describe the Workflow resource. For example, ‘Inbound Call Workflow` or `2014 Outbound Campaign`.

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

    The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details.

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

    The URL that we should call when a call to the ‘assignment_callback_url` fails.

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

    A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](www.twilio.com/docs/taskrouter/workflow-configuration) for more information.

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

    How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to ‘86,400` (24 hours) and the default is `120`.

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

    Whether or not to re-evaluate Tasks. The default is ‘false`, which means Tasks in the Workflow will not be processed through the assignment loop again.

Returns:



360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 360

def update(
  friendly_name: :unset, 
  assignment_callback_url: :unset, 
  fallback_assignment_callback_url: :unset, 
  configuration: :unset, 
  task_reservation_timeout: :unset, 
  re_evaluate_tasks: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'AssignmentCallbackUrl' => assignment_callback_url,
        'FallbackAssignmentCallbackUrl' => fallback_assignment_callback_url,
        'Configuration' => configuration,
        'TaskReservationTimeout' => task_reservation_timeout,
        'ReEvaluateTasks' => re_evaluate_tasks,
    })

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

#update_with_metadata(friendly_name: :unset, assignment_callback_url: :unset, fallback_assignment_callback_url: :unset, configuration: :unset, task_reservation_timeout: :unset, re_evaluate_tasks: :unset) ⇒ WorkflowInstance

Update the WorkflowInstanceMetadata

Parameters:

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

    A descriptive string that you create to describe the Workflow resource. For example, ‘Inbound Call Workflow` or `2014 Outbound Campaign`.

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

    The URL from your application that will process task assignment events. See [Handling Task Assignment Callback](www.twilio.com/docs/taskrouter/handle-assignment-callbacks) for more details.

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

    The URL that we should call when a call to the ‘assignment_callback_url` fails.

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

    A JSON string that contains the rules to apply to the Workflow. See [Configuring Workflows](www.twilio.com/docs/taskrouter/workflow-configuration) for more information.

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

    How long TaskRouter will wait for a confirmation response from your application after it assigns a Task to a Worker. Can be up to ‘86,400` (24 hours) and the default is `120`.

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

    Whether or not to re-evaluate Tasks. The default is ‘false`, which means Tasks in the Workflow will not be processed through the assignment loop again.

Returns:



402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 402

def (
  friendly_name: :unset, 
  assignment_callback_url: :unset, 
  fallback_assignment_callback_url: :unset, 
  configuration: :unset, 
  task_reservation_timeout: :unset, 
  re_evaluate_tasks: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'AssignmentCallbackUrl' => assignment_callback_url,
        'FallbackAssignmentCallbackUrl' => fallback_assignment_callback_url,
        'Configuration' => configuration,
        'TaskReservationTimeout' => task_reservation_timeout,
        'ReEvaluateTasks' => re_evaluate_tasks,
    })

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