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

  • worker_sid (String) (defaults to: nil)

    The SID of the Worker that contains the WorkerChannel.

  • sid (String) (defaults to: nil)

    The SID of the WorkerChannel to fetch.


236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 236

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 SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource


283
284
285
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 283

def 
  @properties['account_sid']
end

#assigned_tasksString

Returns The total number of Tasks assigned to Worker for the TaskChannel type.

Returns:

  • (String)

    The total number of Tasks assigned to Worker for the TaskChannel type


289
290
291
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 289

def assigned_tasks
  @properties['assigned_tasks']
end

#availableBoolean

Returns Whether the Worker should receive Tasks of the TaskChannel type.

Returns:

  • (Boolean)

    Whether the Worker should receive Tasks of the TaskChannel type


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

def available
  @properties['available']
end

#available_capacity_percentageString

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

Returns:

  • (String)

    The current available capacity between 0 to 100 for the TaskChannel


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

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


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

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:


269
270
271
272
273
274
275
276
277
278
279
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 269

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 RFC 2822 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was created


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

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The RFC 2822 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the resource was last updated


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

def date_updated
  @properties['date_updated']
end

#fetchWorkerChannelInstance

Fetch the WorkerChannelInstance

Returns:


362
363
364
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 362

def fetch
  context.fetch
end

#inspectObject

Provide a detailed, user friendly representation


389
390
391
392
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 389

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

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource


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

def sid
  @properties['sid']
end

#task_channel_sidString

Returns The SID of the TaskChannel.

Returns:

  • (String)

    The SID of the TaskChannel


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

def task_channel_sid
  @properties['task_channel_sid']
end

#task_channel_unique_nameString

Returns The unique name of the TaskChannel, such as 'voice' or 'sms'.

Returns:

  • (String)

    The unique name of the TaskChannel, such as 'voice' or 'sms'


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

def task_channel_unique_name
  @properties['task_channel_unique_name']
end

#to_sObject

Provide a user friendly representation


382
383
384
385
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 382

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 that the Worker should handle for the TaskChannel type. TaskRouter creates reservations for Tasks of this TaskChannel type up to the specified capacity. If the capacity is 0, no new reservations will be created.

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

    Whether the WorkerChannel is available. Set to `false` to prevent the Worker from receiving any new Tasks of this TaskChannel type.

Returns:


376
377
378
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 376

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

#urlString

Returns The absolute URL of the WorkerChannel resource.

Returns:

  • (String)

    The absolute URL of the WorkerChannel resource


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

def url
  @properties['url']
end

#worker_sidString

Returns The SID of the Worker that contains the WorkerChannel.

Returns:

  • (String)

    The SID of the Worker that contains the WorkerChannel


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

def worker_sid
  @properties['worker_sid']
end

#workspace_sidString

Returns The SID of the Workspace that contains the WorkerChannel.

Returns:

  • (String)

    The SID of the Workspace that contains the WorkerChannel


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

def workspace_sid
  @properties['workspace_sid']
end