Class: Twilio::REST::Chat::V2::ServiceContext::ChannelContext::MessageContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/chat/v2/service/channel/message.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, channel_sid, sid) ⇒ MessageContext

Initialize the MessageContext

Parameters:



230
231
232
233
234
235
236
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/message.rb', line 230

def initialize(version, service_sid, channel_sid, sid)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, channel_sid: channel_sid, sid: sid, }
  @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Messages/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Deletes the MessageInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



262
263
264
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/message.rb', line 262

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

#fetchMessageInstance

Fetch a MessageInstance

Returns:



241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/message.rb', line 241

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

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

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

#to_sObject

Provide a user friendly representation



312
313
314
315
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/message.rb', line 312

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

#update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, from: :unset) ⇒ MessageInstance

Update the MessageInstance

Parameters:

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

    The message body string. You can also send structured data by serializing it into a string. May be updated to empty string or ‘null`, will be set as empty string as a result in this cases.

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

    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 this will always be null for resources returned via LIST GET operations, but will be present for single GET operations.

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

    The ISO8601 time specifying the datetime the Message should be set as being created.

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

    The ISO8601 time specifying the datetime the Message should be set as having been last updated.

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

    Specify the Identity of the User that last updated the Message (if relevant)

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

    The [identity](www.twilio.com/docs/api/chat/guides/identity) of the message’s author.

Returns:



285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/message.rb', line 285

def update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :unset, from: :unset)
  data = Twilio::Values.of({
      'Body' => body,
      'Attributes' => attributes,
      'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
      'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
      'LastUpdatedBy' => last_updated_by,
      'From' => from,
  })

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

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