Skip to content

Commit

Permalink
Merge pull request #67 from Bandwidth/SWI-2790
Browse files Browse the repository at this point in the history
SWI-2790 Add `StartTranscription` and `StopTranscription`
  • Loading branch information
ajrice6713 authored Jun 13, 2023
2 parents 76fd4f5 + 5659990 commit 0ee5917
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Bandwidth.Standard/Voice/Bxml/CustomParam.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Xml.Serialization;

namespace Bandwidth.Standard.Voice.Bxml
{
public class CustomParam : IVerb
{
public CustomParam()
{
}

[XmlAttribute("name")]
public string Name { get; set; }

[XmlAttribute("value")]
public string Value { get; set; }

}
}
41 changes: 41 additions & 0 deletions Bandwidth.Standard/Voice/Bxml/StartTranscription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections.Generic;
using System.Xml.Serialization;

namespace Bandwidth.Standard.Voice.Bxml
{
public class StartTranscription : IVerb
{
public StartTranscription()
{
Stabilized = true;
}

[XmlAttribute("name")]
public string Name { get; set; }

[XmlAttribute("tracks")]
public string Tracks { get; set; }

[XmlAttribute("transcriptionEventUrl")]
public string TranscriptionEventUrl { get; set; }

[XmlAttribute("transcriptionEventMethod")]
public string TranscriptionEventMethod { get; set; }

[XmlAttribute("username")]
public string Username { get; set; }

[XmlAttribute("password")]
public string Password { get; set; }

[XmlAttribute("destination")]
public string Destination { get; set; }

[XmlAttribute("stabilized")]
public bool Stabilized { get; set; }

[XmlElement("CustomParam")]
public List<CustomParam> CustomParams { get; set; }

}
}
15 changes: 15 additions & 0 deletions Bandwidth.Standard/Voice/Bxml/StopTranscription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Xml.Serialization;

namespace Bandwidth.Standard.Voice.Bxml
{
public class StopTranscription : IVerb
{
public StopTranscription()
{
}

[XmlAttribute("name")]
public string Name { get; set; }

}
}
51 changes: 51 additions & 0 deletions Bandwidth.StandardTests/Voice/Bxml/StartStopTranscriptionTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using Bandwidth.Standard.Voice.Bxml;
using Xunit;

namespace Bandwidth.StandardTests.Voice.Bxml
{
public class StartStopTranscriptionTests
{

[Fact]
public void StartTranscriptionBxmlVerbTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <StartTranscription name=\"test_transcription\" stabilized=\"true\"> <CustomParam name=\"name1\" value=\"value1\" /> <CustomParam name=\"name2\" value=\"value2\" /> </StartTranscription></Response>";

var customParam1 = new CustomParam();
customParam1.Name = "name1";
customParam1.Value = "value1";

var customParam2 = new CustomParam();
customParam2.Name = "name2";
customParam2.Value = "value2";

var startTranscription = new StartTranscription();
startTranscription.Name = "test_transcription";
startTranscription.CustomParams = new List<CustomParam>()
{
customParam1,
customParam2
};

var response = new Response(startTranscription);
var actual = response.ToBXML();

Assert.Equal(expected, actual.Replace("\n", "").Replace("\r", ""));
}

[Fact]
public void StopTranscriptionmBxmlVerbTest()
{
var expected = "<?xml version=\"1.0\" encoding=\"utf-8\"?><Response> <StopTranscription name=\"test_transcription\" /></Response>";
var stopTranscription = new StopTranscription();
stopTranscription.Name = "test_transcription";

var response = new Response(stopTranscription);
var actual = response.ToBXML();

Assert.Equal(expected, actual.Replace("\n", "").Replace("\r", ""));
}
}
}

0 comments on commit 0ee5917

Please sign in to comment.