Class: VoiceML::Media

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

Overview

Twilio-compatible MMS Media item. VoiceML's outbound SMS gateway is text-only today (no MMS), so this model exists primarily for response- shape conformance and to round-trip migrated tooling. parent_sid ties the media back to its parent Message (SM... sid).

Constant Summary collapse

ATTRIBUTES =
%w[
  sid account_sid parent_sid content_type
  date_created date_updated uri
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Media

Returns a new instance of Media.



18
19
20
21
22
23
# File 'lib/voiceml/models/media.rb', line 18

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



25
26
27
28
29
# File 'lib/voiceml/models/media.rb', line 25

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

  new(hash)
end