class Twilio::REST::Chat::V2::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/chat/rest/service-resource] the Channel
resource is associated with.

@return [ChannelList] ChannelList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/chat/v2/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, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :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
Channel 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`.

@param [Time] date_created The date, specified in {ISO

8601}[https://en.wikipedia.org/wiki/ISO_8601] format, to assign to the resource
as the date it was created. The default value is the current time set by the
Chat service.  Note that this should only be used in cases where a Channel is
being recreated from a backup/separate source.

@param [Time] date_updated The date, specified in {ISO

8601}[https://en.wikipedia.org/wiki/ISO_8601] format, to assign to the resource
as the date it was last updated. The default value is `null`. Note that this
parameter should only be used in cases where a Channel is being recreated from a
backup/separate source  and where a Message was previously updated.

@param [String] created_by The `identity` of the User that created the channel.

Default is: `system`.

@param [channel.WebhookEnabledType] x_twilio_webhook_enabled The

X-Twilio-Webhook-Enabled HTTP request header

@return [ChannelInstance] Created ChannelInstance

   # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
57 def create(friendly_name: :unset, unique_name: :unset, attributes: :unset, type: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset)
58   data = Twilio::Values.of({
59       'FriendlyName' => friendly_name,
60       'UniqueName' => unique_name,
61       'Attributes' => attributes,
62       'Type' => type,
63       'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
64       'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
65       'CreatedBy' => created_by,
66   })
67   headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
68 
69   payload = @version.create('POST', @uri, data: data, headers: headers)
70 
71   ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], )
72 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/v2/service/channel.rb
116 def each
117   limits = @version.read_limits
118 
119   page = self.page(page_size: limits[:page_size], )
120 
121   @version.stream(page,
122                   limit: limits[:limit],
123                   page_limit: limits[:page_limit]).each {|x| yield x}
124 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/v2/service/channel.rb
153 def get_page(target_url)
154   response = @version.domain.request(
155       'GET',
156       target_url
157   )
158   ChannelPage.new(@version, response, @solution)
159 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/v2/service/channel.rb
87 def list(type: :unset, limit: nil, page_size: nil)
88   self.stream(type: type, limit: limit, page_size: page_size).entries
89 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/v2/service/channel.rb
135 def page(type: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
136   params = Twilio::Values.of({
137       'Type' => Twilio.serialize_list(type) { |e| e },
138       'PageToken' => page_token,
139       'Page' => page_number,
140       'PageSize' => page_size,
141   })
142 
143   response = @version.page('GET', @uri, params: params)
144 
145   ChannelPage.new(@version, response, @solution)
146 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/v2/service/channel.rb
104 def stream(type: :unset, limit: nil, page_size: nil)
105   limits = @version.read_limits(limit, page_size)
106 
107   page = self.page(type: type, page_size: limits[:page_size], )
108 
109   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
110 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
163 def to_s
164   '#<Twilio.Chat.V2.ChannelList>'
165 end