Class: Twilio::REST::Api::V2010::AccountContext::MessageInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/api/v2010/account/message.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, account_sid: nil, sid: nil) ⇒ MessageInstance

Initialize the MessageInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String) (defaults to: nil)

    The unique id of the Account that sent this message.

  • sid (String) (defaults to: nil)

    The message Sid that uniquely identifies this resource



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 340

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

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'api_version' => payload['api_version'],
      'body' => payload['body'],
      'date_created' => Twilio.deserialize_rfc2822(payload['date_created']),
      'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']),
      'date_sent' => Twilio.deserialize_rfc2822(payload['date_sent']),
      'direction' => payload['direction'],
      'error_code' => payload['error_code'].to_i,
      'error_message' => payload['error_message'],
      'from' => payload['from'],
      'messaging_service_sid' => payload['messaging_service_sid'],
      'num_media' => payload['num_media'],
      'num_segments' => payload['num_segments'],
      'price' => payload['price'].to_f,
      'price_unit' => payload['price_unit'],
      'sid' => payload['sid'],
      'status' => payload['status'],
      'subresource_uris' => payload['subresource_uris'],
      'to' => payload['to'],
      'uri' => payload['uri'],
  }

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

Instance Method Details

#account_sidString

Returns The unique sid that identifies this account.

Returns:

  • (String)

    The unique sid that identifies this account



385
386
387
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 385

def 
  @properties['account_sid']
end

#api_versionString

Returns The version of the Twilio API used to process the message.

Returns:

  • (String)

    The version of the Twilio API used to process the message.



391
392
393
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 391

def api_version
  @properties['api_version']
end

#bodyString

Returns The text body of the message. Up to 1600 characters long.

Returns:

  • (String)

    The text body of the message. Up to 1600 characters long.



397
398
399
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 397

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:



376
377
378
379
380
381
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 376

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

#date_createdTime

Returns The date this resource was created.

Returns:

  • (Time)

    The date this resource was created



403
404
405
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 403

def date_created
  @properties['date_created']
end

#date_sentTime

Returns The date the message was sent.

Returns:

  • (Time)

    The date the message was sent



415
416
417
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 415

def date_sent
  @properties['date_sent']
end

#date_updatedTime

Returns The date this resource was last updated.

Returns:

  • (Time)

    The date this resource was last updated



409
410
411
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 409

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the MessageInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



506
507
508
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 506

def delete
  context.delete
end

#directionmessage.Direction

Returns The direction of the message.

Returns:

  • (message.Direction)

    The direction of the message



421
422
423
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 421

def direction
  @properties['direction']
end

#error_codeString

Returns The error code associated with the message.

Returns:

  • (String)

    The error code associated with the message



427
428
429
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 427

def error_code
  @properties['error_code']
end

#error_messageString

Returns Human readable description of the ErrorCode.

Returns:

  • (String)

    Human readable description of the ErrorCode



433
434
435
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 433

def error_message
  @properties['error_message']
end

#feedbackfeedback

Access the feedback

Returns:



535
536
537
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 535

def feedback
  context.feedback
end

#fetchMessageInstance

Fetch a MessageInstance

Returns:



513
514
515
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 513

def fetch
  context.fetch
end

#fromString

Returns The phone number that initiated the message.

Returns:

  • (String)

    The phone number that initiated the message



439
440
441
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 439

def from
  @properties['from']
end

#inspectObject

Provide a detailed, user friendly representation



548
549
550
551
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 548

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

#mediamedia

Access the media

Returns:



528
529
530
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 528

def media
  context.media
end

#messaging_service_sidString

Returns The messaging_service_sid.

Returns:

  • (String)

    The messaging_service_sid



445
446
447
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 445

def messaging_service_sid
  @properties['messaging_service_sid']
end

#num_mediaString

Returns Number of media files associated with the message.

Returns:

  • (String)

    Number of media files associated with the message



451
452
453
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 451

def num_media
  @properties['num_media']
end

#num_segmentsString

Returns Indicates number of messages used to delivery the body.

Returns:

  • (String)

    Indicates number of messages used to delivery the body



457
458
459
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 457

def num_segments
  @properties['num_segments']
end

#priceString

Returns The amount billed for the message.

Returns:

  • (String)

    The amount billed for the message



463
464
465
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 463

def price
  @properties['price']
end

#price_unitString

Returns The currency in which Price is measured.

Returns:

  • (String)

    The currency in which Price is measured



469
470
471
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 469

def price_unit
  @properties['price_unit']
end

#sidString

Returns A string that uniquely identifies this message.

Returns:

  • (String)

    A string that uniquely identifies this message



475
476
477
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 475

def sid
  @properties['sid']
end

#statusmessage.Status

Returns The status of this message.

Returns:

  • (message.Status)

    The status of this message



481
482
483
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 481

def status
  @properties['status']
end

#subresource_urisString

Returns The URI for any subresources.

Returns:

  • (String)

    The URI for any subresources



487
488
489
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 487

def subresource_uris
  @properties['subresource_uris']
end

#toString

Returns The phone number that received the message.

Returns:

  • (String)

    The phone number that received the message



493
494
495
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 493

def to
  @properties['to']
end

#to_sObject

Provide a user friendly representation



541
542
543
544
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 541

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

#update(body: nil) ⇒ MessageInstance

Update the MessageInstance

Parameters:

  • body (String) (defaults to: nil)

    The body

Returns:



521
522
523
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 521

def update(body: nil)
  context.update(body: body)
end

#uriString

Returns The URI for this resource.

Returns:

  • (String)

    The URI for this resource



499
500
501
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 499

def uri
  @properties['uri']
end