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

Public Class Methods

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

Initialize the MessageInstance @param [Version] version Version that contains the resource @param [Hash] payload payload that contains response from Twilio @param [String] service_sid The SID of the

{Service}[https://www.twilio.com/docs/api/chat/rest/services] the resource is
associated with.

@param [String] channel_sid The unique ID of the

{Channel}[https://www.twilio.com/docs/api/chat/rest/channels] the Message
resource belongs to.

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

Message resource to fetch.

@return [MessageInstance] MessageInstance

Calls superclass method Twilio::REST::InstanceResource::new
    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
280 def initialize(version, payload, service_sid: nil, channel_sid: nil, sid: nil)
281   super(version)
282 
283   # Marshaled Properties
284   @properties = {
285       'sid' => payload['sid'],
286       'account_sid' => payload['account_sid'],
287       'attributes' => payload['attributes'],
288       'service_sid' => payload['service_sid'],
289       'to' => payload['to'],
290       'channel_sid' => payload['channel_sid'],
291       'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
292       'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
293       'was_edited' => payload['was_edited'],
294       'from' => payload['from'],
295       'body' => payload['body'],
296       'index' => payload['index'].to_i,
297       'url' => payload['url'],
298   }
299 
300   # Context
301   @instance_context = nil
302   @params = {
303       'service_sid' => service_sid,
304       'channel_sid' => channel_sid,
305       'sid' => sid || @properties['sid'],
306   }
307 end

Public Instance Methods

account_sid() click to toggle source

@return [String] The SID of the Account that created the resource

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
333 def account_sid
334   @properties['account_sid']
335 end
attributes() click to toggle source

@return [String] The JSON string that stores application-specific data

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
339 def attributes
340   @properties['attributes']
341 end
body() click to toggle source

@return [String] The content of the message

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
387 def body
388   @properties['body']
389 end
channel_sid() click to toggle source

@return [String] The unique ID of the Channel the Message resource belongs to

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
357 def channel_sid
358   @properties['channel_sid']
359 end
context() click to toggle source

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context @return [MessageContext] MessageContext for this MessageInstance

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
313 def context
314   unless @instance_context
315     @instance_context = MessageContext.new(
316         @version,
317         @params['service_sid'],
318         @params['channel_sid'],
319         @params['sid'],
320     )
321   end
322   @instance_context
323 end
date_created() click to toggle source

@return [Time] The RFC 2822 date and time in GMT when the resource was created

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
363 def date_created
364   @properties['date_created']
365 end
date_updated() click to toggle source

@return [Time] The RFC 2822 date and time in GMT when the resource was last updated

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
369 def date_updated
370   @properties['date_updated']
371 end
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
413 def delete
414   context.delete
415 end
fetch() click to toggle source

Fetch the MessageInstance @return [MessageInstance] Fetched MessageInstance

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
406 def fetch
407   context.fetch
408 end
from() click to toggle source

@return [String] The identity of the message's author

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
381 def from
382   @properties['from']
383 end
index() click to toggle source

@return [String] The index of the message within the Channel

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
393 def index
394   @properties['index']
395 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
438 def inspect
439   values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
440   "<Twilio.Chat.V1.MessageInstance #{values}>"
441 end
service_sid() click to toggle source

@return [String] The SID of the Service that the resource is associated with

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
345 def service_sid
346   @properties['service_sid']
347 end
sid() click to toggle source

@return [String] The unique string that identifies the resource

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
327 def sid
328   @properties['sid']
329 end
to() click to toggle source

@return [String] The SID of the Channel that the message was sent to

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
351 def to
352   @properties['to']
353 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
431 def to_s
432   values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
433   "<Twilio.Chat.V1.MessageInstance #{values}>"
434 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
425 def update(body: :unset, attributes: :unset)
426   context.update(body: body, attributes: attributes, )
427 end
url() click to toggle source

@return [String] The absolute URL of the Message resource

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
399 def url
400   @properties['url']
401 end
was_edited() click to toggle source

@return [Boolean] Whether the message has been edited since it was created

    # File lib/twilio-ruby/rest/chat/v1/service/channel/message.rb
375 def was_edited
376   @properties['was_edited']
377 end