Class: Twilio::REST::Api::V2010::AccountContext::MessageInstance
- Inherits:
-
InstanceResource
- Object
- InstanceResource
- Twilio::REST::Api::V2010::AccountContext::MessageInstance
- Defined in:
- lib/twilio-ruby/rest/api/v2010/account/message.rb
Instance Method Summary collapse
-
#account_sid ⇒ String
The SID of the [Account](www.twilio.com/docs/iam/api/account) associated with the Message resource.
-
#api_version ⇒ String
The API version used to process the Message.
-
#body ⇒ String
The text content of the message.
-
#context ⇒ MessageContext
Generate an instance context for the instance, the context is capable of performing various actions.
-
#date_created ⇒ Time
The [RFC 2822](datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was created.
-
#date_sent ⇒ Time
The [RFC 2822](datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message was sent.
-
#date_updated ⇒ Time
The [RFC 2822](datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was last updated.
-
#delete ⇒ Boolean
Delete the MessageInstance.
- #direction ⇒ Direction
-
#error_code ⇒ String
The [error code](www.twilio.com/docs/api/errors) returned if the Message ‘status` is `failed` or `undelivered`.
-
#error_message ⇒ String
The description of the ‘error_code` if the Message `status` is `failed` or `undelivered`.
-
#feedback ⇒ feedback
Access the feedback.
-
#fetch ⇒ MessageInstance
Fetch the MessageInstance.
-
#from ⇒ String
The sender’s phone number (in [E.164](en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), [Wireless SIM](www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](www.twilio.com/docs/sms/api/short-code), or [channel address](www.twilio.com/docs/messaging/channels) (e.g., ‘whatsapp:+15554449999`).
-
#initialize(version, payload, account_sid: nil, sid: nil) ⇒ MessageInstance
constructor
Initialize the MessageInstance.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#media ⇒ media
Access the media.
-
#messaging_service_sid ⇒ String
The SID of the [Messaging Service](www.twilio.com/docs/messaging/api/service-resource) associated with the Message resource.
-
#num_media ⇒ String
The number of media files associated with the Message resource.
-
#num_segments ⇒ String
The number of segments that make up the complete message.
-
#price ⇒ String
The amount billed for the message in the currency specified by ‘price_unit`.
-
#price_unit ⇒ String
The currency in which ‘price` is measured, in [ISO 4127](www.iso.org/iso/home/standards/currency_codes.htm) format (e.g. `usd`, `eur`, `jpy`).
-
#sid ⇒ String
The unique, Twilio-provided string that identifies the Message resource.
- #status ⇒ Status
-
#subresource_uris ⇒ Hash
A list of related resources identified by their URIs relative to ‘api.twilio.com`.
-
#tags ⇒ Hash
A string containing a JSON map of key value pairs of tags to be recorded as metadata for the message.
-
#to ⇒ String
The recipient’s phone number (in [E.164](en.wikipedia.org/wiki/E.164) format) or [channel address](www.twilio.com/docs/messaging/channels) (e.g. ‘whatsapp:+15552229999`).
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(body: :unset, status: :unset) ⇒ MessageInstance
Update the MessageInstance.
-
#uri ⇒ String
The URI of the Message resource, relative to ‘api.twilio.com`.
Constructor Details
#initialize(version, payload, account_sid: nil, sid: nil) ⇒ MessageInstance
Initialize the MessageInstance
395 396 397 398 399 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 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 395 def initialize(version, payload , account_sid: nil, sid: nil) super(version) # Marshaled Properties @properties = { 'body' => payload['body'], 'num_segments' => payload['num_segments'], 'direction' => payload['direction'], 'from' => payload['from'], 'to' => payload['to'], 'date_updated' => Twilio.deserialize_rfc2822(payload['date_updated']), 'price' => payload['price'], 'error_message' => payload['error_message'], 'uri' => payload['uri'], 'account_sid' => payload['account_sid'], 'num_media' => payload['num_media'], 'status' => payload['status'], 'messaging_service_sid' => payload['messaging_service_sid'], 'sid' => payload['sid'], 'date_sent' => Twilio.deserialize_rfc2822(payload['date_sent']), 'date_created' => Twilio.deserialize_rfc2822(payload['date_created']), 'error_code' => payload['error_code'] == nil ? payload['error_code'] : payload['error_code'].to_i, 'price_unit' => payload['price_unit'], 'api_version' => payload['api_version'], 'subresource_uris' => payload['subresource_uris'], 'tags' => payload['tags'], } # Context @instance_context = nil @params = { 'account_sid' => account_sid ,'sid' => sid || @properties['sid'] , } end |
Instance Method Details
#account_sid ⇒ String
Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) associated with the Message resource.
495 496 497 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 495 def account_sid @properties['account_sid'] end |
#api_version ⇒ String
Returns The API version used to process the Message.
549 550 551 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 549 def api_version @properties['api_version'] end |
#body ⇒ String
Returns The text content of the message.
441 442 443 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 441 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
432 433 434 435 436 437 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 432 def context unless @instance_context @instance_context = MessageContext.new(@version , @params['account_sid'], @params['sid']) end @instance_context end |
#date_created ⇒ Time
Returns The [RFC 2822](datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was created.
531 532 533 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 531 def date_created @properties['date_created'] end |
#date_sent ⇒ Time
Returns The [RFC 2822](datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message was sent. For an outgoing message, this is when Twilio sent the message. For an incoming message, this is when Twilio sent the HTTP request to your incoming message webhook URL.
525 526 527 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 525 def date_sent @properties['date_sent'] end |
#date_updated ⇒ Time
Returns The [RFC 2822](datatracker.ietf.org/doc/html/rfc2822#section-3.3) timestamp (in GMT) of when the Message resource was last updated.
471 472 473 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 471 def date_updated @properties['date_updated'] end |
#delete ⇒ Boolean
Delete the MessageInstance
568 569 570 571 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 568 def delete context.delete end |
#direction ⇒ Direction
453 454 455 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 453 def direction @properties['direction'] end |
#error_code ⇒ String
Returns The [error code](www.twilio.com/docs/api/errors) returned if the Message ‘status` is `failed` or `undelivered`. If no error was encountered, the value is `null`.
537 538 539 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 537 def error_code @properties['error_code'] end |
#error_message ⇒ String
Returns The description of the ‘error_code` if the Message `status` is `failed` or `undelivered`. If no error was encountered, the value is `null`.
483 484 485 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 483 def @properties['error_message'] end |
#feedback ⇒ feedback
Access the feedback
600 601 602 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 600 def feedback context.feedback end |
#fetch ⇒ MessageInstance
Fetch the MessageInstance
576 577 578 579 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 576 def fetch context.fetch end |
#from ⇒ String
Returns The sender’s phone number (in [E.164](en.wikipedia.org/wiki/E.164) format), [alphanumeric sender ID](www.twilio.com/docs/sms/send-messages#use-an-alphanumeric-sender-id), [Wireless SIM](www.twilio.com/docs/iot/wireless/programmable-wireless-send-machine-machine-sms-commands), [short code](www.twilio.com/docs/sms/api/short-code), or [channel address](www.twilio.com/docs/messaging/channels) (e.g., ‘whatsapp:+15554449999`). For incoming messages, this is the number or channel address of the sender. For outgoing messages, this value is a Twilio phone number, alphanumeric sender ID, short code, or channel address from which the message is sent.
459 460 461 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 459 def from @properties['from'] end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
620 621 622 623 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 620 def inspect values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ") "<Twilio.Api.V2010.MessageInstance #{values}>" end |
#media ⇒ media
Access the media
607 608 609 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 607 def media context.media end |
#messaging_service_sid ⇒ String
Returns The SID of the [Messaging Service](www.twilio.com/docs/messaging/api/service-resource) associated with the Message resource. The value is ‘null` if a Messaging Service was not used.
513 514 515 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 513 def messaging_service_sid @properties['messaging_service_sid'] end |
#num_media ⇒ String
Returns The number of media files associated with the Message resource.
501 502 503 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 501 def num_media @properties['num_media'] end |
#num_segments ⇒ String
Returns The number of segments that make up the complete message. SMS message bodies that exceed the [character limit](www.twilio.com/docs/glossary/what-sms-character-limit) are segmented and charged as multiple messages. Note: For messages sent via a Messaging Service, ‘num_segments` is initially `0`, since a sender hasn’t yet been assigned.
447 448 449 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 447 def num_segments @properties['num_segments'] end |
#price ⇒ String
Returns The amount billed for the message in the currency specified by ‘price_unit`. The `price` is populated after the message has been sent/received, and may not be immediately availalble. View the [Pricing page](www.twilio.com/en-us/pricing) for more details.
477 478 479 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 477 def price @properties['price'] end |
#price_unit ⇒ String
Returns The currency in which ‘price` is measured, in [ISO 4127](www.iso.org/iso/home/standards/currency_codes.htm) format (e.g. `usd`, `eur`, `jpy`).
543 544 545 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 543 def price_unit @properties['price_unit'] end |
#sid ⇒ String
Returns The unique, Twilio-provided string that identifies the Message resource.
519 520 521 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 519 def sid @properties['sid'] end |
#status ⇒ Status
507 508 509 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 507 def status @properties['status'] end |
#subresource_uris ⇒ Hash
Returns A list of related resources identified by their URIs relative to ‘api.twilio.com`.
555 556 557 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 555 def subresource_uris @properties['subresource_uris'] end |
#tags ⇒ Hash
Returns A string containing a JSON map of key value pairs of tags to be recorded as metadata for the message.
561 562 563 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 561 def @properties['tags'] end |
#to ⇒ String
Returns The recipient’s phone number (in [E.164](en.wikipedia.org/wiki/E.164) format) or [channel address](www.twilio.com/docs/messaging/channels) (e.g. ‘whatsapp:+15552229999`).
465 466 467 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 465 def to @properties['to'] end |
#to_s ⇒ Object
Provide a user friendly representation
613 614 615 616 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 613 def to_s values = @params.map{|k, v| "#{k}: #{v}"}.join(" ") "<Twilio.Api.V2010.MessageInstance #{values}>" end |
#update(body: :unset, status: :unset) ⇒ MessageInstance
Update the MessageInstance
586 587 588 589 590 591 592 593 594 595 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 586 def update( body: :unset, status: :unset ) context.update( body: body, status: status, ) end |
#uri ⇒ String
Returns The URI of the Message resource, relative to ‘api.twilio.com`.
489 490 491 |
# File 'lib/twilio-ruby/rest/api/v2010/account/message.rb', line 489 def uri @properties['uri'] end |