class Twilio::REST::Chat::V1::ServiceContext::ChannelList

Public Class Methods

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

Initialize the ChannelList @param [Version] version Version that contains the resource @param [String] service_sid The SID of the

{Service}[https://www.twilio.com/docs/api/chat/rest/services] the resource is
associated with.

@return [ChannelList] ChannelList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
22 def initialize(version, service_sid: nil)
23   super(version)
24 
25   # Path Solution
26   @solution = {service_sid: service_sid}
27   @uri = "/Services/#{@solution[:service_sid]}/Channels"
28 end

Public Instance Methods

create(friendly_name: :unset, unique_name: :unset, attributes: :unset, type: :unset) click to toggle source

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

the new resource. It can be up to 64 characters long.

@param [String] unique_name An application-defined string that uniquely

identifies the resource. It can be used to address the resource in place of the
resource's `sid` in the URL. This value must be 64 characters or less in length
and be unique within the Service.

@param [String] attributes A valid JSON string that contains

application-specific data.

@param [channel.ChannelType] type The visibility of the channel. Can be:

`public` or `private` and defaults to `public`.

@return [ChannelInstance] Created ChannelInstance

   # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
43 def create(friendly_name: :unset, unique_name: :unset, attributes: :unset, type: :unset)
44   data = Twilio::Values.of({
45       'FriendlyName' => friendly_name,
46       'UniqueName' => unique_name,
47       'Attributes' => attributes,
48       'Type' => type,
49   })
50 
51   payload = @version.create('POST', @uri, data: data)
52 
53   ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], )
54 end
each() { |x| ... } click to toggle source

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

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
 98 def each
 99   limits = @version.read_limits
100 
101   page = self.page(page_size: limits[:page_size], )
102 
103   @version.stream(page,
104                   limit: limits[:limit],
105                   page_limit: limits[:page_limit]).each {|x| yield x}
106 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
135 def get_page(target_url)
136   response = @version.domain.request(
137       'GET',
138       target_url
139   )
140   ChannelPage.new(@version, response, @solution)
141 end
list(type: :unset, limit: nil, page_size: nil) click to toggle source

Lists ChannelInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [Array] type The visibility of the Channels to read.

Can be: `public` or `private` and defaults to `public`.

@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/chat/v1/service/channel.rb
69 def list(type: :unset, limit: nil, page_size: nil)
70   self.stream(type: type, limit: limit, page_size: page_size).entries
71 end
page(type: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of ChannelInstance records from the API. Request is executed immediately. @param [Array] type The visibility of the Channels to read.

Can be: `public` or `private` and defaults to `public`.

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

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
117 def page(type: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
118   params = Twilio::Values.of({
119       'Type' => Twilio.serialize_list(type) { |e| e },
120       'PageToken' => page_token,
121       'Page' => page_number,
122       'PageSize' => page_size,
123   })
124 
125   response = @version.page('GET', @uri, params: params)
126 
127   ChannelPage.new(@version, response, @solution)
128 end
stream(type: :unset, limit: nil, page_size: nil) click to toggle source

Streams ChannelInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [Array] type The visibility of the Channels to read.

Can be: `public` or `private` and defaults to `public`.

@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/chat/v1/service/channel.rb
86 def stream(type: :unset, limit: nil, page_size: nil)
87   limits = @version.read_limits(limit, page_size)
88 
89   page = self.page(type: type, page_size: limits[:page_size], )
90 
91   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
92 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
145 def to_s
146   '#<Twilio.Chat.V1.ChannelList>'
147 end