class Twilio::REST::Chat::V2::ServiceContext::ChannelContext::MessageContext
Public Class Methods
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/chat/rest/service-resource] to fetch the Message resource from.
@param [String] channel_sid The SID of the
{Channel}[https://www.twilio.com/docs/chat/channels] the Message resource to fetch belongs to. This value can be the Channel resource's `sid` or `unique_name`.
@param [String] sid The SID of the Message resource to fetch. @return [MessageContext] MessageContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb 223 def initialize(version, service_sid, channel_sid, sid) 224 super(version) 225 226 # Path Solution 227 @solution = {service_sid: service_sid, channel_sid: channel_sid, sid: sid, } 228 @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Messages/#{@solution[:sid]}" 229 end
Public Instance Methods
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 251 def delete(x_twilio_webhook_enabled: :unset) 252 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 253 254 @version.delete('DELETE', @uri, headers: headers) 255 end
Fetch the MessageInstance
@return [MessageInstance] Fetched MessageInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb 234 def fetch 235 payload = @version.fetch('GET', @uri) 236 237 MessageInstance.new( 238 @version, 239 payload, 240 service_sid: @solution[:service_sid], 241 channel_sid: @solution[:channel_sid], 242 sid: @solution[:sid], 243 ) 244 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb 311 def inspect 312 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 313 "#<Twilio.Chat.V2.MessageContext #{context}>" 314 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/chat/v2/service/channel/message.rb 304 def to_s 305 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 306 "#<Twilio.Chat.V2.MessageContext #{context}>" 307 end
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 280 def update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, from: :unset, x_twilio_webhook_enabled: :unset) 281 data = Twilio::Values.of({ 282 'Body' => body, 283 'Attributes' => attributes, 284 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 285 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 286 'LastUpdatedBy' => last_updated_by, 287 'From' => from, 288 }) 289 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 290 291 payload = @version.update('POST', @uri, data: data, headers: headers) 292 293 MessageInstance.new( 294 @version, 295 payload, 296 service_sid: @solution[:service_sid], 297 channel_sid: @solution[:channel_sid], 298 sid: @solution[:sid], 299 ) 300 end