class Twilio::REST::IpMessaging::V2::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/v2/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(from: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, body: :unset, media_sid: :unset, x_twilio_webhook_enabled: :unset) click to toggle source

Create the MessageInstance @param [String] from The from @param [String] attributes The attributes @param [Time] date_created The date_created @param [Time] date_updated The date_updated @param [String] last_updated_by The last_updated_by @param [String] body The body @param [String] media_sid The media_sid @param [message.WebhookEnabledType] x_twilio_webhook_enabled The

X-Twilio-Webhook-Enabled HTTP request header

@return [MessageInstance] Created MessageInstance

   # File lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb
42 def create(from: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, body: :unset, media_sid: :unset, x_twilio_webhook_enabled: :unset)
43   data = Twilio::Values.of({
44       'From' => from,
45       'Attributes' => attributes,
46       'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
47       'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
48       'LastUpdatedBy' => last_updated_by,
49       'Body' => body,
50       'MediaSid' => media_sid,
51   })
52   headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
53 
54   payload = @version.create('POST', @uri, data: data, headers: headers)
55 
56   MessageInstance.new(
57       @version,
58       payload,
59       service_sid: @solution[:service_sid],
60       channel_sid: @solution[:channel_sid],
61   )
62 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/v2/service/channel/message.rb
104 def each
105   limits = @version.read_limits
106 
107   page = self.page(page_size: limits[:page_size], )
108 
109   @version.stream(page,
110                   limit: limits[:limit],
111                   page_limit: limits[:page_limit]).each {|x| yield x}
112 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/v2/service/channel/message.rb
140 def get_page(target_url)
141   response = @version.domain.request(
142       'GET',
143       target_url
144   )
145   MessagePage.new(@version, response, @solution)
146 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/v2/service/channel/message.rb
76 def list(order: :unset, limit: nil, page_size: nil)
77   self.stream(order: order, limit: limit, page_size: page_size).entries
78 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/v2/service/channel/message.rb
122 def page(order: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
123   params = Twilio::Values.of({
124       'Order' => order,
125       'PageToken' => page_token,
126       'Page' => page_number,
127       'PageSize' => page_size,
128   })
129 
130   response = @version.page('GET', @uri, params: params)
131 
132   MessagePage.new(@version, response, @solution)
133 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/v2/service/channel/message.rb
92 def stream(order: :unset, limit: nil, page_size: nil)
93   limits = @version.read_limits(limit, page_size)
94 
95   page = self.page(order: order, page_size: limits[:page_size], )
96 
97   @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
98 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb
150 def to_s
151   '#<Twilio.IpMessaging.V2.MessageList>'
152 end