Sha256: e76e8bb092639e16dc92e270f6ea65993f1438305b3cd7d58a4d852d9867c3f2

Contents?: true

Size: 1.19 KB

Versions: 17

Compression:

Stored size: 1.19 KB

Contents

module Plivo
  module XML
    class Stream < Element
      @nestables = []
      @valid_attributes = %w[bidirectional audioTrack streamTimeout statusCallbackUrl
                             statusCallbackMethod contentType extraHeaders]

      SUPPORTED_BIDIRECTIONAL=%w(true false)
      SUPPORTED_AUDIOTRACK=%w(inbound outbound both)
      SUPPORTED_CALLBACKMETHOD=%w(GET POST)

      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
        raise PlivoXMLError, 'No text set for Stream' unless body
        super(body, attributes)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
plivo-4.60.0 lib/plivo/xml/stream.rb
plivo-4.59.1 lib/plivo/xml/stream.rb
plivo-4.59.0 lib/plivo/xml/stream.rb
plivo-4.56.0 lib/plivo/xml/stream.rb
plivo-4.55.2 lib/plivo/xml/stream.rb
plivo-4.55.1 lib/plivo/xml/stream.rb
plivo-4.55.0 lib/plivo/xml/stream.rb
plivo-4.54.0 lib/plivo/xml/stream.rb
plivo-4.53.1 lib/plivo/xml/stream.rb
plivo-4.53.0 lib/plivo/xml/stream.rb
plivo-4.52.0 lib/plivo/xml/stream.rb
plivo-4.51.0 lib/plivo/xml/stream.rb
plivo-4.50.0 lib/plivo/xml/stream.rb
plivo-4.49.0 lib/plivo/xml/stream.rb
plivo-4.48.0 lib/plivo/xml/stream.rb
plivo-4.47.0 lib/plivo/xml/stream.rb
plivo-4.46.0 lib/plivo/xml/stream.rb