Class: VoiceML::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/voiceml/models/messages.rb

Overview

A Twilio-compatible Message resource.

VoiceML's outbound SMS today is fire-and-forget through the SDK 2.2 gateway — status pins to "sent" on successful dispatch and "failed" otherwise. There is no in-flight queued/sending/delivered lifecycle.

Two wire shapes deserve a note:

  • num_segments and num_media are strings on the wire (Twilio-compatible), not integers. num_media is always "0" because the gateway has no MMS today.
  • error_code is a nullable integer; error_message, price, price_unit, date_sent, and messaging_service_sid are nullable strings.

Constant Summary collapse

ATTRIBUTES =
%w[
  sid account_sid api_version to from body status num_segments num_media
  direction price price_unit error_code error_message messaging_service_sid
  date_created date_updated date_sent uri subresource_uris
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Message

Returns a new instance of Message.



27
28
29
30
31
32
# File 'lib/voiceml/models/messages.rb', line 27

def initialize(attrs = {})
  ATTRIBUTES.each do |field|
    value = attrs.key?(field) ? attrs[field] : attrs[field.to_sym]
    instance_variable_set("@#{field}", value)
  end
end

Class Method Details

.from_hash(hash) ⇒ Object



34
35
36
37
38
# File 'lib/voiceml/models/messages.rb', line 34

def self.from_hash(hash)
  return nil if hash.nil?

  new(hash)
end