Skip to content

Commit a520ba9

Browse files
authored
Merge pull request #58 from Bandwidth/DX-2701
DX-2701 Add `<StartStream>` and `<StopStream>` BXML Verbs
2 parents b91c19d + facf2d8 commit a520ba9

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require_relative 'xml_verb'
2+
3+
module Bandwidth
4+
module Voice
5+
# The StartStream verb allows a segment of a call to be sent off to another destination for additional processing
6+
class StartStream
7+
include XmlVerb
8+
9+
def to_bxml(xml)
10+
xml.StartStream(compact_hash({
11+
'destination' => destination,
12+
'name' => name,
13+
'tracks' => tracks,
14+
'streamEventUrl' => streamEventUrl,
15+
'streamEventMethod' => streamEventMethod,
16+
'username' => username,
17+
'password' => password
18+
}))
19+
end
20+
end
21+
end
22+
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require_relative 'xml_verb'
2+
3+
module Bandwidth
4+
module Voice
5+
# The StopStream verb is used to stop a stream that was started with a previous `<StartStream>` verb
6+
class StopStream
7+
include XmlVerb
8+
9+
def to_bxml(xml)
10+
xml.StopStream(compact_hash({
11+
'name' => name
12+
}))
13+
end
14+
end
15+
end
16+
end

test/integration/test_integration.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,4 +688,34 @@ def test_webrtc_generate_transfer_bxml_verb
688688
actual = Bandwidth::WebRtc.generate_transfer_bxml_verb('asdf', 'c-93d6f3c0-be584596-0b74-4fa2-8015-d8ede84bd1a4')
689689
assert_equal(expected, actual)
690690
end
691+
692+
def test_start_stream_bxml_verb
693+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StartStream destination="https://www.test.com/stream" name="test_stream" tracks="inbound" streamEventUrl="https://www.test.com/event" streamEventMethod="POST" username="username" password="password"/></Response>'
694+
response = Bandwidth::Voice::Response.new()
695+
start_stream = Bandwidth::Voice::StartStream.new({
696+
:destination => "https://www.test.com/stream",
697+
:name => "test_stream",
698+
:tracks => "inbound",
699+
:streamEventUrl => "https://www.test.com/event",
700+
:streamEventMethod => "POST",
701+
:username => "username",
702+
:password => "password"
703+
})
704+
response.push(start_stream)
705+
actual = response.to_bxml()
706+
707+
assert_equal(expected, actual)
708+
end
709+
710+
def test_stop_stream_bxml_verb
711+
expected = '<?xml version="1.0" encoding="UTF-8"?><Response><StopStream name="test_stream"/></Response>'
712+
response = Bandwidth::Voice::Response.new()
713+
stop_stream = Bandwidth::Voice::StopStream.new({
714+
:name => "test_stream"
715+
})
716+
response.push(stop_stream)
717+
actual = response.to_bxml()
718+
719+
assert_equal(expected, actual)
720+
end
691721
end

0 commit comments

Comments
 (0)