class Twilio::REST::Taskrouter::V1::WorkspaceContext::TaskList

Public Class Methods

new(version, workspace_sid: nil) click to toggle source

Initialize the TaskList @param [Version] version Version that contains the resource @param [String] workspace_sid The SID of the Workspace that contains the Task. @return [TaskList] TaskList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
20 def initialize(version, workspace_sid: nil)
21   super(version)
22 
23   # Path Solution
24   @solution = {workspace_sid: workspace_sid}
25   @uri = "/Workspaces/#{@solution[:workspace_sid]}/Tasks"
26 end

Public Instance Methods

create(timeout: :unset, priority: :unset, task_channel: :unset, workflow_sid: :unset, attributes: :unset) click to toggle source

Create the TaskInstance @param [String] timeout The amount of time in seconds the new task can live

before being assigned. Can be up to a maximum of 2 weeks (1,209,600 seconds).
The default value is 24 hours (86,400 seconds). On timeout, the `task.canceled`
event will fire with description `Task TTL Exceeded`.

@param [String] priority The priority to assign the new task and override the

default. When supplied, the new Task will have this priority unless it matches a
Workflow Target with a Priority set. When not supplied, the new Task will have
the priority of the matching Workflow Target. Value can be 0 to 2^31^
(2,147,483,647).

@param [String] task_channel When MultiTasking is enabled, specify the

TaskChannel by passing either its `unique_name` or `sid`. Default value is
`default`.

@param [String] workflow_sid The SID of the Workflow that you would like to

handle routing for the new Task. If there is only one Workflow defined for the
Workspace that you are posting the new task to, this parameter is optional.

@param [String] attributes A URL-encoded JSON string with the attributes of the

new task. This value is passed to the Workflow's `assignment_callback_url` when
the Task is assigned to a Worker. For example: `{ "task_type": "call",
"twilio_call_sid": "CAxxx", "customer_ticket_number": "12345" }`.

@return [TaskInstance] Created TaskInstance

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
246 def create(timeout: :unset, priority: :unset, task_channel: :unset, workflow_sid: :unset, attributes: :unset)
247   data = Twilio::Values.of({
248       'Timeout' => timeout,
249       'Priority' => priority,
250       'TaskChannel' => task_channel,
251       'WorkflowSid' => workflow_sid,
252       'Attributes' => attributes,
253   })
254 
255   payload = @version.create('POST', @uri, data: data)
256 
257   TaskInstance.new(@version, payload, workspace_sid: @solution[:workspace_sid], )
258 end
each() { |x| ... } click to toggle source

When passed a block, yields TaskInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
145 def each
146   limits = @version.read_limits
147 
148   page = self.page(page_size: limits[:page_size], )
149 
150   @version.stream(page,
151                   limit: limits[:limit],
152                   page_limit: limits[:page_limit]).each {|x| yield x}
153 end
get_page(target_url) click to toggle source

Retrieve a single page of TaskInstance records from the API. Request is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page of TaskInstance

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
216 def get_page(target_url)
217   response = @version.domain.request(
218       'GET',
219       target_url
220   )
221   TaskPage.new(@version, response, @solution)
222 end
list(priority: :unset, assignment_status: :unset, workflow_sid: :unset, workflow_name: :unset, task_queue_sid: :unset, task_queue_name: :unset, evaluate_task_attributes: :unset, ordering: :unset, has_addons: :unset, limit: nil, page_size: nil) click to toggle source

Lists TaskInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] priority The priority value of the Tasks to read. Returns the

list of all Tasks in the Workspace with the specified priority.

@param [Array] assignment_status The `assignment_status` of the Tasks

you want to read. Can be: `pending`, `reserved`, `assigned`, `canceled`,
`wrapping`, or `completed`. Returns all Tasks in the Workspace with the
specified `assignment_status`.

@param [String] workflow_sid The SID of the Workflow with the Tasks to read.

Returns the Tasks controlled by the Workflow identified by this SID.

@param [String] workflow_name The friendly name of the Workflow with the Tasks

to read. Returns the Tasks controlled by the Workflow identified by this
friendly name.

@param [String] task_queue_sid The SID of the TaskQueue with the Tasks to read.

Returns the Tasks waiting in the TaskQueue identified by this SID.

@param [String] task_queue_name The `friendly_name` of the TaskQueue with the

Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this
friendly name.

@param [String] evaluate_task_attributes The attributes of the Tasks to read.

Returns the Tasks that match the attributes specified in this parameter.

@param [String] ordering How to order the returned Task resources. y default,

Tasks are sorted by ascending DateCreated. This value is specified as:
`Attribute:Order`, where `Attribute` can be either `Priority` or `DateCreated`
and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns
Tasks ordered in descending order of their Priority. Multiple sort orders can be
specified in a comma-separated list such as `Priority:desc,DateCreated:asc`,
which returns the Tasks in descending Priority order and ascending DateCreated
Order.

@param [Boolean] has_addons Whether to read Tasks with addons. If `true`,

returns only Tasks with addons. If `false`, returns only Tasks without addons.

@param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit.  Default is no limit

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records.  If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Array] Array of up to limit results

   # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
67 def list(priority: :unset, assignment_status: :unset, workflow_sid: :unset, workflow_name: :unset, task_queue_sid: :unset, task_queue_name: :unset, evaluate_task_attributes: :unset, ordering: :unset, has_addons: :unset, limit: nil, page_size: nil)
68   self.stream(
69       priority: priority,
70       assignment_status: assignment_status,
71       workflow_sid: workflow_sid,
72       workflow_name: workflow_name,
73       task_queue_sid: task_queue_sid,
74       task_queue_name: task_queue_name,
75       evaluate_task_attributes: evaluate_task_attributes,
76       ordering: ordering,
77       has_addons: has_addons,
78       limit: limit,
79       page_size: page_size
80   ).entries
81 end
page(priority: :unset, assignment_status: :unset, workflow_sid: :unset, workflow_name: :unset, task_queue_sid: :unset, task_queue_name: :unset, evaluate_task_attributes: :unset, ordering: :unset, has_addons: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of TaskInstance records from the API. Request is executed immediately. @param [String] priority The priority value of the Tasks to read. Returns the

list of all Tasks in the Workspace with the specified priority.

@param [Array] assignment_status The `assignment_status` of the Tasks

you want to read. Can be: `pending`, `reserved`, `assigned`, `canceled`,
`wrapping`, or `completed`. Returns all Tasks in the Workspace with the
specified `assignment_status`.

@param [String] workflow_sid The SID of the Workflow with the Tasks to read.

Returns the Tasks controlled by the Workflow identified by this SID.

@param [String] workflow_name The friendly name of the Workflow with the Tasks

to read. Returns the Tasks controlled by the Workflow identified by this
friendly name.

@param [String] task_queue_sid The SID of the TaskQueue with the Tasks to read.

Returns the Tasks waiting in the TaskQueue identified by this SID.

@param [String] task_queue_name The `friendly_name` of the TaskQueue with the

Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this
friendly name.

@param [String] evaluate_task_attributes The attributes of the Tasks to read.

Returns the Tasks that match the attributes specified in this parameter.

@param [String] ordering How to order the returned Task resources. y default,

Tasks are sorted by ascending DateCreated. This value is specified as:
`Attribute:Order`, where `Attribute` can be either `Priority` or `DateCreated`
and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns
Tasks ordered in descending order of their Priority. Multiple sort orders can be
specified in a comma-separated list such as `Priority:desc,DateCreated:asc`,
which returns the Tasks in descending Priority order and ascending DateCreated
Order.

@param [Boolean] has_addons Whether to read Tasks with addons. If `true`,

returns only Tasks with addons. If `false`, returns only Tasks without addons.

@param [String] page_token PageToken provided by the API @param [Integer] page_number Page Number, this value is simply for client state @param [Integer] page_size Number of records to return, defaults to 50 @return [Page] Page of TaskInstance

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
190 def page(priority: :unset, assignment_status: :unset, workflow_sid: :unset, workflow_name: :unset, task_queue_sid: :unset, task_queue_name: :unset, evaluate_task_attributes: :unset, ordering: :unset, has_addons: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
191   params = Twilio::Values.of({
192       'Priority' => priority,
193       'AssignmentStatus' => Twilio.serialize_list(assignment_status) { |e| e },
194       'WorkflowSid' => workflow_sid,
195       'WorkflowName' => workflow_name,
196       'TaskQueueSid' => task_queue_sid,
197       'TaskQueueName' => task_queue_name,
198       'EvaluateTaskAttributes' => evaluate_task_attributes,
199       'Ordering' => ordering,
200       'HasAddons' => has_addons,
201       'PageToken' => page_token,
202       'Page' => page_number,
203       'PageSize' => page_size,
204   })
205 
206   response = @version.page('GET', @uri, params: params)
207 
208   TaskPage.new(@version, response, @solution)
209 end
stream(priority: :unset, assignment_status: :unset, workflow_sid: :unset, workflow_name: :unset, task_queue_sid: :unset, task_queue_name: :unset, evaluate_task_attributes: :unset, ordering: :unset, has_addons: :unset, limit: nil, page_size: nil) click to toggle source

Streams TaskInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] priority The priority value of the Tasks to read. Returns the

list of all Tasks in the Workspace with the specified priority.

@param [Array] assignment_status The `assignment_status` of the Tasks

you want to read. Can be: `pending`, `reserved`, `assigned`, `canceled`,
`wrapping`, or `completed`. Returns all Tasks in the Workspace with the
specified `assignment_status`.

@param [String] workflow_sid The SID of the Workflow with the Tasks to read.

Returns the Tasks controlled by the Workflow identified by this SID.

@param [String] workflow_name The friendly name of the Workflow with the Tasks

to read. Returns the Tasks controlled by the Workflow identified by this
friendly name.

@param [String] task_queue_sid The SID of the TaskQueue with the Tasks to read.

Returns the Tasks waiting in the TaskQueue identified by this SID.

@param [String] task_queue_name The `friendly_name` of the TaskQueue with the

Tasks to read. Returns the Tasks waiting in the TaskQueue identified by this
friendly name.

@param [String] evaluate_task_attributes The attributes of the Tasks to read.

Returns the Tasks that match the attributes specified in this parameter.

@param [String] ordering How to order the returned Task resources. y default,

Tasks are sorted by ascending DateCreated. This value is specified as:
`Attribute:Order`, where `Attribute` can be either `Priority` or `DateCreated`
and `Order` can be either `asc` or `desc`. For example, `Priority:desc` returns
Tasks ordered in descending order of their Priority. Multiple sort orders can be
specified in a comma-separated list such as `Priority:desc,DateCreated:asc`,
which returns the Tasks in descending Priority order and ascending DateCreated
Order.

@param [Boolean] has_addons Whether to read Tasks with addons. If `true`,

returns only Tasks with addons. If `false`, returns only Tasks without addons.

@param [Integer] limit Upper limit for the number of records to return. stream()

guarantees to never return more than limit. Default is no limit.

@param [Integer] page_size Number of records to fetch per request, when

not set will use the default value of 50 records. If no page_size is defined
but a limit is defined, stream() will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)

@return [Enumerable] Enumerable that will yield up to limit results

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
122 def stream(priority: :unset, assignment_status: :unset, workflow_sid: :unset, workflow_name: :unset, task_queue_sid: :unset, task_queue_name: :unset, evaluate_task_attributes: :unset, ordering: :unset, has_addons: :unset, limit: nil, page_size: nil)
123   limits = @version.read_limits(limit, page_size)
124 
125   page = self.page(
126       priority: priority,
127       assignment_status: assignment_status,
128       workflow_sid: workflow_sid,
129       workflow_name: workflow_name,
130       task_queue_sid: task_queue_sid,
131       task_queue_name: task_queue_name,
132       evaluate_task_attributes: evaluate_task_attributes,
133       ordering: ordering,
134       has_addons: has_addons,
135       page_size: limits[:page_size],
136   )
137 
138   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
139 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/task.rb
262 def to_s
263   '#<Twilio.Taskrouter.V1.TaskList>'
264 end