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

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb

Instance Method Summary collapse

Constructor Details

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

Initialize the MessageContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The service_sid

  • channel_sid (String)

    The channel_sid

  • sid (String)

    The sid



226
227
228
229
230
231
232
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb', line 226

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



258
259
260
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb', line 258

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

#fetchMessageInstance

Fetch a MessageInstance

Returns:



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb', line 237

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



304
305
306
307
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb', line 304

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

#update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :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)

Returns:



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb', line 278

def update(body: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, last_updated_by: :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,
  })

  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