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 SID of the [Account](www.twilio.com/docs/api/rest/account) that sent the message that created the resource.

  • sid (String) (defaults to: nil)

    The Twilio-provided string that uniquely identifies the Message resource to fetch.



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 400

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'] == nil ? payload['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'],
      '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 SID of the Account that created the resource.

Returns:

  • (String)

    The SID of the Account that created the resource



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

def 
  @properties['account_sid']
end

#api_versionString

Returns The API version used to process the message.

Returns:

  • (String)

    The API version used to process the message



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

def api_version
  @properties['api_version']
end

#bodyString

Returns The message text.

Returns:

  • (String)

    The message text



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

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:



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

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

#date_createdTime

Returns The RFC 2822 date and time in GMT that the resource was created.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT that the resource was created



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

def date_created
  @properties['date_created']
end

#date_sentTime

Returns The RFC 2822 date and time in GMT when the message was sent.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT when the message was sent



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

def date_sent
  @properties['date_sent']
end

#date_updatedTime

Returns The RFC 2822 date and time in GMT that the resource was last updated.

Returns:

  • (Time)

    The RFC 2822 date and time in GMT that the resource was last updated



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

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the MessageInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



566
567
568
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 566

def delete
  context.delete
end

#directionmessage.Direction

Returns The direction of the message.

Returns:

  • (message.Direction)

    The direction of the message



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

def direction
  @properties['direction']
end

#error_codeString

Returns The error code associated with the message.

Returns:

  • (String)

    The error code associated with the message



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

def error_code
  @properties['error_code']
end

#error_messageString

Returns The description of the error_code.

Returns:

  • (String)

    The description of the error_code



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

def error_message
  @properties['error_message']
end

#feedbackfeedback

Access the feedback

Returns:



596
597
598
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 596

def feedback
  context.feedback
end

#fetchMessageInstance

Fetch a MessageInstance

Returns:



573
574
575
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 573

def fetch
  context.fetch
end

#fromString

Returns The phone number that initiated the message.

Returns:

  • (String)

    The phone number that initiated the message



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

def from
  @properties['from']
end

#inspectObject

Provide a detailed, user friendly representation



609
610
611
612
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 609

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

#mediamedia

Access the media

Returns:



589
590
591
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 589

def media
  context.media
end

#messaging_service_sidString

Returns The SID of the Messaging Service used with the message.

Returns:

  • (String)

    The SID of the Messaging Service used with the message.



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

def messaging_service_sid
  @properties['messaging_service_sid']
end

#num_mediaString

Returns The number of media files associated with the message.

Returns:

  • (String)

    The number of media files associated with the message



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

def num_media
  @properties['num_media']
end

#num_segmentsString

Returns The number of messages used to deliver the message body.

Returns:

  • (String)

    The number of messages used to deliver the message body



517
518
519
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 517

def num_segments
  @properties['num_segments']
end

#priceString

Returns The amount billed for the message.

Returns:

  • (String)

    The amount billed for the message



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

def price
  @properties['price']
end

#price_unitString

Returns The currency in which price is measured.

Returns:

  • (String)

    The currency in which price is measured



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

def price_unit
  @properties['price_unit']
end

#sidString

Returns The unique string that identifies the resource.

Returns:

  • (String)

    The unique string that identifies the resource



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

def sid
  @properties['sid']
end

#statusmessage.Status

Returns The status of the message.

Returns:

  • (message.Status)

    The status of the message



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

def status
  @properties['status']
end

#subresource_urisString

Returns A list of related resources identified by their relative URIs.

Returns:

  • (String)

    A list of related resources identified by their relative URIs



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

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



553
554
555
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 553

def to
  @properties['to']
end

#to_sObject

Provide a user friendly representation



602
603
604
605
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 602

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 text of the message you want to send. Can be up to 1,600 characters long.

Returns:



582
583
584
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 582

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

#uriString

Returns The URI of the resource, relative to ‘api.twilio.com`.

Returns:

  • (String)

    The URI of the resource, relative to ‘api.twilio.com`



559
560
561
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 559

def uri
  @properties['uri']
end