Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::TaskContext

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

Defined Under Namespace

Classes: ReservationContext, ReservationInstance, ReservationList, ReservationPage

Instance Method Summary collapse

Constructor Details

#initialize(version, workspace_sid, sid) ⇒ TaskContext

Initialize the TaskContext

Parameters:

  • version (Version)

    Version that contains the resource

  • workspace_sid (String)

    The SID of the Workspace with the Task to fetch.

  • sid (String)

    The SID of the Task resource to fetch.



307
308
309
310
311
312
313
314
315
316
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 307

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

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

  # Dependents
  @reservations = nil
end

Instance Method Details

#deleteBoolean

Deletes the TaskInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



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

def delete
  @version.delete('delete', @uri)
end

#fetchTaskInstance

Fetch a TaskInstance

Returns:



321
322
323
324
325
326
327
328
329
330
331
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 321

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  TaskInstance.new(@version, payload, workspace_sid: @solution[:workspace_sid], sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation



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

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

#reservations(sid = :unset) ⇒ ReservationList, ReservationContext

Access the reservations

Returns:

Raises:

  • (ArgumentError)


380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 380

def reservations(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return ReservationContext.new(@version, @solution[:workspace_sid], @solution[:sid], sid, )
  end

  unless @reservations
    @reservations = ReservationList.new(
        @version,
        workspace_sid: @solution[:workspace_sid],
        task_sid: @solution[:sid],
    )
  end

  @reservations
end

#to_sObject

Provide a user friendly representation



400
401
402
403
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 400

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Taskrouter.V1.TaskContext #{context}>"
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 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`.

Returns:



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 351

def update(attributes: :unset, assignment_status: :unset, reason: :unset, priority: :unset, task_channel: :unset)
  data = Twilio::Values.of({
      'Attributes' => attributes,
      'AssignmentStatus' => assignment_status,
      'Reason' => reason,
      'Priority' => priority,
      'TaskChannel' => task_channel,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  TaskInstance.new(@version, payload, workspace_sid: @solution[:workspace_sid], sid: @solution[:sid], )
end