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 SID of the Workspace that contains the Task.

  • sid (String) (defaults to: nil)

    The SID of the Task resource to fetch.



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
440
441
442
443
444
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 413

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']),
      'task_queue_entered_date' => Twilio.deserialize_iso8601_datetime(payload['task_queue_entered_date']),
      '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 SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



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

def 
  @properties['account_sid']
end

#addonsString

Returns An object that contains the addon data for all installed addons.

Returns:

  • (String)

    An object that contains the addon data for all installed addons



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

def addons
  @properties['addons']
end

#ageString

Returns The number of seconds since the Task was created.

Returns:

  • (String)

    The number of seconds since the Task was created



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

def age
  @properties['age']
end

#assignment_statustask.Status

Returns The current status of the Task’s assignment.

Returns:

  • (task.Status)

    The current status of the Task’s assignment



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

def assignment_status
  @properties['assignment_status']
end

#attributesString

Returns The JSON string with custom attributes of the work.

Returns:

  • (String)

    The JSON string with custom attributes of the work



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

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:



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

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

#date_createdTime

Returns The ISO 8601 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was created



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

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The ISO 8601 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was last updated



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

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Delete the TaskInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



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

def delete
  context.delete
end

#fetchTaskInstance

Fetch the TaskInstance

Returns:



586
587
588
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 586

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



647
648
649
650
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 647

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

Returns The URLs of related resources.

Returns:

  • (String)

    The URLs of related resources



579
580
581
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 579

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



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

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



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

def reason
  @properties['reason']
end

#reservationsreservations

Access the reservations

Returns:



634
635
636
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 634

def reservations
  context.reservations
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



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

def sid
  @properties['sid']
end

#task_channel_sidString

Returns The SID of the TaskChannel.

Returns:

  • (String)

    The SID of the TaskChannel



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

def task_channel_sid
  @properties['task_channel_sid']
end

#task_channel_unique_nameString

Returns The unique name of the TaskChannel.

Returns:

  • (String)

    The unique name of the TaskChannel



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

def task_channel_unique_name
  @properties['task_channel_unique_name']
end

#task_queue_entered_dateTime

Returns The ISO 8601 date and time in GMT when the Task entered the TaskQueue.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the Task entered the TaskQueue.



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

def task_queue_entered_date
  @properties['task_queue_entered_date']
end

#task_queue_friendly_nameString

Returns The friendly name of the TaskQueue.

Returns:

  • (String)

    The friendly name of the TaskQueue



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

def task_queue_friendly_name
  @properties['task_queue_friendly_name']
end

#task_queue_sidString

Returns The SID of the TaskQueue.

Returns:

  • (String)

    The SID of the TaskQueue



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

def task_queue_sid
  @properties['task_queue_sid']
end

#timeoutString

Returns The amount of time in seconds that the Task can live before being assigned.

Returns:

  • (String)

    The amount of time in seconds that the Task can live before being assigned



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

def timeout
  @properties['timeout']
end

#to_sObject

Provide a user friendly representation



640
641
642
643
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 640

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, if_match: :unset) ⇒ TaskInstance

Update the TaskInstance

Parameters:

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

    The JSON string that describes the custom attributes of the task.

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

    The new status of the task. Can be: ‘canceled`, to cancel a Task that is currently `pending` or `reserved`; `wrapping`, to move the Task to wrapup state; or `completed`, to move a Task to the completed state.

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

    The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason.

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

    The Task’s new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647).

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

    When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel’s SID or its ‘unique_name`, such as `voice`, `sms`, or `default`.

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

    If provided, applies this mutation if (and only if) the ETag header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP If-Match header.

Returns:



613
614
615
616
617
618
619
620
621
622
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 613

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

#urlString

Returns The absolute URL of the Task resource.

Returns:

  • (String)

    The absolute URL of the Task resource



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

def url
  @properties['url']
end

#workflow_friendly_nameString

Returns The friendly name of the Workflow that is controlling the Task.

Returns:

  • (String)

    The friendly name of the Workflow that is controlling the Task



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

def workflow_friendly_name
  @properties['workflow_friendly_name']
end

#workflow_sidString

Returns The SID of the Workflow that is controlling the Task.

Returns:

  • (String)

    The SID of the Workflow that is controlling the Task



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

def workflow_sid
  @properties['workflow_sid']
end

#workspace_sidString

Returns The SID of the Workspace that contains the Task.

Returns:

  • (String)

    The SID of the Workspace that contains the Task



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

def workspace_sid
  @properties['workspace_sid']
end