class Twilio::REST::Taskrouter::V1::WorkspaceContext::TaskChannelList
Public Class Methods
Initialize the TaskChannelList
@param [Version] version Version
that contains the resource @param [String] workspace_sid The SID of the Workspace that contains the Task
Channel.
@return [TaskChannelList] TaskChannelList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.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]}/TaskChannels" 27 end
Public Instance Methods
Create the TaskChannelInstance
@param [String] friendly_name A descriptive string that you create to describe
the Task Channel. It can be up to 64 characters long.
@param [String] unique_name An application-defined string that uniquely
identifies the Task Channel, such as `voice` or `sms`.
@param [Boolean] channel_optimized_routing Whether the Task Channel should
prioritize Workers that have been idle. If `true`, Workers that have been idle the longest are prioritized.
@return [TaskChannelInstance] Created TaskChannelInstance
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb 119 def create(friendly_name: nil, unique_name: nil, channel_optimized_routing: :unset) 120 data = Twilio::Values.of({ 121 'FriendlyName' => friendly_name, 122 'UniqueName' => unique_name, 123 'ChannelOptimizedRouting' => channel_optimized_routing, 124 }) 125 126 payload = @version.create('POST', @uri, data: data) 127 128 TaskChannelInstance.new(@version, payload, workspace_sid: @solution[:workspace_sid], ) 129 end
When passed a block, yields TaskChannelInstance
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_channel.rb 67 def each 68 limits = @version.read_limits 69 70 page = self.page(page_size: limits[:page_size], ) 71 72 @version.stream(page, 73 limit: limits[:limit], 74 page_limit: limits[:page_limit]).each {|x| yield x} 75 end
Retrieve a single page of TaskChannelInstance
records from the API. Request
is executed immediately. @param [String] target_url API-generated URL for the requested results page @return [Page] Page
of TaskChannelInstance
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb 101 def get_page(target_url) 102 response = @version.domain.request( 103 'GET', 104 target_url 105 ) 106 TaskChannelPage.new(@version, response, @solution) 107 end
Lists TaskChannelInstance
records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @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_channel.rb 40 def list(limit: nil, page_size: nil) 41 self.stream(limit: limit, page_size: page_size).entries 42 end
Retrieve a single page of TaskChannelInstance
records from the API. Request
is executed immediately. @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 TaskChannelInstance
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb 84 def page(page_token: :unset, page_number: :unset, page_size: :unset) 85 params = Twilio::Values.of({ 86 'PageToken' => page_token, 87 'Page' => page_number, 88 'PageSize' => page_size, 89 }) 90 91 response = @version.page('GET', @uri, params: params) 92 93 TaskChannelPage.new(@version, response, @solution) 94 end
Streams TaskChannelInstance
records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @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_channel.rb 55 def stream(limit: nil, page_size: nil) 56 limits = @version.read_limits(limit, page_size) 57 58 page = self.page(page_size: limits[:page_size], ) 59 60 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 61 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/taskrouter/v1/workspace/task_channel.rb 133 def to_s 134 '#<Twilio.Taskrouter.V1.TaskChannelList>' 135 end