Skip to content

Commit

Permalink
Merge pull request #66 from Bandwidth/SWI-2564
Browse files Browse the repository at this point in the history
SWI-2564
  • Loading branch information
ajrice6713 authored May 23, 2023
2 parents 9828ac8 + a236a49 commit 76fd4f5
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Bandwidth.Standard/Voice/Bxml/Recording.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ namespace Bandwidth.Standard.Voice.Bxml
public class Record : IVerb
{

/// <summary>
/// (optional) A boolean value. Indicates that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish.
/// </summary>
[XmlAttribute("detectLanguage")]
public bool DetectLanguage { get; set; }

/// <summary>
/// (optional) A boolean value. If true, the recording will be submitted for transcription upon completion. Defaults to false.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions Bandwidth.Standard/Voice/Bxml/StartRecording.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ namespace Bandwidth.Standard.Voice.Bxml
public class StartRecording : IVerb
{

/// <summary>
/// (optional) A boolean value. Indicates that the recording may not be in English, and the transcription service will need to detect the dominant language the recording is in and transcribe accordingly. Current supported languages are English, French, and Spanish.
/// </summary>
[XmlAttribute("detectLanguage")]
public bool DetectLanguage { get; set; }

/// <summary>
/// (optional) A boolean value. If true, the recording will be submitted for transcription upon completion. Defaults to false.
/// </summary>
Expand Down
53 changes: 52 additions & 1 deletion Bandwidth.Standard/Voice/Models/TranscribeRecordingRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ namespace Bandwidth.Standard.Voice.Models
/// </summary>
public class TranscribeRecordingRequest
{
private bool? detectLanguage;
private Models.CallbackMethodEnum? callbackMethod;
private string username;
private string password;
private string tag;
private double? callbackTimeout;
private Dictionary<string, bool> shouldSerialize = new Dictionary<string, bool>
{
{ "detectLanguage", false },
{ "callbackMethod", false },
{ "username", false },
{ "password", false },
Expand All @@ -44,21 +46,30 @@ public TranscribeRecordingRequest()
/// <summary>
/// Initializes a new instance of the <see cref="TranscribeRecordingRequest"/> class.
/// </summary>
/// <param name="detectLanguage">detectLanguage.</param>
/// <param name="callbackUrl">callbackUrl.</param>
/// <param name="callbackMethod">callbackMethod.</param>
/// <param name="username">username.</param>
/// <param name="password">password.</param>
/// <param name="tag">tag.</param>
/// <param name="callbackTimeout">callbackTimeout.</param>
public TranscribeRecordingRequest(
bool? detectLanguage = null,
string callbackUrl = null,
Models.CallbackMethodEnum? callbackMethod = null,
string username = null,
string password = null,
string tag = null,
double? callbackTimeout = null)
{

this.CallbackUrl = callbackUrl;

if (detectLanguage != null)
{
this.DetectLanguage = detectLanguage;
}

if (callbackMethod != null)
{
this.CallbackMethod = callbackMethod;
Expand Down Expand Up @@ -92,6 +103,22 @@ public TranscribeRecordingRequest(
[JsonProperty("callbackUrl", NullValueHandling = NullValueHandling.Ignore)]
public string CallbackUrl { get; set; }

/// <summary>
/// Gets or sets DetectLanguage
/// </summary>
[JsonProperty("detectLanguage")]
public bool? DetectLanguage {
get
{
return this.detectLanguage;
}
set
{
this.shouldSerialize["detectLanguage"] = true;
this.detectLanguage = value;
}
}

/// <summary>
/// Gets or sets CallbackMethod.
/// </summary>
Expand Down Expand Up @@ -192,6 +219,14 @@ public override string ToString()
return $"TranscribeRecordingRequest : ({string.Join(", ", toStringOutput)})";
}

/// <summary>
/// Marks the field to not be serialized.
/// </summary>
public void UnsetDetectLanguage()
{
this.shouldSerialize["detectLanguage"] = false;
}

/// <summary>
/// Marks the field to not be serailized.
/// </summary>
Expand Down Expand Up @@ -232,6 +267,15 @@ public void UnsetCallbackTimeout()
this.shouldSerialize["callbackTimeout"] = false;
}

/// <summary>
/// Checks if the field should be serialized or not.
/// </summary>
/// <returns>A boolean weather the field should be serialized or not.</returns>
public bool ShouldSerializeDetectLanguage()
{
return this.shouldSerialize["detectLanguage"];
}

/// <summary>
/// Checks if the field should be serialized or not.
/// </summary>
Expand Down Expand Up @@ -291,6 +335,7 @@ public override bool Equals(object obj)
}

return obj is TranscribeRecordingRequest other &&
((this.DetectLanguage == null && other.DetectLanguage == null) || (this.DetectLanguage?.Equals(other.DetectLanguage) == true)) &&
((this.CallbackUrl == null && other.CallbackUrl == null) || (this.CallbackUrl?.Equals(other.CallbackUrl) == true)) &&
((this.CallbackMethod == null && other.CallbackMethod == null) || (this.CallbackMethod?.Equals(other.CallbackMethod) == true)) &&
((this.Username == null && other.Username == null) || (this.Username?.Equals(other.Username) == true)) &&
Expand All @@ -304,6 +349,11 @@ public override int GetHashCode()
{
int hashCode = -2127634834;

if(this.detectLanguage != null)
{
hashCode += this.detectLanguage.GetHashCode();
}

if (this.CallbackUrl != null)
{
hashCode += this.CallbackUrl.GetHashCode();
Expand Down Expand Up @@ -343,6 +393,7 @@ public override int GetHashCode()
/// <param name="toStringOutput">List of strings.</param>
protected void ToString(List<string> toStringOutput)
{
toStringOutput.Add($"this.DetectLanguage = {(this.DetectLanguage == null ? "null" : this.DetectLanguage.ToString())}");
toStringOutput.Add($"this.CallbackUrl = {(this.CallbackUrl == null ? "null" : this.CallbackUrl == string.Empty ? "" : this.CallbackUrl)}");
toStringOutput.Add($"this.CallbackMethod = {(this.CallbackMethod == null ? "null" : this.CallbackMethod.ToString())}");
toStringOutput.Add($"this.Username = {(this.Username == null ? "null" : this.Username == string.Empty ? "" : this.Username)}");
Expand All @@ -351,4 +402,4 @@ protected void ToString(List<string> toStringOutput)
toStringOutput.Add($"this.CallbackTimeout = {(this.CallbackTimeout == null ? "null" : this.CallbackTimeout.ToString())}");
}
}
}
}
21 changes: 21 additions & 0 deletions Bandwidth.StandardTests/Voice/Bxml/RecordingTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Bandwidth.Standard.Voice.Bxml;
using Xunit;

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

[Fact]
public void RecordingShouldHaveDetectLanguage()
{
var recording = new Bandwidth.Standard.Voice.Bxml.Record();
recording.DetectLanguage = true;


var bxml = new BXML(recording);

Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-8\"?><Bxml> <Record detectLanguage=\"true\" transcribe=\"false\" /></Bxml>", bxml.ToBXML().Replace("\n", "").Replace("\r", ""));
}
}
}
21 changes: 21 additions & 0 deletions Bandwidth.StandardTests/Voice/Bxml/StartRecordingTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Bandwidth.Standard.Voice.Bxml;
using Xunit;

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

[Fact]
public void RecordingShouldHaveDetectLanguage()
{
var recording = new StartRecording();
recording.DetectLanguage = true;


var bxml = new BXML(recording);

Assert.Equal("<?xml version=\"1.0\" encoding=\"utf-8\"?><Bxml> <StartRecording detectLanguage=\"true\" transcribe=\"false\" multiChannel=\"false\" /></Bxml>", bxml.ToBXML().Replace("\n", "").Replace("\r", ""));
}
}
}
13 changes: 12 additions & 1 deletion Bandwidth.StandardTests/Voice/ModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ public void CheckModifyCallRequestCallStateStatus()
};

Assert.Equal(StateEnum.Active, modifyCallRequest.State);
}
}

[Fact]
public void CheckTranscribeRecordingRequestDetectLanguage()
{
var transcribeCallRequest = new TranscribeRecordingRequest
{
DetectLanguage = true
};

Assert.Equal(true, transcribeCallRequest.DetectLanguage);
}
}
}

0 comments on commit 76fd4f5

Please sign in to comment.