Class: Twilio::REST::Messaging::V1::SessionContext::MessageInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/messaging/v1/session/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, payload, session_sid: nil, sid: nil) ⇒ MessageInstance

Initialize the MessageInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • session_sid (String) (defaults to: nil)

    The SID of the Session for the message.

  • sid (String) (defaults to: nil)

    The SID of the SessionMessage resource to fetch.



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

def initialize(version, payload, session_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'service_sid' => payload['service_sid'],
      'messaging_service_sid' => payload['messaging_service_sid'],
      'session_sid' => payload['session_sid'],
      'sid' => payload['sid'],
      'index' => payload['index'].to_i,
      'author' => payload['author'],
      'body' => payload['body'],
      'attributes' => payload['attributes'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'url' => payload['url'],
  }

  # Context
  @instance_context = nil
  @params = {'session_sid' => session_sid, 'sid' => sid || @properties['sid'], }
end

Instance Method Details

#account_sidString

Returns The SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



314
315
316
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 314

def 
  @properties['account_sid']
end

#attributesString

Returns The JSON string that stores application-specific data.

Returns:

  • (String)

    The JSON string that stores application-specific data



362
363
364
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 362

def attributes
  @properties['attributes']
end

#authorString

Returns The identity or the address of the device of the message’s author.

Returns:

  • (String)

    The identity or the address of the device of the message’s author



350
351
352
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 350

def author
  @properties['author']
end

#bodyString

Returns The message body.

Returns:

  • (String)

    The message body



356
357
358
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 356

def body
  @properties['body']
end

#contextMessageContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



305
306
307
308
309
310
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 305

def context
  unless @instance_context
    @instance_context = MessageContext.new(@version, @params['session_sid'], @params['sid'], )
  end
  @instance_context
end

#date_createdTime

Returns The ISO 8601 date and time in GMT when the resource was created.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was created



368
369
370
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 368

def date_created
  @properties['date_created']
end

#date_updatedTime

Returns The ISO 8601 date and time in GMT when the resource was last updated.

Returns:

  • (Time)

    The ISO 8601 date and time in GMT when the resource was last updated



374
375
376
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 374

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the MessageInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



417
418
419
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 417

def delete
  context.delete
end

#fetchMessageInstance

Fetch a MessageInstance

Returns:



387
388
389
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 387

def fetch
  context.fetch
end

#indexString

Returns The index of the message within the Session.

Returns:

  • (String)

    The index of the message within the Session



344
345
346
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 344

def index
  @properties['index']
end

#inspectObject

Provide a detailed, user friendly representation



430
431
432
433
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 430

def inspect
  values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Messaging.V1.MessageInstance #{values}>"
end

#messaging_service_sidString

Returns The SID of the Messaging Service the message belongs to.

Returns:

  • (String)

    The SID of the Messaging Service the message belongs to



326
327
328
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 326

def messaging_service_sid
  @properties['messaging_service_sid']
end

#service_sidString

Returns The SID of the Service that the resource is associated with.

Returns:

  • (String)

    The SID of the Service that the resource is associated with



320
321
322
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 320

def service_sid
  @properties['service_sid']
end

#session_sidString

Returns The SID of the Session for the message.

Returns:

  • (String)

    The SID of the Session for the message



332
333
334
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 332

def session_sid
  @properties['session_sid']
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



338
339
340
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 338

def sid
  @properties['sid']
end

#to_sObject

Provide a user friendly representation



423
424
425
426
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 423

def to_s
  values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
  "<Twilio.Messaging.V1.MessageInstance #{values}>"
end

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

Update the MessageInstance

Parameters:

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

    The [identity](www.twilio.com/docs/chat/identity) of the message’s author. Defaults to system.

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

    A JSON string that stores application-specific data.

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

    The date, specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was created.

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

    The date, specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated.

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

    The message body.

Returns:



404
405
406
407
408
409
410
411
412
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 404

def update(author: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, body: :unset)
  context.update(
      author: author,
      attributes: attributes,
      date_created: date_created,
      date_updated: date_updated,
      body: body,
  )
end

#urlString

Returns The absolute URL of the message.

Returns:

  • (String)

    The absolute URL of the message



380
381
382
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 380

def url
  @properties['url']
end