class Twilio::REST::Taskrouter::V1::WorkspaceContext::WorkflowList

Public Class Methods

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

Initialize the WorkflowList @param [Version] version Version that contains the resource @param [String] workspace_sid The SID of the Workspace that contains the

Workflow.

@return [WorkflowList] WorkflowList

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

Public Instance Methods

create(friendly_name: nil, configuration: nil, assignment_callback_url: :unset, fallback_assignment_callback_url: :unset, task_reservation_timeout: :unset) click to toggle source

Create the WorkflowInstance @param [String] friendly_name A descriptive string that you create to describe

the Workflow resource. For example, `Inbound Call Workflow` or `2014 Outbound
Campaign`.

@param [String] configuration A JSON string that contains the rules to apply to

the Workflow. See {Configuring
Workflows}[https://www.twilio.com/docs/taskrouter/workflow-configuration] for
more information.

@param [String] assignment_callback_url The URL from your application that will

process task assignment events. See {Handling Task Assignment
Callback}[https://www.twilio.com/docs/taskrouter/handle-assignment-callbacks]
for more details.

@param [String] fallback_assignment_callback_url The URL that we should call

when a call to the `assignment_callback_url` fails.

@param [String] task_reservation_timeout How long TaskRouter will wait for a

confirmation response from your application after it assigns a Task to a Worker.
Can be up to `86,400` (24 hours) and the default is `120`.

@return [WorkflowInstance] Created WorkflowInstance

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb
135 def create(friendly_name: nil, configuration: nil, assignment_callback_url: :unset, fallback_assignment_callback_url: :unset, task_reservation_timeout: :unset)
136   data = Twilio::Values.of({
137       'FriendlyName' => friendly_name,
138       'Configuration' => configuration,
139       'AssignmentCallbackUrl' => assignment_callback_url,
140       'FallbackAssignmentCallbackUrl' => fallback_assignment_callback_url,
141       'TaskReservationTimeout' => task_reservation_timeout,
142   })
143 
144   payload = @version.create('POST', @uri, data: data)
145 
146   WorkflowInstance.new(@version, payload, workspace_sid: @solution[:workspace_sid], )
147 end
each() { |x| ... } click to toggle source

When passed a block, yields WorkflowInstance 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/workflow.rb
71 def each
72   limits = @version.read_limits
73 
74   page = self.page(page_size: limits[:page_size], )
75 
76   @version.stream(page,
77                   limit: limits[:limit],
78                   page_limit: limits[:page_limit]).each {|x| yield x}
79 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb
108 def get_page(target_url)
109   response = @version.domain.request(
110       'GET',
111       target_url
112   )
113   WorkflowPage.new(@version, response, @solution)
114 end
list(friendly_name: :unset, limit: nil, page_size: nil) click to toggle source

Lists WorkflowInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [String] friendly_name The `friendly_name` of the Workflow resources to

read.

@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/workflow.rb
42 def list(friendly_name: :unset, limit: nil, page_size: nil)
43   self.stream(friendly_name: friendly_name, limit: limit, page_size: page_size).entries
44 end
page(friendly_name: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of WorkflowInstance records from the API. Request is executed immediately. @param [String] friendly_name The `friendly_name` of the Workflow resources to

read.

@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 WorkflowInstance

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb
 90 def page(friendly_name: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
 91   params = Twilio::Values.of({
 92       'FriendlyName' => friendly_name,
 93       'PageToken' => page_token,
 94       'Page' => page_number,
 95       'PageSize' => page_size,
 96   })
 97 
 98   response = @version.page('GET', @uri, params: params)
 99 
100   WorkflowPage.new(@version, response, @solution)
101 end
stream(friendly_name: :unset, limit: nil, page_size: nil) click to toggle source

Streams WorkflowInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [String] friendly_name The `friendly_name` of the Workflow resources to

read.

@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/workflow.rb
59 def stream(friendly_name: :unset, limit: nil, page_size: nil)
60   limits = @version.read_limits(limit, page_size)
61 
62   page = self.page(friendly_name: friendly_name, page_size: limits[:page_size], )
63 
64   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
65 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/taskrouter/v1/workspace/workflow.rb
151 def to_s
152   '#<Twilio.Taskrouter.V1.WorkflowList>'
153 end