diff --git a/Bandwidth.Standard/Voice/Bxml/StartStream.cs b/Bandwidth.Standard/Voice/Bxml/StartStream.cs new file mode 100644 index 00000000..88113fa0 --- /dev/null +++ b/Bandwidth.Standard/Voice/Bxml/StartStream.cs @@ -0,0 +1,88 @@ +using System; +using System.Xml; +using System.Xml.Schema; +using System.Xml.Serialization; + +namespace Bandwidth.Standard.Voice.Bxml +{ + /// + /// The StartStream verb allows a segment of a call to be sent off to another destination for additional processing. + /// + /// + public class StartStream : IXmlSerializable, IVerb, IAudioProducer + { + /// + /// A websocket URI to send the stream to + /// + public string Destination { get; set; } + + /// + /// A name to refer to this stream by + /// + public string Name { get; set; } + + /// + /// The part of the call to send a stream from. `inbound`, `outbound` or `both`. + /// + public string Tracks { get; set; } + + /// + /// URL to send the associated Webhook events to during this stream's lifetime + /// + public string StreamEventUrl { get; set; } + + /// + /// The HTTP method to use for the request to `streamEventUrl` + /// + public string StreamEventMethod { get; set; } + + /// + /// The username to send in the HTTP request to `streamEventUrl` + /// + public string Username { get; set; } + + /// + /// The password to send in the HTTP request to `streamEventUrl` + /// + public string Password { get; set; } + + XmlSchema IXmlSerializable.GetSchema() + { + return null; + } + + void IXmlSerializable.ReadXml(XmlReader reader) + { + throw new NotImplementedException(); + } + + void IXmlSerializable.WriteXml(XmlWriter writer) + { + writer.WriteAttributeString("destination", Destination); + if (!string.IsNullOrEmpty(Name)) + { + writer.WriteAttributeString("name", Name); + } + if (!string.IsNullOrEmpty(Tracks)) + { + writer.WriteAttributeString("tracks", Tracks); + } + if (!string.IsNullOrEmpty(StreamEventUrl)) + { + writer.WriteAttributeString("streamEventUrl", StreamEventUrl); + } + if (!string.IsNullOrEmpty(StreamEventMethod)) + { + writer.WriteAttributeString("streamEventMethod", StreamEventMethod); + } + if (!string.IsNullOrEmpty(Username)) + { + writer.WriteAttributeString("username", Username); + } + if (!string.IsNullOrEmpty(Password)) + { + writer.WriteAttributeString("password", Password); + } + } + } +} diff --git a/Bandwidth.Standard/Voice/Bxml/StopStream.cs b/Bandwidth.Standard/Voice/Bxml/StopStream.cs new file mode 100644 index 00000000..af8bb0fa --- /dev/null +++ b/Bandwidth.Standard/Voice/Bxml/StopStream.cs @@ -0,0 +1,34 @@ +using System; +using System.Xml; +using System.Xml.Schema; +using System.Xml.Serialization; + +namespace Bandwidth.Standard.Voice.Bxml +{ + /// + /// The StopStream verb is used to stop a stream that was started with a previous `` verb. + /// + /// + public class StopStream : IXmlSerializable, IVerb, IAudioProducer + { + /// + /// The name of the stream to stop + /// + public string Name { get; set; } + + XmlSchema IXmlSerializable.GetSchema() + { + return null; + } + + void IXmlSerializable.ReadXml(XmlReader reader) + { + throw new NotImplementedException(); + } + + void IXmlSerializable.WriteXml(XmlWriter writer) + { + writer.WriteAttributeString("name", Name); + } + } +} diff --git a/Bandwidth.StandardTests/Voice/Bxml/StreamTests.cs b/Bandwidth.StandardTests/Voice/Bxml/StreamTests.cs new file mode 100644 index 00000000..fa910764 --- /dev/null +++ b/Bandwidth.StandardTests/Voice/Bxml/StreamTests.cs @@ -0,0 +1,41 @@ +using Bandwidth.Standard.Voice.Bxml; +using Xunit; + +namespace Bandwidth.StandardTests.Voice.Bxml +{ + public class StreamTests + { + + [Fact] + public void StartStreamBxmlVerbTest() + { + var expected = " "; + var startStream = new StartStream(); + startStream.Destination = "https://www.test.com/stream"; + startStream.Name = "test_stream"; + startStream.Tracks = "inbound"; + startStream.StreamEventUrl = "https://www.test.com/event"; + startStream.StreamEventMethod = "POST"; + startStream.Username = "username"; + startStream.Password = "password"; + + var response = new Response(startStream); + var actual = response.ToBXML(); + + Assert.Equal(expected, actual); + } + + [Fact] + public void StopStreamBxmlVerbTest() + { + var expected = " "; + var stopStream = new StopStream(); + stopStream.Name = "test_stream"; + + var response = new Response(stopStream); + var actual = response.ToBXML(); + + Assert.Equal(expected, actual); + } + } +}