class Plivo::XML::Stream

Constants

SUPPORTED_AUDIOTRACK
SUPPORTED_BIDIRECTIONAL
SUPPORTED_CALLBACKMETHOD
SUPPORTED_KEEPCALLALIVE

Public Class Methods

new(body, attributes = {}) click to toggle source
Calls superclass method Plivo::XML::Element::new
# File lib/plivo/xml/stream.rb, line 13
def initialize(body, attributes = {})
  if attributes[:bidirectional] && !SUPPORTED_BIDIRECTIONAL.include?(attributes[:bidirectional])
    raise PlivoXMLError, "<Stream> bidirectional #{attributes[:bidirectional]} is not valid."
  end
  if attributes[:audioTrack] && !SUPPORTED_AUDIOTRACK.include?(attributes[:audioTrack])
    raise PlivoXMLError, "<Stream> audioTrack #{attributes[:audioTrack]} is not valid."
  end
  if attributes[:statusCallbackMethod] && !SUPPORTED_CALLBACKMETHOD.include?(attributes[:statusCallbackMethod].upcase)
    raise PlivoXMLError, "<Stream> statusCallbackMethod #{attributes[:statusCallbackMethod]} is not valid."
  end
  if attributes[:keepCallAlive] && !SUPPORTED_KEEPCALLALIVE.include?(attributes[:keepCallAlive])
    raise PlivoXMLError, "<Stream> keepCallAlive #{attributes[:keepCallAlive]} is not valid."
  end
  raise PlivoXMLError, 'No text set for Stream' unless body
  super(body, attributes)
end