Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::TaskInstance

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

Instance Method Summary collapse

Constructor Details

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

Initialize the TaskInstance

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 holds this Task

  • sid (String) (defaults to: nil)

    The sid



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
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 406

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

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'age' => payload['age'].to_i,
      'assignment_status' => payload['assignment_status'],
      'attributes' => payload['attributes'],
      'addons' => payload['addons'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'priority' => payload['priority'].to_i,
      'reason' => payload['reason'],
      'sid' => payload['sid'],
      'task_queue_sid' => payload['task_queue_sid'],
      'task_queue_friendly_name' => payload['task_queue_friendly_name'],
      'task_channel_sid' => payload['task_channel_sid'],
      'task_channel_unique_name' => payload['task_channel_unique_name'],
      'timeout' => payload['timeout'].to_i,
      'workflow_sid' => payload['workflow_sid'],
      'workflow_friendly_name' => payload['workflow_friendly_name'],
      '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 Task.

Returns:

  • (String)

    The ID of the account that owns this Task



451
452
453
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 451

def 
  @properties['account_sid']
end

#addonsString

Returns The addon data for all installed addons is returned with this attribute.

Returns:

  • (String)

    The addon data for all installed addons is returned with this attribute



475
476
477
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 475

def addons
  @properties['addons']
end

#ageString

Returns The number of seconds since this task was created.

Returns:

  • (String)

    The number of seconds since this task was created.



457
458
459
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 457

def age
  @properties['age']
end

#assignment_statustask.Status

Returns the list of all Tasks in the workspace with the specified AssignmentStatus.

Returns:

  • (task.Status)

    Returns the list of all Tasks in the workspace with the specified AssignmentStatus.



463
464
465
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 463

def assignment_status
  @properties['assignment_status']
end

#attributesString

Returns The user-defined JSON string describing the custom attributes of this work.

Returns:

  • (String)

    The user-defined JSON string describing the custom attributes of this work.



469
470
471
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 469

def attributes
  @properties['attributes']
end

#contextTaskContext

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

Returns:



442
443
444
445
446
447
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 442

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

#date_createdTime

Returns Date this task was created, given as ISO 8601 format.

Returns:

  • (Time)

    Date this task was created, given as ISO 8601 format.



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

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns Date this task was updated, given as ISO 8601 format.

Returns:

  • (Time)

    Date this task was updated, given as ISO 8601 format.



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

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the TaskInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



605
606
607
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 605

def delete
  context.delete
end

#fetchTaskInstance

Fetch a TaskInstance

Returns:



572
573
574
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 572

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



625
626
627
628
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 625

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

Returns The links.

Returns:

  • (String)

    The links



565
566
567
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 565

def links
  @properties['links']
end

#priorityString

Returns Retrieve the list of all Tasks in the workspace with the specified priority.

Returns:

  • (String)

    Retrieve the list of all Tasks in the workspace with the specified priority.



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

def priority
  @properties['priority']
end

#reasonString

Returns The reason the task was canceled or completed.

Returns:

  • (String)

    The reason the task was canceled or completed



499
500
501
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 499

def reason
  @properties['reason']
end

#reservationsreservations

Access the reservations

Returns:



612
613
614
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 612

def reservations
  context.reservations
end

#sidString

Returns The unique ID of the Task.

Returns:

  • (String)

    The unique ID of the Task



505
506
507
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 505

def sid
  @properties['sid']
end

#task_channel_sidString

Returns The ID of the Task Channel.

Returns:

  • (String)

    The ID of the Task Channel



523
524
525
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 523

def task_channel_sid
  @properties['task_channel_sid']
end

#task_channel_unique_nameString

Returns The unique name of the Task Channel.

Returns:

  • (String)

    The unique name of the Task Channel



529
530
531
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 529

def task_channel_unique_name
  @properties['task_channel_unique_name']
end

#task_queue_friendly_nameString

Returns The task_queue_friendly_name.

Returns:

  • (String)

    The task_queue_friendly_name



517
518
519
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 517

def task_queue_friendly_name
  @properties['task_queue_friendly_name']
end

#task_queue_sidString

Returns the list of Tasks that are currently waiting in the TaskQueue identified by the Sid specified.

Returns:

  • (String)

    Returns the list of Tasks that are currently waiting in the TaskQueue identified by the Sid specified.



511
512
513
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 511

def task_queue_sid
  @properties['task_queue_sid']
end

#timeoutString

Returns The amount of time in seconds the task is allowed to live.

Returns:

  • (String)

    The amount of time in seconds the task is allowed to live



535
536
537
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 535

def timeout
  @properties['timeout']
end

#to_sObject

Provide a user friendly representation



618
619
620
621
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 618

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

#update(attributes: :unset, assignment_status: :unset, reason: :unset, priority: :unset, task_channel: :unset) ⇒ TaskInstance

Update the TaskInstance

Parameters:

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

    The user-defined JSON data describing the custom attributes of this task.

  • assignment_status (task.Status) (defaults to: :unset)

    A ‘pending’ or ‘reserved’ Task may be canceled by posting AssignmentStatus=‘canceled’. Post AssignmentStatus=‘wrapping’ to move Task to ‘wrapup’ state and AssignmentStatus=‘completed’ to move a Task to ‘completed’ state.

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

    This is only required if the Task is canceled or completed. This logs the reason the task was either canceled or completed and queues the task for deletion after 5 minutes.

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

    Override priority for the Task. When supplied, the Task will take on the given priority unless it matches a Workflow Target with a Priority set.

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

    The task_channel

Returns:



592
593
594
595
596
597
598
599
600
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 592

def update(attributes: :unset, assignment_status: :unset, reason: :unset, priority: :unset, task_channel: :unset)
  context.update(
      attributes: attributes,
      assignment_status: assignment_status,
      reason: reason,
      priority: priority,
      task_channel: task_channel,
  )
end

#urlString

Returns The url.

Returns:

  • (String)

    The url



559
560
561
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 559

def url
  @properties['url']
end

#workflow_friendly_nameString

Returns The workflow_friendly_name.

Returns:

  • (String)

    The workflow_friendly_name



547
548
549
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 547

def workflow_friendly_name
  @properties['workflow_friendly_name']
end

#workflow_sidString

Returns the list of Tasks that are being controlled by the Workflow with the specified Sid value.

Returns:

  • (String)

    Returns the list of Tasks that are being controlled by the Workflow with the specified Sid value.



541
542
543
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 541

def workflow_sid
  @properties['workflow_sid']
end

#workspace_sidString

Returns The ID of the Workspace that holds this Task.

Returns:

  • (String)

    The ID of the Workspace that holds this Task



553
554
555
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 553

def workspace_sid
  @properties['workspace_sid']
end