Class: Twilio::REST::Taskrouter::V1::WorkspaceContext::TaskContext

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

Defined Under Namespace

Classes: ReservationContext, ReservationInstance, ReservationList, ReservationPage

Instance Method Summary collapse

Constructor Details

#initialize(version, workspace_sid, sid) ⇒ TaskContext

Initialize the TaskContext

Parameters:

  • version (Version)

    Version that contains the resource

  • workspace_sid (String)

    The SID of the Workspace with the Task to update.

  • sid (String)

    The SID of the Task resource to update.



222
223
224
225
226
227
228
229
230
231
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 222

def initialize(version, workspace_sid, sid)
    super(version)

    # Path Solution
    @solution = { workspace_sid: workspace_sid, sid: sid,  }
    @uri = "/Workspaces/#{@solution[:workspace_sid]}/Tasks/#{@solution[:sid]}"

    # Dependents
    @reservations = nil
end

Instance Method Details

#delete(if_match: :unset) ⇒ Boolean

Delete the TaskInstance

Parameters:

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



236
237
238
239
240
241
242
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 236

def delete(
    if_match: :unset
)

    headers = Twilio::Values.of({ 'If-Match' => if_match, })
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchTaskInstance

Fetch the TaskInstance

Returns:



247
248
249
250
251
252
253
254
255
256
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 247

def fetch

    payload = @version.fetch('GET', @uri)
    TaskInstance.new(
        @version,
        payload,
        workspace_sid: @solution[:workspace_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



323
324
325
326
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 323

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Taskrouter.V1.TaskContext #{context}>"
end

#reservations(sid = :unset) ⇒ ReservationList, ReservationContext

Access the reservations

Returns:

Raises:

  • (ArgumentError)


298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 298

def reservations(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return ReservationContext.new(@version, @solution[:workspace_sid], @solution[:sid],sid )
    end

    unless @reservations
        @reservations = ReservationList.new(
            @version, workspace_sid: @solution[:workspace_sid], task_sid: @solution[:sid], )
    end

 @reservations
end

#to_sObject

Provide a user friendly representation



316
317
318
319
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 316

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Taskrouter.V1.TaskContext #{context}>"
end

#update(attributes: :unset, assignment_status: :unset, reason: :unset, priority: :unset, task_channel: :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`.

  • 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:



267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
# File 'lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb', line 267

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

    data = Twilio::Values.of({
        'Attributes' => attributes,
        'AssignmentStatus' => assignment_status,
        'Reason' => reason,
        'Priority' => priority,
        'TaskChannel' => task_channel,
    })

    headers = Twilio::Values.of({ 'If-Match' => if_match, })
    payload = @version.update('POST', @uri, data: data, headers: headers)
    TaskInstance.new(
        @version,
        payload,
        workspace_sid: @solution[:workspace_sid],
        sid: @solution[:sid],
    )
end