class Twilio::REST::Taskrouter::V1::WorkspaceContext::WorkerInstance
Public Class Methods
Initialize the WorkerInstance
@param [Version] version Version
that contains the resource @param [Hash] payload payload that contains response from Twilio
@param [String] workspace_sid
The SID of the Workspace that contains the Worker. @param [String] sid The SID of the Worker resource to fetch. @return [WorkerInstance] WorkerInstance
Twilio::REST::InstanceResource::new
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 421 def initialize(version, payload, workspace_sid: nil, sid: nil) 422 super(version) 423 424 # Marshaled Properties 425 @properties = { 426 'account_sid' => payload['account_sid'], 427 'activity_name' => payload['activity_name'], 428 'activity_sid' => payload['activity_sid'], 429 'attributes' => payload['attributes'], 430 'available' => payload['available'], 431 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 432 'date_status_changed' => Twilio.deserialize_iso8601_datetime(payload['date_status_changed']), 433 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 434 'friendly_name' => payload['friendly_name'], 435 'sid' => payload['sid'], 436 'workspace_sid' => payload['workspace_sid'], 437 'url' => payload['url'], 438 'links' => payload['links'], 439 } 440 441 # Context 442 @instance_context = nil 443 @params = {'workspace_sid' => workspace_sid, 'sid' => sid || @properties['sid'], } 444 end
Public Instance Methods
@return [String] The SID of the Account that created the resource
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 459 def account_sid 460 @properties['account_sid'] 461 end
@return [String] The friendly_name
of the Worker's current Activity
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 465 def activity_name 466 @properties['activity_name'] 467 end
@return [String] The SID of the Worker's current Activity
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 471 def activity_sid 472 @properties['activity_sid'] 473 end
@return [String] The JSON string that describes the Worker
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 477 def attributes 478 @properties['attributes'] 479 end
@return [Boolean] Whether the Worker is available to perform tasks
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 483 def available 484 @properties['available'] 485 end
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context @return [WorkerContext] WorkerContext
for this WorkerInstance
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 450 def context 451 unless @instance_context 452 @instance_context = WorkerContext.new(@version, @params['workspace_sid'], @params['sid'], ) 453 end 454 @instance_context 455 end
Access the cumulative_statistics
@return [cumulative_statistics] cumulative_statistics
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 583 def cumulative_statistics 584 context.cumulative_statistics 585 end
@return [Time] The ISO 8601 date and time in GMT when the resource was created
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 489 def date_created 490 @properties['date_created'] 491 end
@return [Time] The date and time in GMT of the last change to the Worker's activity
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 495 def date_status_changed 496 @properties['date_status_changed'] 497 end
@return [Time] The ISO 8601 date and time in GMT when the resource was last updated
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 501 def date_updated 502 @properties['date_updated'] 503 end
Delete the WorkerInstance
@return [Boolean] true if delete succeeds, false otherwise
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 569 def delete 570 context.delete 571 end
Fetch the WorkerInstance
@return [WorkerInstance] Fetched WorkerInstance
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 538 def fetch 539 context.fetch 540 end
@return [String] The string that you assigned to describe the resource
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 507 def friendly_name 508 @properties['friendly_name'] 509 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 617 def inspect 618 values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") 619 "<Twilio.Taskrouter.V1.WorkerInstance #{values}>" 620 end
@return [String] The URLs of related resources
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 531 def links 532 @properties['links'] 533 end
Access the real_time_statistics
@return [real_time_statistics] real_time_statistics
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 576 def real_time_statistics 577 context.real_time_statistics 578 end
Access the reservations @return [reservations] reservations
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 597 def reservations 598 context.reservations 599 end
@return [String] The unique string that identifies the resource
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 513 def sid 514 @properties['sid'] 515 end
Access the statistics @return [statistics] statistics
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 590 def statistics 591 context.statistics 592 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 610 def to_s 611 values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") 612 "<Twilio.Taskrouter.V1.WorkerInstance #{values}>" 613 end
Update the WorkerInstance
@param [String] activity_sid
The SID of a valid Activity that will describe the
Worker's initial state. See {Activities}[https://www.twilio.com/docs/taskrouter/api/activity] for more information.
@param [String] attributes The JSON string that describes the Worker. For
example: `{ "email": "Bob@example.com", "phone": "+5095551234" }`. This data is passed to the `assignment_callback_url` when TaskRouter assigns a Task to the Worker. Defaults to {}.
@param [String] friendly_name
A descriptive string that you create to describe
the Worker. It can be up to 64 characters long.
@param [Boolean] reject_pending_reservations Whether to reject pending
reservations.
@return [WorkerInstance] Updated WorkerInstance
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 557 def update(activity_sid: :unset, attributes: :unset, friendly_name: :unset, reject_pending_reservations: :unset) 558 context.update( 559 activity_sid: activity_sid, 560 attributes: attributes, 561 friendly_name: friendly_name, 562 reject_pending_reservations: reject_pending_reservations, 563 ) 564 end
@return [String] The absolute URL of the Worker resource
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 525 def url 526 @properties['url'] 527 end
Access the worker_channels
@return [worker_channels] worker_channels
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 604 def worker_channels 605 context.worker_channels 606 end
@return [String] The SID of the Workspace that contains the Worker
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb 519 def workspace_sid 520 @properties['workspace_sid'] 521 end