class Twilio::REST::Taskrouter::V1::WorkspaceContext::TaskContext

Public Class Methods

new(version, workspace_sid, sid) click to toggle source

Initialize the TaskContext @param [Version] version Version that contains the resource @param [String] workspace_sid The SID of the Workspace with the Task to fetch. @param [String] sid The SID of the Task resource to fetch. @return [TaskContext] TaskContext

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
303 def initialize(version, workspace_sid, sid)
304   super(version)
305 
306   # Path Solution
307   @solution = {workspace_sid: workspace_sid, sid: sid, }
308   @uri = "/Workspaces/#{@solution[:workspace_sid]}/Tasks/#{@solution[:sid]}"
309 
310   # Dependents
311   @reservations = nil
312 end

Public Instance Methods

delete(if_match: :unset) click to toggle source

Delete the TaskInstance @param [String] if_match If provided, deletes this Task if (and only if) the

{ETag}[https://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}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match].

@return [Boolean] true if delete succeeds, false otherwise

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
369 def delete(if_match: :unset)
370   headers = Twilio::Values.of({'If-Match' => if_match, })
371 
372    @version.delete('DELETE', @uri, headers: headers)
373 end
fetch() click to toggle source

Fetch the TaskInstance @return [TaskInstance] Fetched TaskInstance

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
317 def fetch
318   payload = @version.fetch('GET', @uri)
319 
320   TaskInstance.new(@version, payload, workspace_sid: @solution[:workspace_sid], sid: @solution[:sid], )
321 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
406 def inspect
407   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
408   "#<Twilio.Taskrouter.V1.TaskContext #{context}>"
409 end
reservations(sid=:unset) click to toggle source

Access the reservations @return [ReservationList] @return [ReservationContext] if sid was passed.

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
379 def reservations(sid=:unset)
380   raise ArgumentError, 'sid cannot be nil' if sid.nil?
381 
382   if sid != :unset
383     return ReservationContext.new(@version, @solution[:workspace_sid], @solution[:sid], sid, )
384   end
385 
386   unless @reservations
387     @reservations = ReservationList.new(
388         @version,
389         workspace_sid: @solution[:workspace_sid],
390         task_sid: @solution[:sid],
391     )
392   end
393 
394   @reservations
395 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
399 def to_s
400   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
401   "#<Twilio.Taskrouter.V1.TaskContext #{context}>"
402 end
update(attributes: :unset, assignment_status: :unset, reason: :unset, priority: :unset, task_channel: :unset, if_match: :unset) click to toggle source

Update the TaskInstance @param [String] attributes The JSON string that describes the custom attributes

of the task.

@param [task.Status] assignment_status The new status of the task. Can be:

`canceled`, to cancel a Task that is currently `pending` or `reserved`;
`wrapping`, to move the Task to wrapup state; or `completed`, to move a Task to
the completed state.

@param [String] reason 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.

@param [String] priority 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).

@param [String] task_channel 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`.

@param [String] if_match If provided, applies this mutation if (and only if) the

{ETag}[https://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}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match].

@return [TaskInstance] Updated TaskInstance

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
346 def update(attributes: :unset, assignment_status: :unset, reason: :unset, priority: :unset, task_channel: :unset, if_match: :unset)
347   data = Twilio::Values.of({
348       'Attributes' => attributes,
349       'AssignmentStatus' => assignment_status,
350       'Reason' => reason,
351       'Priority' => priority,
352       'TaskChannel' => task_channel,
353   })
354   headers = Twilio::Values.of({'If-Match' => if_match, })
355 
356   payload = @version.update('POST', @uri, data: data, headers: headers)
357 
358   TaskInstance.new(@version, payload, workspace_sid: @solution[:workspace_sid], sid: @solution[:sid], )
359 end