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

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

Instance Method Summary collapse

Constructor Details

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

Initialize the WorkerInstance

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

  • sid (String) (defaults to: nil)

    The SID of the Worker resource to fetch.



441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 441

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

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'activity_name' => payload['activity_name'],
      'activity_sid' => payload['activity_sid'],
      'attributes' => payload['attributes'],
      'available' => payload['available'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_status_changed' => Twilio.deserialize_iso8601_datetime(payload['date_status_changed']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'friendly_name' => payload['friendly_name'],
      'sid' => payload['sid'],
      'workspace_sid' => payload['workspace_sid'],
      'url' => payload['url'],
      'links' => payload['links'],
  }

  # Context
  @instance_context = nil
  @params = {'workspace_sid' => workspace_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



479
480
481
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 479

def 
  @properties['account_sid']
end

#activity_nameString

Returns The friendly_name of the Worker’s current Activity.

Returns:

  • (String)

    The friendly_name of the Worker’s current Activity



485
486
487
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 485

def activity_name
  @properties['activity_name']
end

#activity_sidString

Returns The SID of the Worker’s current Activity.

Returns:

  • (String)

    The SID of the Worker’s current Activity



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

def activity_sid
  @properties['activity_sid']
end

#attributesString

Returns The JSON string that describes the Worker.

Returns:

  • (String)

    The JSON string that describes the Worker



497
498
499
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 497

def attributes
  @properties['attributes']
end

#availableBoolean

Returns Whether the Worker is available to perform tasks.

Returns:

  • (Boolean)

    Whether the Worker is available to perform tasks



503
504
505
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 503

def available
  @properties['available']
end

#contextWorkerContext

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

Returns:



470
471
472
473
474
475
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 470

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

#cumulative_statisticscumulative_statistics

Access the cumulative_statistics

Returns:



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

def cumulative_statistics
  context.cumulative_statistics
end

#date_createdTime

Returns The ISO 8601 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was created



509
510
511
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 509

def date_created
  @properties['date_created']
end

#date_status_changedTime

Returns The date and time in GMT of the last change to the Worker’s activity.

Returns:

  • (Time)

    The date and time in GMT of the last change to the Worker’s activity



515
516
517
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 515

def date_status_changed
  @properties['date_status_changed']
end

#date_updatedTime

Returns The ISO 8601 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was last updated



521
522
523
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 521

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the WorkerInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



589
590
591
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 589

def delete
  context.delete
end

#fetchWorkerInstance

Fetch a WorkerInstance

Returns:



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

def fetch
  context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the resource.

Returns:

  • (String)

    The string that you assigned to describe the resource



527
528
529
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 527

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



637
638
639
640
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 637

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

Returns The URLs of related resources.

Returns:

  • (String)

    The URLs of related resources



551
552
553
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 551

def links
  @properties['links']
end

#real_time_statisticsreal_time_statistics

Access the real_time_statistics

Returns:



596
597
598
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 596

def real_time_statistics
  context.real_time_statistics
end

#reservationsreservations

Access the reservations

Returns:



617
618
619
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 617

def reservations
  context.reservations
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



533
534
535
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 533

def sid
  @properties['sid']
end

#statisticsstatistics

Access the statistics

Returns:



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

def statistics
  context.statistics
end

#to_sObject

Provide a user friendly representation



630
631
632
633
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 630

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

#update(activity_sid: :unset, attributes: :unset, friendly_name: :unset, reject_pending_reservations: :unset) ⇒ WorkerInstance

Update the WorkerInstance

Parameters:

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

    The SID of a valid Activity that will describe the Worker’s initial state. See [Activities](www.twilio.com/docs/taskrouter/api/activity) for more information.

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

    The JSON string that describes the Worker. For example: ‘{ “email”: “[email protected]”, “phone”: “+5095551234” }`. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker. Defaults to {}.

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

    A descriptive string that you create to describe the Worker. It can be up to 64 characters long.

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

    Whether to reject pending reservations.

Returns:



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

def update(activity_sid: :unset, attributes: :unset, friendly_name: :unset, reject_pending_reservations: :unset)
  context.update(
      activity_sid: activity_sid,
      attributes: attributes,
      friendly_name: friendly_name,
      reject_pending_reservations: reject_pending_reservations,
  )
end

#urlString

Returns The absolute URL of the Worker resource.

Returns:

  • (String)

    The absolute URL of the Worker resource



545
546
547
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 545

def url
  @properties['url']
end

#worker_channelsworker_channels

Access the worker_channels

Returns:



624
625
626
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 624

def worker_channels
  context.worker_channels
end

#workspace_sidString

Returns The SID of the Workspace that contains the Worker.

Returns:

  • (String)

    The SID of the Workspace that contains the Worker



539
540
541
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 539

def workspace_sid
  @properties['workspace_sid']
end