diff --git a/Bandwidth.Standard/Voice/Models/MachineDetectionConfiguration.cs b/Bandwidth.Standard/Voice/Models/MachineDetectionConfiguration.cs index ba40c568..6f5566e5 100644 --- a/Bandwidth.Standard/Voice/Models/MachineDetectionConfiguration.cs +++ b/Bandwidth.Standard/Voice/Models/MachineDetectionConfiguration.cs @@ -28,6 +28,7 @@ public class MachineDetectionConfiguration private string password; private string fallbackUsername; private string fallbackPassword; + private double? machineSpeechEndThreshold; private Dictionary shouldSerialize = new Dictionary { { "callbackUrl", false }, @@ -64,6 +65,7 @@ public MachineDetectionConfiguration() /// password. /// fallbackUsername. /// fallbackPassword. + /// machineSpeechEndThreshold. public MachineDetectionConfiguration( Models.ModeEnum? mode = null, double? detectionTimeout = null, @@ -78,7 +80,8 @@ public MachineDetectionConfiguration( string username = null, string password = null, string fallbackUsername = null, - string fallbackPassword = null) + string fallbackPassword = null, + double? machineSpeechEndThreshold = null) { this.Mode = mode; this.DetectionTimeout = detectionTimeout; @@ -126,6 +129,7 @@ public MachineDetectionConfiguration( this.FallbackPassword = fallbackPassword; } + this.MachineSpeechEndThreshold = machineSpeechEndThreshold; } /// @@ -308,6 +312,12 @@ public string FallbackPassword } } + /// + /// When an answering machine is detected, the amount of silence (in seconds) before assuming the message has finished playing. + /// + [JsonProperty("machineSpeechEndThreshold", NullValueHandling = NullValueHandling.Ignore)] + public double? MachineSpeechEndThreshold; + /// public override string ToString() { @@ -319,7 +329,7 @@ public override string ToString() } /// - /// Marks the field to not be serailized. + /// Marks the field to not be serialized. /// public void UnsetCallbackUrl() { @@ -327,7 +337,7 @@ public void UnsetCallbackUrl() } /// - /// Marks the field to not be serailized. + /// Marks the field to not be serialized. /// public void UnsetCallbackMethod() { @@ -335,7 +345,7 @@ public void UnsetCallbackMethod() } /// - /// Marks the field to not be serailized. + /// Marks the field to not be serialized. /// public void UnsetFallbackUrl() { @@ -343,7 +353,7 @@ public void UnsetFallbackUrl() } /// - /// Marks the field to not be serailized. + /// Marks the field to not be serialized. /// public void UnsetFallbackMethod() { @@ -351,7 +361,7 @@ public void UnsetFallbackMethod() } /// - /// Marks the field to not be serailized. + /// Marks the field to not be serialized. /// public void UnsetUsername() { @@ -359,7 +369,7 @@ public void UnsetUsername() } /// - /// Marks the field to not be serailized. + /// Marks the field to not be serialized. /// public void UnsetPassword() { @@ -367,7 +377,7 @@ public void UnsetPassword() } /// - /// Marks the field to not be serailized. + /// Marks the field to not be serialized. /// public void UnsetFallbackUsername() { @@ -375,7 +385,7 @@ public void UnsetFallbackUsername() } /// - /// Marks the field to not be serailized. + /// Marks the field to not be serialized. /// public void UnsetFallbackPassword() { @@ -385,7 +395,7 @@ public void UnsetFallbackPassword() /// /// Checks if the field should be serialized or not. /// - /// A boolean weather the field should be serialized or not. + /// A boolean whether the field should be serialized or not. public bool ShouldSerializeCallbackUrl() { return this.shouldSerialize["callbackUrl"]; @@ -394,7 +404,7 @@ public bool ShouldSerializeCallbackUrl() /// /// Checks if the field should be serialized or not. /// - /// A boolean weather the field should be serialized or not. + /// A boolean whether the field should be serialized or not. public bool ShouldSerializeCallbackMethod() { return this.shouldSerialize["callbackMethod"]; @@ -403,7 +413,7 @@ public bool ShouldSerializeCallbackMethod() /// /// Checks if the field should be serialized or not. /// - /// A boolean weather the field should be serialized or not. + /// A boolean whether the field should be serialized or not. public bool ShouldSerializeFallbackUrl() { return this.shouldSerialize["fallbackUrl"]; @@ -412,7 +422,7 @@ public bool ShouldSerializeFallbackUrl() /// /// Checks if the field should be serialized or not. /// - /// A boolean weather the field should be serialized or not. + /// A boolean whether the field should be serialized or not. public bool ShouldSerializeFallbackMethod() { return this.shouldSerialize["fallbackMethod"]; @@ -421,7 +431,7 @@ public bool ShouldSerializeFallbackMethod() /// /// Checks if the field should be serialized or not. /// - /// A boolean weather the field should be serialized or not. + /// A boolean whether the field should be serialized or not. public bool ShouldSerializeUsername() { return this.shouldSerialize["username"]; @@ -430,7 +440,7 @@ public bool ShouldSerializeUsername() /// /// Checks if the field should be serialized or not. /// - /// A boolean weather the field should be serialized or not. + /// A boolean whether the field should be serialized or not. public bool ShouldSerializePassword() { return this.shouldSerialize["password"]; @@ -439,7 +449,7 @@ public bool ShouldSerializePassword() /// /// Checks if the field should be serialized or not. /// - /// A boolean weather the field should be serialized or not. + /// A boolean whether the field should be serialized or not. public bool ShouldSerializeFallbackUsername() { return this.shouldSerialize["fallbackUsername"]; @@ -448,7 +458,7 @@ public bool ShouldSerializeFallbackUsername() /// /// Checks if the field should be serialized or not. /// - /// A boolean weather the field should be serialized or not. + /// A boolean whether the field should be serialized or not. public bool ShouldSerializeFallbackPassword() { return this.shouldSerialize["fallbackPassword"]; @@ -481,7 +491,8 @@ public override bool Equals(object obj) ((this.Username == null && other.Username == null) || (this.Username?.Equals(other.Username) == true)) && ((this.Password == null && other.Password == null) || (this.Password?.Equals(other.Password) == true)) && ((this.FallbackUsername == null && other.FallbackUsername == null) || (this.FallbackUsername?.Equals(other.FallbackUsername) == true)) && - ((this.FallbackPassword == null && other.FallbackPassword == null) || (this.FallbackPassword?.Equals(other.FallbackPassword) == true)); + ((this.FallbackPassword == null && other.FallbackPassword == null) || (this.FallbackPassword?.Equals(other.FallbackPassword) == true)) && + ((this.MachineSpeechEndThreshold == null && other.MachineSpeechEndThreshold == null) || (this.MachineSpeechEndThreshold?.Equals(other.MachineSpeechEndThreshold) == true)); } /// @@ -559,6 +570,11 @@ public override int GetHashCode() hashCode += this.FallbackPassword.GetHashCode(); } + if (this.MachineSpeechEndThreshold != null) + { + hashCode += this.MachineSpeechEndThreshold.GetHashCode(); + } + return hashCode; } @@ -582,6 +598,7 @@ protected void ToString(List toStringOutput) toStringOutput.Add($"this.Password = {(this.Password == null ? "null" : this.Password == string.Empty ? "" : this.Password)}"); toStringOutput.Add($"this.FallbackUsername = {(this.FallbackUsername == null ? "null" : this.FallbackUsername == string.Empty ? "" : this.FallbackUsername)}"); toStringOutput.Add($"this.FallbackPassword = {(this.FallbackPassword == null ? "null" : this.FallbackPassword == string.Empty ? "" : this.FallbackPassword)}"); + toStringOutput.Add($"this.MachineSpeechEndThreshold = {(this.MachineSpeechEndThreshold == null ? "null" : this.MachineSpeechEndThreshold.ToString())}"); } } } \ No newline at end of file diff --git a/Bandwidth.StandardTests/Voice/ModelTests.cs b/Bandwidth.StandardTests/Voice/ModelTests.cs new file mode 100644 index 00000000..87570d7d --- /dev/null +++ b/Bandwidth.StandardTests/Voice/ModelTests.cs @@ -0,0 +1,99 @@ +using Bandwidth.Standard.Voice.Models; +using Newtonsoft.Json; +using Xunit; + +namespace Bandwidth.StandardTests.Voice +{ + public class ModelTests + { + [Fact] + public void PopulateMachineDetectionConfiguration() + { + var machineDetectionConfiguration = new MachineDetectionConfiguration + { + Mode = ModeEnum.Async, + DetectionTimeout = 3.2, + SilenceTimeout = 5.6, + SpeechThreshold = 1.2, + SpeechEndThreshold = 7.6, + DelayResult = false, + CallbackUrl = "https://www.example.com/", + CallbackMethod = CallbackMethodEnum.GET, + FallbackUrl = "https://www.example-fallback.com/", + FallbackMethod = FallbackMethodEnum.GET, + Username = "neato-username", + Password = "neato-password", + FallbackUsername = "neato-username-fallback", + FallbackPassword = "neato-password-fallback", + MachineSpeechEndThreshold = 3.4 + }; + + Assert.Equal(ModeEnum.Async, machineDetectionConfiguration.Mode); + Assert.Equal(3.2, machineDetectionConfiguration.DetectionTimeout); + Assert.Equal(5.6, machineDetectionConfiguration.SilenceTimeout); + Assert.Equal(1.2, machineDetectionConfiguration.SpeechThreshold); + Assert.Equal(7.6, machineDetectionConfiguration.SpeechEndThreshold); + Assert.False(machineDetectionConfiguration.DelayResult); + Assert.Equal("https://www.example.com/", machineDetectionConfiguration.CallbackUrl); + Assert.Equal(CallbackMethodEnum.GET, machineDetectionConfiguration.CallbackMethod); + Assert.Equal("https://www.example-fallback.com/", machineDetectionConfiguration.FallbackUrl); + Assert.Equal(FallbackMethodEnum.GET, machineDetectionConfiguration.FallbackMethod); + Assert.Equal("neato-username", machineDetectionConfiguration.Username); + Assert.Equal("neato-password", machineDetectionConfiguration.Password); + Assert.Equal("neato-username-fallback", machineDetectionConfiguration.FallbackUsername); + Assert.Equal("neato-password-fallback", machineDetectionConfiguration.FallbackPassword); + Assert.Equal(3.4, machineDetectionConfiguration.MachineSpeechEndThreshold); + } + + [Fact] + public void SerializeMachineDetectionConfiguration() + { + var machineDetectionConfiguration = new MachineDetectionConfiguration + { + Mode = ModeEnum.Async, + DetectionTimeout = 3.2, + SilenceTimeout = 5.6, + SpeechThreshold = 1.2, + SpeechEndThreshold = 7.6, + DelayResult = false, + CallbackUrl = "https://www.example.com/", + CallbackMethod = CallbackMethodEnum.GET, + FallbackUrl = "https://www.example-fallback.com/", + FallbackMethod = FallbackMethodEnum.GET, + Username = "neato-username", + Password = "neato-password", + FallbackUsername = "neato-username-fallback", + FallbackPassword = "neato-password-fallback", + MachineSpeechEndThreshold = 3.4 + }; + + var json = JsonConvert.SerializeObject(machineDetectionConfiguration); + Assert.Equal("{\"machineSpeechEndThreshold\":3.4,\"mode\":\"async\",\"detectionTimeout\":3.2,\"silenceTimeout\":5.6,\"speechThreshold\":1.2,\"speechEndThreshold\":7.6,\"delayResult\":false,\"callbackUrl\":\"https://www.example.com/\",\"callbackMethod\":\"GET\",\"fallbackUrl\":\"https://www.example-fallback.com/\",\"fallbackMethod\":\"GET\",\"username\":\"neato-username\",\"password\":\"neato-password\",\"fallbackUsername\":\"neato-username-fallback\",\"fallbackPassword\":\"neato-password-fallback\"}", json); + } + + [Fact] + public void SerializeMachineDetectionConfigurationUnsetMachineSpeechEndThreshold() + { + var machineDetectionConfiguration = new MachineDetectionConfiguration + { + Mode = ModeEnum.Async, + DetectionTimeout = 3.2, + SilenceTimeout = 5.6, + SpeechThreshold = 1.2, + SpeechEndThreshold = 7.6, + DelayResult = false, + CallbackUrl = "https://www.example.com/", + CallbackMethod = CallbackMethodEnum.GET, + FallbackUrl = "https://www.example-fallback.com/", + FallbackMethod = FallbackMethodEnum.GET, + Username = "neato-username", + Password = "neato-password", + FallbackUsername = "neato-username-fallback", + FallbackPassword = "neato-password-fallback" + }; + + var json = JsonConvert.SerializeObject(machineDetectionConfiguration); + Assert.Equal("{\"mode\":\"async\",\"detectionTimeout\":3.2,\"silenceTimeout\":5.6,\"speechThreshold\":1.2,\"speechEndThreshold\":7.6,\"delayResult\":false,\"callbackUrl\":\"https://www.example.com/\",\"callbackMethod\":\"GET\",\"fallbackUrl\":\"https://www.example-fallback.com/\",\"fallbackMethod\":\"GET\",\"username\":\"neato-username\",\"password\":\"neato-password\",\"fallbackUsername\":\"neato-username-fallback\",\"fallbackPassword\":\"neato-password-fallback\"}", json); + } + } +}