Class: Twilio::REST::Conversations::V1::ConversationContext::MessageContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/conversation/message.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

#initialize(version, conversation_sid, sid) ⇒ MessageContext

Initialize the MessageContext

Parameters:



190
191
192
193
194
195
196
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 190

def initialize(version, conversation_sid, sid)
  super(version)

  # Path Solution
  @solution = {conversation_sid: conversation_sid, sid: sid, }
  @uri = "/Conversations/#{@solution[:conversation_sid]}/Messages/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Deletes the MessageInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



233
234
235
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 233

def delete
  @version.delete('delete', @uri)
end

#fetchMessageInstance

Fetch a MessageInstance

Returns:



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 240

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  MessageInstance.new(
      @version,
      payload,
      conversation_sid: @solution[:conversation_sid],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation



266
267
268
269
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 266

def inspect
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Conversations.V1.MessageContext #{context}>"
end

#to_sObject

Provide a user friendly representation



259
260
261
262
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 259

def to_s
  context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
  "#<Twilio.Conversations.V1.MessageContext #{context}>"
end

#update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset) ⇒ MessageInstance

Update the MessageInstance

Parameters:

  • author (String) (defaults to: :unset)

    The channel specific identifier of the message’s author. Defaults to ‘system`.

  • body (String) (defaults to: :unset)

    The content of the message, can be up to 1,600 characters long.

  • date_created (Time) (defaults to: :unset)

    The date that this resource was created.

  • date_updated (Time) (defaults to: :unset)

    The date that this resource was last updated. ‘null` if the message has not been edited.

Returns:



208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/message.rb', line 208

def update(author: :unset, body: :unset, date_created: :unset, date_updated: :unset)
  data = Twilio::Values.of({
      'Author' => author,
      'Body' => body,
      'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
      'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  MessageInstance.new(
      @version,
      payload,
      conversation_sid: @solution[:conversation_sid],
      sid: @solution[:sid],
  )
end