class Twilio::REST::IpMessaging::V1::ServiceContext::ChannelList
Public Class Methods
Initialize the ChannelList
@param [Version] version Version
that contains the resource @param [String] service_sid The service_sid @return [ChannelList] ChannelList
Twilio::REST::ListResource::new
# File lib/twilio-ruby/rest/ip_messaging/v1/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 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 @return [ChannelInstance] Created ChannelInstance
# File lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb 35 def create(friendly_name: :unset, unique_name: :unset, attributes: :unset, type: :unset) 36 data = Twilio::Values.of({ 37 'FriendlyName' => friendly_name, 38 'UniqueName' => unique_name, 39 'Attributes' => attributes, 40 'Type' => type, 41 }) 42 43 payload = @version.create('POST', @uri, data: data) 44 45 ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], ) 46 end
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/v1/service/channel.rb 88 def each 89 limits = @version.read_limits 90 91 page = self.page(page_size: limits[:page_size], ) 92 93 @version.stream(page, 94 limit: limits[:limit], 95 page_limit: limits[:page_limit]).each {|x| yield x} 96 end
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/v1/service/channel.rb 124 def get_page(target_url) 125 response = @version.domain.request( 126 'GET', 127 target_url 128 ) 129 ChannelPage.new(@version, response, @solution) 130 end
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/v1/service/channel.rb 60 def list(type: :unset, limit: nil, page_size: nil) 61 self.stream(type: type, limit: limit, page_size: page_size).entries 62 end
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/v1/service/channel.rb 106 def page(type: :unset, page_token: :unset, page_number: :unset, page_size: :unset) 107 params = Twilio::Values.of({ 108 'Type' => Twilio.serialize_list(type) { |e| e }, 109 'PageToken' => page_token, 110 'Page' => page_number, 111 'PageSize' => page_size, 112 }) 113 114 response = @version.page('GET', @uri, params: params) 115 116 ChannelPage.new(@version, response, @solution) 117 end
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/v1/service/channel.rb 76 def stream(type: :unset, limit: nil, page_size: nil) 77 limits = @version.read_limits(limit, page_size) 78 79 page = self.page(type: type, page_size: limits[:page_size], ) 80 81 @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit]) 82 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/ip_messaging/v1/service/channel.rb 134 def to_s 135 '#<Twilio.IpMessaging.V1.ChannelList>' 136 end