class Twilio::REST::Chat::V2::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/chat/rest/service-resource] the Message
resource is associated with.

@param [String] channel_sid The SID of the

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

@param [String] sid The SID of the Message resource to fetch. @return [MessageInstance] MessageInstance

Calls superclass method Twilio::REST::InstanceResource::new
    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
330 def initialize(version, payload, service_sid: nil, channel_sid: nil, sid: nil)
331   super(version)
332 
333   # Marshaled Properties
334   @properties = {
335       'sid' => payload['sid'],
336       'account_sid' => payload['account_sid'],
337       'attributes' => payload['attributes'],
338       'service_sid' => payload['service_sid'],
339       'to' => payload['to'],
340       'channel_sid' => payload['channel_sid'],
341       'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
342       'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
343       'last_updated_by' => payload['last_updated_by'],
344       'was_edited' => payload['was_edited'],
345       'from' => payload['from'],
346       'body' => payload['body'],
347       'index' => payload['index'].to_i,
348       'type' => payload['type'],
349       'media' => payload['media'],
350       'url' => payload['url'],
351   }
352 
353   # Context
354   @instance_context = nil
355   @params = {
356       'service_sid' => service_sid,
357       'channel_sid' => channel_sid,
358       'sid' => sid || @properties['sid'],
359   }
360 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/v2/service/channel/message.rb
386 def account_sid
387   @properties['account_sid']
388 end
attributes() click to toggle source

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

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
392 def attributes
393   @properties['attributes']
394 end
body() click to toggle source

@return [String] The content of the message

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
446 def body
447   @properties['body']
448 end
channel_sid() click to toggle source

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

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
410 def channel_sid
411   @properties['channel_sid']
412 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/v2/service/channel/message.rb
366 def context
367   unless @instance_context
368     @instance_context = MessageContext.new(
369         @version,
370         @params['service_sid'],
371         @params['channel_sid'],
372         @params['sid'],
373     )
374   end
375   @instance_context
376 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/v2/service/channel/message.rb
416 def date_created
417   @properties['date_created']
418 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/v2/service/channel/message.rb
422 def date_updated
423   @properties['date_updated']
424 end
delete(x_twilio_webhook_enabled: :unset) click to toggle source

Delete the MessageInstance @param [message.WebhookEnabledType] x_twilio_webhook_enabled The

X-Twilio-Webhook-Enabled HTTP request header

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

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
486 def delete(x_twilio_webhook_enabled: :unset)
487   context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
488 end
fetch() click to toggle source

Fetch the MessageInstance @return [MessageInstance] Fetched MessageInstance

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
477 def fetch
478   context.fetch
479 end
from() click to toggle source

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

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
440 def from
441   @properties['from']
442 end
index() click to toggle source

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

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
452 def index
453   @properties['index']
454 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
534 def inspect
535   values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
536   "<Twilio.Chat.V2.MessageInstance #{values}>"
537 end
last_updated_by() click to toggle source

@return [String] The Identity of the User who last updated the Message

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
428 def last_updated_by
429   @properties['last_updated_by']
430 end
media() click to toggle source

@return [Hash] A Media object that describes the Message's media if attached; otherwise, null

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
464 def media
465   @properties['media']
466 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/v2/service/channel/message.rb
398 def service_sid
399   @properties['service_sid']
400 end
sid() click to toggle source

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

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
380 def sid
381   @properties['sid']
382 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/v2/service/channel/message.rb
404 def to
405   @properties['to']
406 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
527 def to_s
528   values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
529   "<Twilio.Chat.V2.MessageInstance #{values}>"
530 end
type() click to toggle source

@return [String] The Message type

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
458 def type
459   @properties['type']
460 end
update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, from: :unset, x_twilio_webhook_enabled: :unset) click to toggle source

Update the MessageInstance @param [String] body The message to send to the channel. Can 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.

@param [Time] date_created The date, specified in {ISO

8601}[https://en.wikipedia.org/wiki/ISO_8601] format, to assign to the resource
as the date it was created. The default value is the current time set by the
Chat service. This parameter should only be used when a Chat's history is being
recreated from a backup/separate source.

@param [Time] date_updated The date, specified in {ISO

8601}[https://en.wikipedia.org/wiki/ISO_8601] format, to assign to the resource
as the date it was last updated.

@param [String] last_updated_by The

{Identity}[https://www.twilio.com/docs/chat/identity] of the User who last
updated the Message, if applicable.

@param [String] from The Identity

of the message's author.

@param [message.WebhookEnabledType] x_twilio_webhook_enabled The

X-Twilio-Webhook-Enabled HTTP request header

@return [MessageInstance] Updated MessageInstance

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
513 def update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, from: :unset, x_twilio_webhook_enabled: :unset)
514   context.update(
515       body: body,
516       attributes: attributes,
517       date_created: date_created,
518       date_updated: date_updated,
519       last_updated_by: last_updated_by,
520       from: from,
521       x_twilio_webhook_enabled: x_twilio_webhook_enabled,
522   )
523 end
url() click to toggle source

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

    # File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
470 def url
471   @properties['url']
472 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/v2/service/channel/message.rb
434 def was_edited
435   @properties['was_edited']
436 end