Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::WorkerContext::WorkerChannelInstance

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

Instance Method Summary collapse

Constructor Details

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

Initialize the WorkerChannelInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • workspace_sid (String) (defaults to: nil)

    The unique ID of the Workspace that this WorkerChannel belongs to.

  • worker_sid (String) (defaults to: nil)

    The unique ID of the Worker that this WorkerChannel belongs to.

  • sid (String) (defaults to: nil)

    The sid



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

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

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'assigned_tasks' => payload['assigned_tasks'].to_i,
      'available' => payload['available'],
      'available_capacity_percentage' => payload['available_capacity_percentage'].to_i,
      'configured_capacity' => payload['configured_capacity'].to_i,
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'sid' => payload['sid'],
      'task_channel_sid' => payload['task_channel_sid'],
      'task_channel_unique_name' => payload['task_channel_unique_name'],
      'worker_sid' => payload['worker_sid'],
      'workspace_sid' => payload['workspace_sid'],
      'url' => payload['url'],
  }

  # Context
  @instance_context = nil
  @params = {
      'workspace_sid' => workspace_sid,
      'worker_sid' => worker_sid,
      'sid' => sid || @properties['sid'],
  }
end

Instance Method Details

#account_sidString

Returns The unique ID of the Account that owns this WorkerChannel.

Returns:

  • (String)

    The unique ID of the Account that owns this WorkerChannel.



293
294
295
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 293

def 
  @properties['account_sid']
end

#assigned_tasksString

Returns The total number of tasks assigned to Worker for this TaskChannel type.

Returns:

  • (String)

    The total number of tasks assigned to Worker for this TaskChannel type.



299
300
301
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 299

def assigned_tasks
  @properties['assigned_tasks']
end

#availableBoolean

Returns Boolean value indicating whether the worker should receive Tasks of this TaskChannel type.

Returns:

  • (Boolean)

    Boolean value indicating whether the worker should receive Tasks of this TaskChannel type.



305
306
307
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 305

def available
  @properties['available']
end

#available_capacity_percentageString

Returns The current available capacity between 0 to 100 for this TaskChannel.

Returns:

  • (String)

    The current available capacity between 0 to 100 for this TaskChannel.



311
312
313
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 311

def available_capacity_percentage
  @properties['available_capacity_percentage']
end

#configured_capacityString

Returns The current configured capacity for the WorkerChannel.

Returns:

  • (String)

    The current configured capacity for the WorkerChannel.



317
318
319
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 317

def configured_capacity
  @properties['configured_capacity']
end

#contextWorkerChannelContext

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

Returns:



279
280
281
282
283
284
285
286
287
288
289
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 279

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

#date_createdTime

Returns The date this Activity was created.

Returns:

  • (Time)

    The date this Activity was created.



323
324
325
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 323

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The date this Activity was updated.

Returns:

  • (Time)

    The date this Activity was updated.



329
330
331
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 329

def date_updated
  @properties['date_updated']
end

#fetchWorkerChannelInstance

Fetch a WorkerChannelInstance

Returns:



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

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



399
400
401
402
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 399

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

#sidString

Returns The unique ID for this WorkerChannel.

Returns:

  • (String)

    The unique ID for this WorkerChannel.



335
336
337
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 335

def sid
  @properties['sid']
end

#task_channel_sidString

Returns The unique ID of the TaskChannel.

Returns:

  • (String)

    The unique ID of the TaskChannel.



341
342
343
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 341

def task_channel_sid
  @properties['task_channel_sid']
end

#task_channel_unique_nameString

Returns The unique name of TaskChannel, such as ‘voice’, ‘sms’, etc.

Returns:

  • (String)

    The unique name of TaskChannel, such as ‘voice’, ‘sms’, etc.



347
348
349
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 347

def task_channel_unique_name
  @properties['task_channel_unique_name']
end

#to_sObject

Provide a user friendly representation



392
393
394
395
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 392

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

#update(capacity: :unset, available: :unset) ⇒ WorkerChannelInstance

Update the WorkerChannelInstance

Parameters:

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

    The total number of Tasks worker should handle for this TaskChannel type. TaskRouter will only create reservations for Tasks of this TaskChannel type up to the capacity configured. If the capacity is 0, no new reservations will be created

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

    Toggle the availability of the WorkerChannel. Set this to ‘False’ to make worker unavailable to receive any new Tasks of this TaskChannel type.

Returns:



386
387
388
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 386

def update(capacity: :unset, available: :unset)
  context.update(capacity: capacity, available: available, )
end

#urlString

Returns The url.

Returns:

  • (String)

    The url



365
366
367
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 365

def url
  @properties['url']
end

#worker_sidString

Returns The unique ID of the Worker that this WorkerChannel belongs to.

Returns:

  • (String)

    The unique ID of the Worker that this WorkerChannel belongs to.



353
354
355
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 353

def worker_sid
  @properties['worker_sid']
end

#workspace_sidString

Returns The unique ID of the Workspace that this WorkerChannel belongs to.

Returns:

  • (String)

    The unique ID of the Workspace that this WorkerChannel belongs to.



359
360
361
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 359

def workspace_sid
  @properties['workspace_sid']
end