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

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/taskrouter/v1/workspace.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/event.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/activity.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/task/reservation.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/reservation.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow/workflow_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_real_time_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/workspace_cumulative_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queues_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_real_time_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/workers_cumulative_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,
lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_real_time_statistics.rb,
lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_cumulative_statistics.rb

Defined Under Namespace

Classes: ActivityContext, ActivityInstance, ActivityList, ActivityPage, EventContext, EventInstance, EventList, EventPage, TaskChannelContext, TaskChannelInstance, TaskChannelList, TaskChannelPage, TaskContext, TaskInstance, TaskList, TaskPage, TaskQueueContext, TaskQueueInstance, TaskQueueList, TaskQueuePage, WorkerContext, WorkerInstance, WorkerList, WorkerPage, WorkflowContext, WorkflowInstance, WorkflowList, WorkflowPage, WorkspaceCumulativeStatisticsContext, WorkspaceCumulativeStatisticsInstance, WorkspaceCumulativeStatisticsList, WorkspaceCumulativeStatisticsPage, WorkspaceRealTimeStatisticsContext, WorkspaceRealTimeStatisticsInstance, WorkspaceRealTimeStatisticsList, WorkspaceRealTimeStatisticsPage, WorkspaceStatisticsContext, WorkspaceStatisticsInstance, WorkspaceStatisticsList, WorkspaceStatisticsPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ WorkspaceContext

Initialize the WorkspaceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the Workspace resource to fetch.


201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 201

def initialize(version, sid)
  super(version)

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

  # Dependents
  @activities = nil
  @events = nil
  @tasks = nil
  @task_queues = nil
  @workers = nil
  @workflows = nil
  @statistics = nil
  @real_time_statistics = nil
  @cumulative_statistics = nil
  @task_channels = nil
end

Instance Method Details

#activities(sid = :unset) ⇒ ActivityList, ActivityContext

Access the activities

Returns:

Raises:

  • (ArgumentError)

286
287
288
289
290
291
292
293
294
295
296
297
298
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 286

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

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

  unless @activities
    @activities = ActivityList.new(@version, workspace_sid: @solution[:sid], )
  end

  @activities
end

#cumulative_statisticsWorkspaceCumulativeStatisticsList, WorkspaceCumulativeStatisticsContext

Access the cumulative_statistics


410
411
412
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 410

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

#deleteBoolean

Delete the WorkspaceInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


278
279
280
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 278

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

#events(sid = :unset) ⇒ EventList, EventContext

Access the events

Returns:

Raises:

  • (ArgumentError)

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

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

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

  unless @events
    @events = EventList.new(@version, workspace_sid: @solution[:sid], )
  end

  @events
end

#fetchWorkspaceInstance

Fetch the WorkspaceInstance

Returns:


224
225
226
227
228
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 224

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

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

#inspectObject

Provide a detailed, user friendly representation


441
442
443
444
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 441

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

#real_time_statisticsWorkspaceRealTimeStatisticsList, WorkspaceRealTimeStatisticsContext

Access the real_time_statistics


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

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

#statisticsWorkspaceStatisticsList, WorkspaceStatisticsContext

Access the statistics


394
395
396
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 394

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

#task_channels(sid = :unset) ⇒ TaskChannelList, TaskChannelContext

Access the task_channels

Returns:

Raises:

  • (ArgumentError)

418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 418

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

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

  unless @task_channels
    @task_channels = TaskChannelList.new(@version, workspace_sid: @solution[:sid], )
  end

  @task_channels
end

#task_queues(sid = :unset) ⇒ TaskQueueList, TaskQueueContext

Access the task_queues

Returns:

Raises:

  • (ArgumentError)

340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 340

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

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

  unless @task_queues
    @task_queues = TaskQueueList.new(@version, workspace_sid: @solution[:sid], )
  end

  @task_queues
end

#tasks(sid = :unset) ⇒ TaskList, TaskContext

Access the tasks

Returns:

Raises:

  • (ArgumentError)

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

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

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

  unless @tasks
    @tasks = TaskList.new(@version, workspace_sid: @solution[:sid], )
  end

  @tasks
end

#to_sObject

Provide a user friendly representation


434
435
436
437
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 434

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

#update(default_activity_sid: :unset, event_callback_url: :unset, events_filter: :unset, friendly_name: :unset, multi_task_enabled: :unset, timeout_activity_sid: :unset, prioritize_queue_order: :unset) ⇒ WorkspaceInstance

Update the WorkspaceInstance

Parameters:

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

    The SID of the Activity that will be used when new Workers are created in the Workspace.

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

    The URL we should call when an event occurs. See Workspace Events for more information.

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

    The list of Workspace events for which to call event_callback_url. For example if `EventsFilter=task.created,task.canceled,worker.activity.update`, then TaskRouter will call event_callback_url only when a task is created, canceled, or a Worker activity is updated.

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

    A descriptive string that you create to describe the Workspace resource. For example: `Sales Call Center` or `Customer Support Team`.

  • multi_task_enabled (Boolean) (defaults to: :unset)

    Whether to enable multi-tasking. Can be: `true` to enable multi-tasking, or `false` to disable it. The default is `false`. Multi-tasking allows Workers to handle multiple Tasks simultaneously. When enabled (`true`), each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. Otherwise, each Worker will only receive a new reservation when the previous task is completed. Learn more at Multitasking.

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

    The SID of the Activity that will be assigned to a Worker when a Task reservation times out without a response.

  • prioritize_queue_order (workspace.QueueOrder) (defaults to: :unset)

    The type of TaskQueue to prioritize when Workers are receiving Tasks from both types of TaskQueues. Can be: `LIFO` or `FIFO` and the default is `FIFO`. For more information, see Queue Ordering.

Returns:


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

def update(default_activity_sid: :unset, event_callback_url: :unset, events_filter: :unset, friendly_name: :unset, multi_task_enabled: :unset, timeout_activity_sid: :unset, prioritize_queue_order: :unset)
  data = Twilio::Values.of({
      'DefaultActivitySid' => default_activity_sid,
      'EventCallbackUrl' => event_callback_url,
      'EventsFilter' => events_filter,
      'FriendlyName' => friendly_name,
      'MultiTaskEnabled' => multi_task_enabled,
      'TimeoutActivitySid' => timeout_activity_sid,
      'PrioritizeQueueOrder' => prioritize_queue_order,
  })

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

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

#workers(sid = :unset) ⇒ WorkerList, WorkerContext

Access the workers

Returns:

Raises:

  • (ArgumentError)

358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 358

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

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

  unless @workers
    @workers = WorkerList.new(@version, workspace_sid: @solution[:sid], )
  end

  @workers
end

#workflows(sid = :unset) ⇒ WorkflowList, WorkflowContext

Access the workflows

Returns:

Raises:

  • (ArgumentError)

376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 376

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

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

  unless @workflows
    @workflows = WorkflowList.new(@version, workspace_sid: @solution[:sid], )
  end

  @workflows
end