class Twilio::REST::IpMessaging::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 service_sid @return [ChannelList] ChannelList

Calls superclass method Twilio::REST::ListResource::new
   # File lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb
20 def initialize(version, service_sid: nil)
21   super(version)
22 
23   # Path Solution
24   @solution = {service_sid: service_sid}
25   @uri = "/Services/#{@solution[:service_sid]}/Channels"
26 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 The friendly_name @param [String] unique_name The unique_name @param [String] attributes The attributes @param [channel.ChannelType] type The type @param [Time] date_created The date_created @param [Time] date_updated The date_updated @param [String] created_by The created_by @param [channel.WebhookEnabledType] x_twilio_webhook_enabled The

X-Twilio-Webhook-Enabled HTTP request header

@return [ChannelInstance] Created ChannelInstance

   # File lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb
40 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)
41   data = Twilio::Values.of({
42       'FriendlyName' => friendly_name,
43       'UniqueName' => unique_name,
44       'Attributes' => attributes,
45       'Type' => type,
46       'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
47       'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
48       'CreatedBy' => created_by,
49   })
50   headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
51 
52   payload = @version.create('POST', @uri, data: data, headers: headers)
53 
54   ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], )
55 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/ip_messaging/v2/service/channel.rb
 97 def each
 98   limits = @version.read_limits
 99 
100   page = self.page(page_size: limits[:page_size], )
101 
102   @version.stream(page,
103                   limit: limits[:limit],
104                   page_limit: limits[:page_limit]).each {|x| yield x}
105 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/ip_messaging/v2/service/channel.rb
133 def get_page(target_url)
134   response = @version.domain.request(
135       'GET',
136       target_url
137   )
138   ChannelPage.new(@version, response, @solution)
139 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 type @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/ip_messaging/v2/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 type @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/ip_messaging/v2/service/channel.rb
115 def page(type: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
116   params = Twilio::Values.of({
117       'Type' => Twilio.serialize_list(type) { |e| e },
118       'PageToken' => page_token,
119       'Page' => page_number,
120       'PageSize' => page_size,
121   })
122 
123   response = @version.page('GET', @uri, params: params)
124 
125   ChannelPage.new(@version, response, @solution)
126 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 type @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/ip_messaging/v2/service/channel.rb
85 def stream(type: :unset, limit: nil, page_size: nil)
86   limits = @version.read_limits(limit, page_size)
87 
88   page = self.page(type: type, page_size: limits[:page_size], )
89 
90   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
91 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb
143 def to_s
144   '#<Twilio.IpMessaging.V2.ChannelList>'
145 end