class Twilio::REST::Chat::V1::ServiceContext::ChannelContext::MessageContext

Public Class Methods

new(version, service_sid, channel_sid, sid) click to toggle source

Initialize the MessageContext @param [Version] version Version that contains the resource @param [String] service_sid The SID of the

{Service}[https://www.twilio.com/docs/api/chat/rest/services] to fetch the
resource from.

@param [String] channel_sid The unique ID of the

{Channel}[https://www.twilio.com/docs/api/chat/rest/channels] the message to
fetch belongs to. Can be the Channel's `sid` or `unique_name`.

@param [String] sid The Twilio-provided string that uniquely identifies the

Message resource to fetch.

@return [MessageContext] MessageContext

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
199 def initialize(version, service_sid, channel_sid, sid)
200   super(version)
201 
202   # Path Solution
203   @solution = {service_sid: service_sid, channel_sid: channel_sid, sid: sid, }
204   @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Messages/#{@solution[:sid]}"
205 end

Public Instance Methods

delete() click to toggle source

Delete the MessageInstance @return [Boolean] true if delete succeeds, false otherwise

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
225 def delete
226    @version.delete('DELETE', @uri)
227 end
fetch() click to toggle source

Fetch the MessageInstance @return [MessageInstance] Fetched MessageInstance

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
210 def fetch
211   payload = @version.fetch('GET', @uri)
212 
213   MessageInstance.new(
214       @version,
215       payload,
216       service_sid: @solution[:service_sid],
217       channel_sid: @solution[:channel_sid],
218       sid: @solution[:sid],
219   )
220 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
260 def inspect
261   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
262   "#<Twilio.Chat.V1.MessageContext #{context}>"
263 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
253 def to_s
254   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
255   "#<Twilio.Chat.V1.MessageContext #{context}>"
256 end
update(body: :unset, attributes: :unset) click to toggle source

Update the MessageInstance @param [String] body The message to send to the channel. Can also be an empty

string or `null`, which sets the value as an empty string. You can send
structured data in the body by serializing it as a string.

@param [String] attributes A valid JSON string that contains

application-specific data.

@return [MessageInstance] Updated MessageInstance

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
237 def update(body: :unset, attributes: :unset)
238   data = Twilio::Values.of({'Body' => body, 'Attributes' => attributes, })
239 
240   payload = @version.update('POST', @uri, data: data)
241 
242   MessageInstance.new(
243       @version,
244       payload,
245       service_sid: @solution[:service_sid],
246       channel_sid: @solution[:channel_sid],
247       sid: @solution[:sid],
248   )
249 end