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,
lib/twilio-ruby/rest/taskrouter/v1/workspace/task_queue/task_queue_bulk_real_time_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 update.



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 182

def initialize(version, sid)
    super(version)

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

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

Instance Method Details

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

Access the activities

Returns:

Raises:

  • (ArgumentError)


309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 309

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



280
281
282
283
284
285
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 280

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

#deleteBoolean

Delete the WorkspaceInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



204
205
206
207
208
209
210
211
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 204

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

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

Access the events

Returns:

Raises:

  • (ArgumentError)


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

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:



216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 216

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    WorkspaceInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



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

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



328
329
330
331
332
333
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 328

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

#statisticsWorkspaceStatisticsList, WorkspaceStatisticsContext

Access the statistics



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

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

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

Access the task_channels

Returns:

Raises:

  • (ArgumentError)


424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 424

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)


290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 290

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)


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

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



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

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](www.twilio.com/docs/taskrouter/api/event) for more information. This parameter supports Twilio’s [Webhooks (HTTP callbacks) Connection Overrides](www.twilio.com/docs/usage/webhooks/webhooks-connection-overrides).

  • 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. However, all workspaces should be maintained as multi-tasking. There is no default when omitting this parameter. A multi-tasking Workspace can’t be updated to single-tasking unless it is not a Flex Project and another (legacy) single-tasking Workspace exists. Multi-tasking allows Workers to handle multiple Tasks simultaneously. In multi-tasking mode, each Worker can receive parallel reservations up to the per-channel maximums defined in the Workers section. In single-tasking mode (legacy mode), each Worker will only receive a new reservation when the previous task is completed. Learn more at [Multitasking](www.twilio.com/docs/taskrouter/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 (QueueOrder) (defaults to: :unset)

Returns:



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 242

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,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    WorkspaceInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

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

Access the workers

Returns:

Raises:

  • (ArgumentError)


395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace.rb', line 395

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)


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

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