class Twilio::REST::Conversations::V1::ConversationContext::MessageInstance
Public Class Methods
Initialize the MessageInstance
@param [Version] version Version
that contains the resource @param [Hash] payload payload that contains response from Twilio
@param [String] conversation_sid
The unique ID of the
{Conversation}[https://www.twilio.com/docs/conversations/api/conversation-resource] for this message.
@param [String] sid A 34 character string that uniquely identifies this
resource.
@return [MessageInstance] MessageInstance
Twilio::REST::InstanceResource::new
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 314 def initialize(version, payload, conversation_sid: nil, sid: nil) 315 super(version) 316 317 # Marshaled Properties 318 @properties = { 319 'account_sid' => payload['account_sid'], 320 'conversation_sid' => payload['conversation_sid'], 321 'sid' => payload['sid'], 322 'index' => payload['index'].to_i, 323 'author' => payload['author'], 324 'body' => payload['body'], 325 'media' => payload['media'], 326 'attributes' => payload['attributes'], 327 'participant_sid' => payload['participant_sid'], 328 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']), 329 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']), 330 'url' => payload['url'], 331 'delivery' => payload['delivery'], 332 'links' => payload['links'], 333 } 334 335 # Context 336 @instance_context = nil 337 @params = {'conversation_sid' => conversation_sid, 'sid' => sid || @properties['sid'], } 338 end
Public Instance Methods
@return [String] The unique ID of the Account responsible for this message.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 353 def account_sid 354 @properties['account_sid'] 355 end
@return [String] A string metadata field you can use to store any data you wish.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 395 def attributes 396 @properties['attributes'] 397 end
@return [String] The content of the message.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 383 def body 384 @properties['body'] 385 end
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/conversations/v1/conversation/message.rb 344 def context 345 unless @instance_context 346 @instance_context = MessageContext.new(@version, @params['conversation_sid'], @params['sid'], ) 347 end 348 @instance_context 349 end
@return [String] The unique ID of the Conversation for this message.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 359 def conversation_sid 360 @properties['conversation_sid'] 361 end
@return [Time] The date that this resource was created.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 407 def date_created 408 @properties['date_created'] 409 end
@return [Time] The date that this resource was last updated.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 413 def date_updated 414 @properties['date_updated'] 415 end
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/conversations/v1/conversation/message.rb 466 def delete(x_twilio_webhook_enabled: :unset) 467 context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, ) 468 end
@return [Hash] An object that contains the summary of delivery statuses for the message to non-chat participants.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 425 def delivery 426 @properties['delivery'] 427 end
Access the delivery_receipts
@return [delivery_receipts] delivery_receipts
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 480 def delivery_receipts 481 context.delivery_receipts 482 end
Fetch the MessageInstance
@return [MessageInstance] Fetched MessageInstance
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 473 def fetch 474 context.fetch 475 end
@return [String] The index of the message within the Conversation.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 371 def index 372 @properties['index'] 373 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 493 def inspect 494 values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") 495 "<Twilio.Conversations.V1.MessageInstance #{values}>" 496 end
@return [String] Absolute URL to access the receipts of this message.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 431 def links 432 @properties['links'] 433 end
@return [Array] An array of objects that describe the Message's media if attached, otherwise, null.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 389 def media 390 @properties['media'] 391 end
@return [String] The unique ID of messages's author participant.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 401 def participant_sid 402 @properties['participant_sid'] 403 end
@return [String] A 34 character string that uniquely identifies this resource.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 365 def sid 366 @properties['sid'] 367 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 486 def to_s 487 values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") 488 "<Twilio.Conversations.V1.MessageInstance #{values}>" 489 end
Update the MessageInstance
@param [String] author The channel specific identifier of the message's author.
Defaults to `system`.
@param [String] body The content of the message, can be up to 1,600 characters
long.
@param [Time] date_created
The date that this resource was created. @param [Time] date_updated
The date that this resource was last updated. `null`
if the message has not been edited.
@param [String] attributes A string metadata field you can use to store any data
you wish. The string value must contain structurally valid JSON if specified. **Note** that if the attributes are not set "{}" will be returned.
@param [message.WebhookEnabledType] x_twilio_webhook_enabled The
X-Twilio-Webhook-Enabled HTTP request header
@return [MessageInstance] Updated MessageInstance
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 450 def update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset) 451 context.update( 452 author: author, 453 body: body, 454 date_created: date_created, 455 date_updated: date_updated, 456 attributes: attributes, 457 x_twilio_webhook_enabled: x_twilio_webhook_enabled, 458 ) 459 end
@return [String] An absolute API URL for this message.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 419 def url 420 @properties['url'] 421 end