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

  • account_sid (String)

    The SID of the Account that created this Worker resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 717

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  || @properties['workspace_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:



756
757
758
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 756

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.



762
763
764
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 762

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.



768
769
770
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 768

def activity_sid
    @properties['activity_sid']
end

#attributesString

Returns The JSON string that describes the Worker. For example: ‘{ "email": "[email protected]", "phone": "+5095551234" }`. Note If this property has been assigned a value, it will only be displayed in FETCH actions that return a single resource. Otherwise, this property will be null, even if it has a value. This data is passed to the assignment_callback_url when TaskRouter assigns a Task to the Worker.

Returns:

  • (String)

    The JSON string that describes the Worker. For example: ‘{ "email": "[email protected]", "phone": "+5095551234" }`. Note If this property has been assigned a value, it will only be displayed in FETCH actions that return a single resource. Otherwise, this property will be null, even if it has a value. This data is passed to the assignment_callback_url when TaskRouter assigns a Task to the Worker.



774
775
776
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 774

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.



780
781
782
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 780

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:



747
748
749
750
751
752
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 747

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:



902
903
904
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 902

def cumulative_statistics
    context.cumulative_statistics
end

#date_createdTime

Returns The date and time in GMT when the resource was created specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



786
787
788
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 786

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 specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format. Used to calculate Workflow statistics.

Returns:

  • (Time)

    The date and time in GMT of the last change to the Worker’s activity specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format. Used to calculate Workflow statistics.



792
793
794
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 792

def date_status_changed
    @properties['date_status_changed']
end

#date_updatedTime

Returns The date and time in GMT when the resource was last updated specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



798
799
800
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 798

def date_updated
    @properties['date_updated']
end

#delete(if_match: :unset) ⇒ Boolean

Delete the WorkerInstance

Parameters:

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

    The If-Match HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



836
837
838
839
840
841
842
843
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 836

def delete(
    if_match: :unset
)

    context.delete(
        if_match: if_match, 
    )
end

#fetchWorkerInstance

Fetch the WorkerInstance

Returns:



848
849
850
851
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 848

def fetch

    context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the resource. Friendly names are case insensitive, and unique within the TaskRouter Workspace.

Returns:

  • (String)

    The string that you assigned to describe the resource. Friendly names are case insensitive, and unique within the TaskRouter Workspace.



804
805
806
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 804

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



922
923
924
925
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 922

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

Returns The URLs of related resources.

Returns:

  • (Hash)

    The URLs of related resources.



828
829
830
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 828

def links
    @properties['links']
end

#real_time_statisticsreal_time_statistics

Access the real_time_statistics

Returns:



888
889
890
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 888

def real_time_statistics
    context.real_time_statistics
end

#reservationsreservations

Access the reservations

Returns:



881
882
883
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 881

def reservations
    context.reservations
end

#sidString

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

Returns:

  • (String)

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



810
811
812
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 810

def sid
    @properties['sid']
end

#statisticsstatistics

Access the statistics

Returns:



895
896
897
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 895

def statistics
    context.statistics
end

#to_sObject

Provide a user friendly representation



915
916
917
918
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 915

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, if_match: :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 the Worker’s pending reservations. This option is only valid if the Worker’s new [Activity](www.twilio.com/docs/taskrouter/api/activity) resource has its availability property set to False.

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

    The If-Match HTTP request header

Returns:



861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 861

def update(
    activity_sid: :unset, 
    attributes: :unset, 
    friendly_name: :unset, 
    reject_pending_reservations: :unset, 
    if_match: :unset
)

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

#urlString

Returns The absolute URL of the Worker resource.

Returns:

  • (String)

    The absolute URL of the Worker resource.



822
823
824
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 822

def url
    @properties['url']
end

#worker_channelsworker_channels

Access the worker_channels

Returns:



909
910
911
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 909

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.



816
817
818
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/worker.rb', line 816

def workspace_sid
    @properties['workspace_sid']
end