Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::TaskInstance

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

Instance Method Summary collapse

Constructor Details

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

Initialize the TaskInstance

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 Task resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 728

def initialize(version, payload , workspace_sid: nil, sid: nil)
    super(version)
    
    
    # Marshaled Properties
    @properties = { 
        'account_sid' => payload['account_sid'],
        'age' => payload['age'] == nil ? payload['age'] : payload['age'].to_i,
        'assignment_status' => payload['assignment_status'],
        'attributes' => payload['attributes'],
        'addons' => payload['addons'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
        'task_queue_entered_date' => Twilio.deserialize_iso8601_datetime(payload['task_queue_entered_date']),
        'priority' => payload['priority'] == nil ? payload['priority'] : payload['priority'].to_i,
        'reason' => payload['reason'],
        'sid' => payload['sid'],
        'task_queue_sid' => payload['task_queue_sid'],
        'task_queue_friendly_name' => payload['task_queue_friendly_name'],
        'task_channel_sid' => payload['task_channel_sid'],
        'task_channel_unique_name' => payload['task_channel_unique_name'],
        'timeout' => payload['timeout'] == nil ? payload['timeout'] : payload['timeout'].to_i,
        'workflow_sid' => payload['workflow_sid'],
        'workflow_friendly_name' => payload['workflow_friendly_name'],
        'workspace_sid' => payload['workspace_sid'],
        'url' => payload['url'],
        'links' => payload['links'],
        'virtual_start_time' => Twilio.deserialize_iso8601_datetime(payload['virtual_start_time']),
        'ignore_capacity' => payload['ignore_capacity'],
        'routing_target' => payload['routing_target'],
    }

    # 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 Task resource.

Returns:



778
779
780
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 778

def 
    @properties['account_sid']
end

#addonsString

Returns An object that contains the [Add-on](www.twilio.com/docs/add-ons) data for all installed Add-ons.

Returns:



802
803
804
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 802

def addons
    @properties['addons']
end

#ageString

Returns The number of seconds since the Task was created.

Returns:

  • (String)

    The number of seconds since the Task was created.



784
785
786
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 784

def age
    @properties['age']
end

#assignment_statusStatus

Returns:

  • (Status)


790
791
792
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 790

def assignment_status
    @properties['assignment_status']
end

#attributesString

Returns The JSON string with custom attributes of the work. Note If this property has been assigned a value, it will only be displayed in FETCH action that returns a single resource. Otherwise, it will be null.

Returns:

  • (String)

    The JSON string with custom attributes of the work. Note If this property has been assigned a value, it will only be displayed in FETCH action that returns a single resource. Otherwise, it will be null.



796
797
798
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 796

def attributes
    @properties['attributes']
end

#contextTaskContext

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

Returns:



769
770
771
772
773
774
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 769

def context
    unless @instance_context
        @instance_context = TaskContext.new(@version , @params['workspace_sid'], @params['sid'])
    end
    @instance_context
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:



808
809
810
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 808

def date_created
    @properties['date_created']
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:



814
815
816
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 814

def date_updated
    @properties['date_updated']
end

#delete(if_match: :unset) ⇒ Boolean

Delete the TaskInstance

Parameters:

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



924
925
926
927
928
929
930
931
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 924

def delete(
  if_match: :unset
)

    context.delete(
        if_match: if_match, 
    )
end

#fetchTaskInstance

Fetch the TaskInstance

Returns:



936
937
938
939
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 936

def fetch

    context.fetch
end

#ignore_capacityBoolean

Returns A boolean that indicates if the Task should respect a Worker’s capacity and availability during assignment. This field can only be used when the ‘RoutingTarget` field is set to a Worker SID. By setting `IgnoreCapacity` to a value of `true`, `1`, or `yes`, the Task will be routed to the Worker without respecting their capacity and availability. Any other value will enforce the Worker’s capacity and availability. The default value of ‘IgnoreCapacity` is `true` when the `RoutingTarget` is set to a Worker SID.

Returns:

  • (Boolean)

    A boolean that indicates if the Task should respect a Worker’s capacity and availability during assignment. This field can only be used when the ‘RoutingTarget` field is set to a Worker SID. By setting `IgnoreCapacity` to a value of `true`, `1`, or `yes`, the Task will be routed to the Worker without respecting their capacity and availability. Any other value will enforce the Worker’s capacity and availability. The default value of ‘IgnoreCapacity` is `true` when the `RoutingTarget` is set to a Worker SID.



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

def ignore_capacity
    @properties['ignore_capacity']
end

#inspectObject

Provide a detailed, user friendly representation



988
989
990
991
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 988

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

Returns The URLs of related resources.

Returns:

  • (Hash)

    The URLs of related resources.



898
899
900
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 898

def links
    @properties['links']
end

#priorityString

Returns The current priority score of the Task as assigned to a Worker by the workflow. Tasks with higher priority values will be assigned before Tasks with lower values.

Returns:

  • (String)

    The current priority score of the Task as assigned to a Worker by the workflow. Tasks with higher priority values will be assigned before Tasks with lower values.



826
827
828
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 826

def priority
    @properties['priority']
end

#reasonString

Returns The reason the Task was canceled or completed, if applicable.

Returns:

  • (String)

    The reason the Task was canceled or completed, if applicable.



832
833
834
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 832

def reason
    @properties['reason']
end

#reservationsreservations

Access the reservations

Returns:



975
976
977
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 975

def reservations
    context.reservations
end

#routing_targetString

Returns A SID of a Worker, Queue, or Workflow to route a Task to.

Returns:

  • (String)

    A SID of a Worker, Queue, or Workflow to route a Task to



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

def routing_target
    @properties['routing_target']
end

#sidString

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

Returns:

  • (String)

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



838
839
840
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 838

def sid
    @properties['sid']
end

#task_channel_sidString

Returns The SID of the TaskChannel.

Returns:

  • (String)

    The SID of the TaskChannel.



856
857
858
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 856

def task_channel_sid
    @properties['task_channel_sid']
end

#task_channel_unique_nameString

Returns The unique name of the TaskChannel.

Returns:

  • (String)

    The unique name of the TaskChannel.



862
863
864
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 862

def task_channel_unique_name
    @properties['task_channel_unique_name']
end

#task_queue_entered_dateTime

Returns The date and time in GMT when the Task entered the TaskQueue, specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



820
821
822
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 820

def task_queue_entered_date
    @properties['task_queue_entered_date']
end

#task_queue_friendly_nameString

Returns The friendly name of the TaskQueue.

Returns:

  • (String)

    The friendly name of the TaskQueue.



850
851
852
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 850

def task_queue_friendly_name
    @properties['task_queue_friendly_name']
end

#task_queue_sidString

Returns The SID of the TaskQueue.

Returns:

  • (String)

    The SID of the TaskQueue.



844
845
846
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 844

def task_queue_sid
    @properties['task_queue_sid']
end

#timeoutString

Returns The amount of time in seconds that the Task can live before being assigned.

Returns:

  • (String)

    The amount of time in seconds that the Task can live before being assigned.



868
869
870
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 868

def timeout
    @properties['timeout']
end

#to_sObject

Provide a user friendly representation



981
982
983
984
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 981

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

#update(attributes: :unset, assignment_status: :unset, reason: :unset, priority: :unset, task_channel: :unset, virtual_start_time: :unset, if_match: :unset) ⇒ TaskInstance

Update the TaskInstance

Parameters:

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

    The JSON string that describes the custom attributes of the task.

  • assignment_status (Status) (defaults to: :unset)
  • reason (String) (defaults to: :unset)

    The reason that the Task was canceled or completed. This parameter is required only if the Task is canceled or completed. Setting this value queues the task for deletion and logs the reason.

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

    The Task’s new priority value. When supplied, the Task takes on the specified priority unless it matches a Workflow Target with a Priority set. Value can be 0 to 2^31^ (2,147,483,647).

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

    When MultiTasking is enabled, specify the TaskChannel with the task to update. Can be the TaskChannel’s SID or its ‘unique_name`, such as `voice`, `sms`, or `default`.

  • virtual_start_time (Time) (defaults to: :unset)

    The task’s new virtual start time value. When supplied, the Task takes on the specified virtual start time. Value can’t be in the future or before the year of 1900.

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

    If provided, applies this mutation if (and only if) the [ETag](developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag) header of the Task matches the provided value. This matches the semantics of (and is implemented with) the HTTP [If-Match header](developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match).

Returns:



951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 951

def update(
  attributes: :unset, 
  assignment_status: :unset, 
  reason: :unset, 
  priority: :unset, 
  task_channel: :unset, 
  virtual_start_time: :unset, 
  if_match: :unset
)

    context.update(
        attributes: attributes, 
        assignment_status: assignment_status, 
        reason: reason, 
        priority: priority, 
        task_channel: task_channel, 
        virtual_start_time: virtual_start_time, 
        if_match: if_match, 
    )
end

#urlString

Returns The absolute URL of the Task resource.

Returns:

  • (String)

    The absolute URL of the Task resource.



892
893
894
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 892

def url
    @properties['url']
end

#virtual_start_timeTime

Returns The date and time in GMT indicating the ordering for routing of the Task specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



904
905
906
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 904

def virtual_start_time
    @properties['virtual_start_time']
end

#workflow_friendly_nameString

Returns The friendly name of the Workflow that is controlling the Task.

Returns:

  • (String)

    The friendly name of the Workflow that is controlling the Task.



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

def workflow_friendly_name
    @properties['workflow_friendly_name']
end

#workflow_sidString

Returns The SID of the Workflow that is controlling the Task.

Returns:

  • (String)

    The SID of the Workflow that is controlling the Task.



874
875
876
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 874

def workflow_sid
    @properties['workflow_sid']
end

#workspace_sidString

Returns The SID of the Workspace that contains the Task.

Returns:

  • (String)

    The SID of the Workspace that contains the Task.



886
887
888
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 886

def workspace_sid
    @properties['workspace_sid']
end