Class: Twilio::REST::Messaging::V1::SessionContext::MessageInstance
- Inherits:
-
InstanceResource
- Object
- InstanceResource
- Twilio::REST::Messaging::V1::SessionContext::MessageInstance
- 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
-
#account_sid ⇒ String
The unique id of the Account responsible for this message.
-
#attributes ⇒ String
A string metadata field you can use to store any data you wish.
-
#author ⇒ String
The identity or the address of the device of the message’s author.
-
#body ⇒ String
The contents of the message.
-
#context ⇒ MessageContext
Generate an instance context for the instance, the context is capable of performing various actions.
-
#date_created ⇒ Time
The date that this resource was created.
-
#date_updated ⇒ Time
The date that this resource was last updated.
-
#delete ⇒ Boolean
Deletes the MessageInstance.
-
#fetch ⇒ MessageInstance
Fetch a MessageInstance.
-
#index ⇒ String
The index of the message within the Session.
-
#initialize(version, payload, session_sid: nil, sid: nil) ⇒ MessageInstance
constructor
Initialize the MessageInstance.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#messaging_service_sid ⇒ String
The unique id of the SMS Service this message belongs to.
-
#service_sid ⇒ String
The unique id of the Chat Service this message belongs to.
-
#session_sid ⇒ String
The unique id of the Session for this message.
-
#sid ⇒ String
A 34 character string that uniquely identifies this resource.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(author: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, body: :unset) ⇒ MessageInstance
Update the MessageInstance.
-
#url ⇒ String
An absolute URL for this message.
Constructor Details
#initialize(version, payload, session_sid: nil, sid: nil) ⇒ MessageInstance
Initialize the MessageInstance
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 280 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_sid ⇒ String
Returns The unique id of the Account responsible for this message.
317 318 319 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 317 def account_sid @properties['account_sid'] end |
#attributes ⇒ String
Returns A string metadata field you can use to store any data you wish.
365 366 367 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 365 def attributes @properties['attributes'] end |
#author ⇒ String
Returns The identity or the address of the device of the message’s author.
353 354 355 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 353 def @properties['author'] end |
#body ⇒ String
Returns The contents of the message.
359 360 361 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 359 def body @properties['body'] end |
#context ⇒ MessageContext
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context
308 309 310 311 312 313 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 308 def context unless @instance_context @instance_context = MessageContext.new(@version, @params['session_sid'], @params['sid'], ) end @instance_context end |
#date_created ⇒ Time
Returns The date that this resource was created.
371 372 373 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 371 def date_created @properties['date_created'] end |
#date_updated ⇒ Time
Returns The date that this resource was last updated.
377 378 379 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 377 def date_updated @properties['date_updated'] end |
#delete ⇒ Boolean
Deletes the MessageInstance
419 420 421 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 419 def delete context.delete end |
#fetch ⇒ MessageInstance
Fetch a MessageInstance
390 391 392 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 390 def fetch context.fetch end |
#index ⇒ String
Returns The index of the message within the Session.
347 348 349 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 347 def index @properties['index'] end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
432 433 434 435 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 432 def inspect values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") "<Twilio.Messaging.V1.MessageInstance #{values}>" end |
#messaging_service_sid ⇒ String
Returns The unique id of the SMS Service this message belongs to.
329 330 331 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 329 def messaging_service_sid @properties['messaging_service_sid'] end |
#service_sid ⇒ String
Returns The unique id of the Chat Service this message belongs to.
323 324 325 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 323 def service_sid @properties['service_sid'] end |
#session_sid ⇒ String
Returns The unique id of the Session for this message.
335 336 337 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 335 def session_sid @properties['session_sid'] end |
#sid ⇒ String
Returns A 34 character string that uniquely identifies this resource.
341 342 343 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 341 def sid @properties['sid'] end |
#to_s ⇒ Object
Provide a user friendly representation
425 426 427 428 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 425 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
406 407 408 409 410 411 412 413 414 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 406 def update(author: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, body: :unset) context.update( author: , attributes: attributes, date_created: date_created, date_updated: date_updated, body: body, ) end |
#url ⇒ String
Returns An absolute URL for this message.
383 384 385 |
# File 'lib/twilio-ruby/rest/messaging/v1/session/message.rb', line 383 def url @properties['url'] end |