class Twilio::REST::Conversations::V1::ServiceContext::ConversationContext::MessageContext

Public Class Methods

new(version, chat_service_sid, conversation_sid, sid) click to toggle source

Initialize the MessageContext @param [Version] version Version that contains the resource @param [String] chat_service_sid The SID of the {Conversation

Service}[https://www.twilio.com/docs/conversations/api/service-resource] the
Participant resource is associated with.

@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

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb
212 def initialize(version, chat_service_sid, conversation_sid, sid)
213   super(version)
214 
215   # Path Solution
216   @solution = {chat_service_sid: chat_service_sid, conversation_sid: conversation_sid, sid: sid, }
217   @uri = "/Services/#{@solution[:chat_service_sid]}/Conversations/#{@solution[:conversation_sid]}/Messages/#{@solution[:sid]}"
218 
219   # Dependents
220   @delivery_receipts = nil
221 end

Public Instance Methods

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/conversations/v1/service/conversation/message.rb
264 def delete(x_twilio_webhook_enabled: :unset)
265   headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
266 
267    @version.delete('DELETE', @uri, headers: headers)
268 end
delivery_receipts(sid=:unset) click to toggle source

Access the delivery_receipts @return [DeliveryReceiptList] @return [DeliveryReceiptContext] if sid was passed.

    # File lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb
289 def delivery_receipts(sid=:unset)
290   raise ArgumentError, 'sid cannot be nil' if sid.nil?
291 
292   if sid != :unset
293     return DeliveryReceiptContext.new(
294         @version,
295         @solution[:chat_service_sid],
296         @solution[:conversation_sid],
297         @solution[:sid],
298         sid,
299     )
300   end
301 
302   unless @delivery_receipts
303     @delivery_receipts = DeliveryReceiptList.new(
304         @version,
305         chat_service_sid: @solution[:chat_service_sid],
306         conversation_sid: @solution[:conversation_sid],
307         message_sid: @solution[:sid],
308     )
309   end
310 
311   @delivery_receipts
312 end
fetch() click to toggle source

Fetch the MessageInstance @return [MessageInstance] Fetched MessageInstance

    # File lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb
273 def fetch
274   payload = @version.fetch('GET', @uri)
275 
276   MessageInstance.new(
277       @version,
278       payload,
279       chat_service_sid: @solution[:chat_service_sid],
280       conversation_sid: @solution[:conversation_sid],
281       sid: @solution[:sid],
282   )
283 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb
323 def inspect
324   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
325   "#<Twilio.Conversations.V1.MessageContext #{context}>"
326 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb
316 def to_s
317   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
318   "#<Twilio.Conversations.V1.MessageContext #{context}>"
319 end
update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset) click to toggle source

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/service/conversation/message.rb
238 def update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset, attributes: :unset, x_twilio_webhook_enabled: :unset)
239   data = Twilio::Values.of({
240       'Author' => author,
241       'Body' => body,
242       'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
243       'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
244       'Attributes' => attributes,
245   })
246   headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
247 
248   payload = @version.update('POST', @uri, data: data, headers: headers)
249 
250   MessageInstance.new(
251       @version,
252       payload,
253       chat_service_sid: @solution[:chat_service_sid],
254       conversation_sid: @solution[:conversation_sid],
255       sid: @solution[:sid],
256   )
257 end