class Twilio::REST::IpMessaging::V1::ServiceContext::ChannelContext::MessageList

Public Class Methods

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

Initialize the MessageList @param [Version] version Version that contains the resource @param [String] service_sid The service_sid @param [String] channel_sid The channel_sid @return [MessageList] MessageList

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

Public Instance Methods

create(body: nil, from: :unset, attributes: :unset) click to toggle source

Create the MessageInstance @param [String] body The body @param [String] from The from @param [String] attributes The attributes @return [MessageInstance] Created MessageInstance

   # File lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb
36 def create(body: nil, from: :unset, attributes: :unset)
37   data = Twilio::Values.of({'Body' => body, 'From' => from, 'Attributes' => attributes, })
38 
39   payload = @version.create('POST', @uri, data: data)
40 
41   MessageInstance.new(
42       @version,
43       payload,
44       service_sid: @solution[:service_sid],
45       channel_sid: @solution[:channel_sid],
46   )
47 end
each() { |x| ... } click to toggle source

When passed a block, yields MessageInstance 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/message.rb
89 def each
90   limits = @version.read_limits
91 
92   page = self.page(page_size: limits[:page_size], )
93 
94   @version.stream(page,
95                   limit: limits[:limit],
96                   page_limit: limits[:page_limit]).each {|x| yield x}
97 end
get_page(target_url) click to toggle source

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

    # File lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb
125 def get_page(target_url)
126   response = @version.domain.request(
127       'GET',
128       target_url
129   )
130   MessagePage.new(@version, response, @solution)
131 end
list(order: :unset, limit: nil, page_size: nil) click to toggle source

Lists MessageInstance records from the API as a list. Unlike stream(), this operation is eager and will load `limit` records into memory before returning. @param [message.OrderType] order The order @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/message.rb
61 def list(order: :unset, limit: nil, page_size: nil)
62   self.stream(order: order, limit: limit, page_size: page_size).entries
63 end
page(order: :unset, page_token: :unset, page_number: :unset, page_size: :unset) click to toggle source

Retrieve a single page of MessageInstance records from the API. Request is executed immediately. @param [message.OrderType] order The order @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 MessageInstance

    # File lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb
107 def page(order: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
108   params = Twilio::Values.of({
109       'Order' => order,
110       'PageToken' => page_token,
111       'Page' => page_number,
112       'PageSize' => page_size,
113   })
114 
115   response = @version.page('GET', @uri, params: params)
116 
117   MessagePage.new(@version, response, @solution)
118 end
stream(order: :unset, limit: nil, page_size: nil) click to toggle source

Streams MessageInstance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached. @param [message.OrderType] order The order @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/message.rb
77 def stream(order: :unset, limit: nil, page_size: nil)
78   limits = @version.read_limits(limit, page_size)
79 
80   page = self.page(order: order, page_size: limits[:page_size], )
81 
82   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
83 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/ip_messaging/v1/service/channel/message.rb
135 def to_s
136   '#<Twilio.IpMessaging.V1.MessageList>'
137 end