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

  • account_sid (String)

    The SID of the Account that created this WorkerChannel resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 460

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'] == nil ? payload['assigned_tasks'] : payload['assigned_tasks'].to_i,
        'available' => payload['available'],
        'available_capacity_percentage' => payload['available_capacity_percentage'] == nil ? payload['available_capacity_percentage'] : payload['available_capacity_percentage'].to_i,
        'configured_capacity' => payload['configured_capacity'] == nil ? payload['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  || @properties['workspace_sid']  ,'worker_sid' => worker_sid  || @properties['worker_sid']  ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Worker resource.

Returns:



499
500
501
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 499

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.



505
506
507
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 505

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.



511
512
513
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 511

def available
    @properties['available']
end

#available_capacity_percentageString

Returns The current percentage of capacity the TaskChannel has available. Can be a number between ‘0` and `100`. A value of `0` indicates that TaskChannel has no capacity available and a value of `100` means the Worker is available to receive any Tasks of this TaskChannel type.

Returns:

  • (String)

    The current percentage of capacity the TaskChannel has available. Can be a number between ‘0` and `100`. A value of `0` indicates that TaskChannel has no capacity available and a value of `100` means the Worker is available to receive any Tasks of this TaskChannel type.



517
518
519
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 517

def available_capacity_percentage
    @properties['available_capacity_percentage']
end

#configured_capacityString

Returns The current configured capacity for the WorkerChannel. TaskRouter will not create any reservations after the assigned Tasks for the Worker reaches the value.

Returns:

  • (String)

    The current configured capacity for the WorkerChannel. TaskRouter will not create any reservations after the assigned Tasks for the Worker reaches the value.



523
524
525
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 523

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:



490
491
492
493
494
495
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 490

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 and time in GMT when the resource was created specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



529
530
531
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 529

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date and time in GMT when the resource was last updated specified in [RFC 2822](www.ietf.org/rfc/rfc2822.txt) format.

Returns:



535
536
537
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 535

def date_updated
    @properties['date_updated']
end

#fetchWorkerChannelInstance

Fetch the WorkerChannelInstance

Returns:



578
579
580
581
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 578

def fetch

    context.fetch
end

#inspectObject

Provide a detailed, user friendly representation



608
609
610
611
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 608

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

#sidString

Returns The unique string that we created to identify the WorkerChannel resource.

Returns:

  • (String)

    The unique string that we created to identify the WorkerChannel resource.



541
542
543
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 541

def sid
    @properties['sid']
end

#task_channel_sidString

Returns The SID of the TaskChannel.

Returns:

  • (String)

    The SID of the TaskChannel.



547
548
549
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 547

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`.



553
554
555
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 553

def task_channel_unique_name
    @properties['task_channel_unique_name']
end

#to_sObject

Provide a user friendly representation



601
602
603
604
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 601

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:



588
589
590
591
592
593
594
595
596
597
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 588

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.



571
572
573
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 571

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.



559
560
561
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 559

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.



565
566
567
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker/worker_channel.rb', line 565

def workspace_sid
    @properties['workspace_sid']
end