class Twilio::REST::Conversations::V1::ConversationContext::MessageContext
Public Class Methods
Initialize the MessageContext
@param [Version] version Version
that contains the resource @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 [MessageContext] MessageContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 195 def initialize(version, conversation_sid, sid) 196 super(version) 197 198 # Path Solution 199 @solution = {conversation_sid: conversation_sid, sid: sid, } 200 @uri = "/Conversations/#{@solution[:conversation_sid]}/Messages/#{@solution[:sid]}" 201 202 # Dependents 203 @delivery_receipts = nil 204 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/conversations/v1/conversation/message.rb 246 def delete(x_twilio_webhook_enabled: :unset) 247 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 248 249 @version.delete('DELETE', @uri, headers: headers) 250 end
Access the delivery_receipts
@return [DeliveryReceiptList] @return [DeliveryReceiptContext] if sid was passed.
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 270 def delivery_receipts(sid=:unset) 271 raise ArgumentError, 'sid cannot be nil' if sid.nil? 272 273 if sid != :unset 274 return DeliveryReceiptContext.new(@version, @solution[:conversation_sid], @solution[:sid], sid, ) 275 end 276 277 unless @delivery_receipts 278 @delivery_receipts = DeliveryReceiptList.new( 279 @version, 280 conversation_sid: @solution[:conversation_sid], 281 message_sid: @solution[:sid], 282 ) 283 end 284 285 @delivery_receipts 286 end
Fetch the MessageInstance
@return [MessageInstance] Fetched MessageInstance
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 255 def fetch 256 payload = @version.fetch('GET', @uri) 257 258 MessageInstance.new( 259 @version, 260 payload, 261 conversation_sid: @solution[:conversation_sid], 262 sid: @solution[:sid], 263 ) 264 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 297 def inspect 298 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 299 "#<Twilio.Conversations.V1.MessageContext #{context}>" 300 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/conversations/v1/conversation/message.rb 290 def to_s 291 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 292 "#<Twilio.Conversations.V1.MessageContext #{context}>" 293 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 221 def update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset) 222 data = Twilio::Values.of({ 223 'Author' => author, 224 'Body' => body, 225 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 226 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 227 'Attributes' => attributes, 228 }) 229 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 230 231 payload = @version.update('POST', @uri, data: data, headers: headers) 232 233 MessageInstance.new( 234 @version, 235 payload, 236 conversation_sid: @solution[:conversation_sid], 237 sid: @solution[:sid], 238 ) 239 end