Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::WorkflowInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, workspace_sid: nil, sid: nil) ⇒ WorkflowInstance

Initialize the WorkflowInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • workspace_sid (String) (defaults to: nil)

    The ID of the Workspace that contains this Workflow

  • sid (String) (defaults to: nil)

    The sid



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

def initialize(version, payload, workspace_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'assignment_callback_url' => payload['assignment_callback_url'],
      'configuration' => payload['configuration'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'document_content_type' => payload['document_content_type'],
      'fallback_assignment_callback_url' => payload['fallback_assignment_callback_url'],
      'friendly_name' => payload['friendly_name'],
      'sid' => payload['sid'],
      'task_reservation_timeout' => payload['task_reservation_timeout'].to_i,
      'workspace_sid' => payload['workspace_sid'],
      'url' => payload['url'],
      'links' => payload['links'],
  }

  # Context
  @instance_context = nil
  @params = {'workspace_sid' => workspace_sid, 'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns The ID of the account that owns this Workflow.

Returns:

  • (String)

    The ID of the account that owns this Workflow



366
367
368
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 366

def 
  @properties['account_sid']
end

#assignment_callback_urlString

Returns The URL that will be called whenever a task managed by this Workflow is assigned to a Worker.

Returns:

  • (String)

    The URL that will be called whenever a task managed by this Workflow is assigned to a Worker.



372
373
374
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 372

def assignment_callback_url
  @properties['assignment_callback_url']
end

#configurationString

Returns JSON document configuring the rules for this Workflow.

Returns:

  • (String)

    JSON document configuring the rules for this Workflow.



378
379
380
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 378

def configuration
  @properties['configuration']
end

#contextWorkflowContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



357
358
359
360
361
362
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 357

def context
  unless @instance_context
    @instance_context = WorkflowContext.new(@version, @params['workspace_sid'], @params['sid'], )
  end
  @instance_context
end

#cumulative_statisticscumulative_statistics

Access the cumulative_statistics

Returns:



501
502
503
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 501

def cumulative_statistics
  context.cumulative_statistics
end

#date_createdTime

Returns The date this workflow was created.

Returns:

  • (Time)

    The date this workflow was created.



384
385
386
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 384

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date this workflow was last updated.

Returns:

  • (Time)

    The date this workflow was last updated.



390
391
392
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 390

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the WorkflowInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



480
481
482
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 480

def delete
  context.delete
end

#document_content_typeString

Returns The document_content_type.

Returns:

  • (String)

    The document_content_type



396
397
398
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 396

def document_content_type
  @properties['document_content_type']
end

#fallback_assignment_callback_urlString

Returns If the request to the AssignmentCallbackUrl fails, the assignment callback will be made to this URL.

Returns:

  • (String)

    If the request to the AssignmentCallbackUrl fails, the assignment callback will be made to this URL.



402
403
404
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 402

def fallback_assignment_callback_url
  @properties['fallback_assignment_callback_url']
end

#fetchWorkflowInstance

Fetch a WorkflowInstance

Returns:



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

def fetch
  context.fetch
end

#friendly_nameString

Returns Human readable description of this Workflow.

Returns:

  • (String)

    Human readable description of this Workflow



408
409
410
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 408

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



514
515
516
517
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 514

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Taskrouter.V1.WorkflowInstance #{values}>"
end

Returns The links.

Returns:

  • (String)

    The links



438
439
440
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 438

def links
  @properties['links']
end

#real_time_statisticsreal_time_statistics

Access the real_time_statistics

Returns:



494
495
496
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 494

def real_time_statistics
  context.real_time_statistics
end

#sidString

Returns The unique ID of the Workflow.

Returns:

  • (String)

    The unique ID of the Workflow



414
415
416
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 414

def sid
  @properties['sid']
end

#statisticsstatistics

Access the statistics

Returns:



487
488
489
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 487

def statistics
  context.statistics
end

#task_reservation_timeoutString

Returns Determines how long TaskRouter will wait for a confirmation response from your application after assigning a Task to a worker.

Returns:

  • (String)

    Determines how long TaskRouter will wait for a confirmation response from your application after assigning a Task to a worker.



420
421
422
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 420

def task_reservation_timeout
  @properties['task_reservation_timeout']
end

#to_sObject

Provide a user friendly representation



507
508
509
510
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 507

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Taskrouter.V1.WorkflowInstance #{values}>"
end

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

Update the WorkflowInstance

Parameters:

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

    A string representing a human readable name for this Workflow. Examples include ‘Customer Support’ or ‘Sales Team’.

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

    A valid URL for the application that will process task assignment events. See [Handling Task Assignment Callback](www.twilio.com/docs/api/taskrouter/handling-assignment-callbacks) for more details.

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

    If the request to the AssignmentCallbackUrl fails, the assignment callback will be made to this URL.

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

    JSON document configuring the rules for this Workflow. See [Configuring Workflows](www.twilio.com/docs/api/taskrouter/workflow-configuration) for more information.

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

    An integer value controlling how long in seconds TaskRouter will wait for a confirmation response from your application after assigning a Task to a worker. Defaults to 120 seconds. Maximum value is 86400 (24 hours)

Returns:



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

def update(friendly_name: :unset, assignment_callback_url: :unset, fallback_assignment_callback_url: :unset, configuration: :unset, task_reservation_timeout: :unset)
  context.update(
      friendly_name: friendly_name,
      assignment_callback_url: assignment_callback_url,
      fallback_assignment_callback_url: fallback_assignment_callback_url,
      configuration: configuration,
      task_reservation_timeout: task_reservation_timeout,
  )
end

#urlString

Returns The url.

Returns:

  • (String)

    The url



432
433
434
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 432

def url
  @properties['url']
end

#workspace_sidString

Returns The ID of the Workspace that contains this Workflow.

Returns:

  • (String)

    The ID of the Workspace that contains this Workflow



426
427
428
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb', line 426

def workspace_sid
  @properties['workspace_sid']
end