Skip to content

Commit 877b7ba

Browse files
authored
DX-2554 Add machineSpeedEndThreshold (#48)
* Add machineSpeedEndThreshold * Serailized is not a word * Weather vs whether * Don't guess at the json ordering
1 parent 1640f3d commit 877b7ba

File tree

2 files changed

+134
-18
lines changed

2 files changed

+134
-18
lines changed

Bandwidth.Standard/Voice/Models/MachineDetectionConfiguration.cs

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class MachineDetectionConfiguration
2828
private string password;
2929
private string fallbackUsername;
3030
private string fallbackPassword;
31+
private double? machineSpeechEndThreshold;
3132
private Dictionary<string, bool> shouldSerialize = new Dictionary<string, bool>
3233
{
3334
{ "callbackUrl", false },
@@ -64,6 +65,7 @@ public MachineDetectionConfiguration()
6465
/// <param name="password">password.</param>
6566
/// <param name="fallbackUsername">fallbackUsername.</param>
6667
/// <param name="fallbackPassword">fallbackPassword.</param>
68+
/// <param name="machineSpeechEndThreshold">machineSpeechEndThreshold.</param>
6769
public MachineDetectionConfiguration(
6870
Models.ModeEnum? mode = null,
6971
double? detectionTimeout = null,
@@ -78,7 +80,8 @@ public MachineDetectionConfiguration(
7880
string username = null,
7981
string password = null,
8082
string fallbackUsername = null,
81-
string fallbackPassword = null)
83+
string fallbackPassword = null,
84+
double? machineSpeechEndThreshold = null)
8285
{
8386
this.Mode = mode;
8487
this.DetectionTimeout = detectionTimeout;
@@ -126,6 +129,7 @@ public MachineDetectionConfiguration(
126129
this.FallbackPassword = fallbackPassword;
127130
}
128131

132+
this.MachineSpeechEndThreshold = machineSpeechEndThreshold;
129133
}
130134

131135
/// <summary>
@@ -308,6 +312,12 @@ public string FallbackPassword
308312
}
309313
}
310314

315+
/// <summary>
316+
/// When an answering machine is detected, the amount of silence (in seconds) before assuming the message has finished playing.
317+
/// </summary>
318+
[JsonProperty("machineSpeechEndThreshold", NullValueHandling = NullValueHandling.Ignore)]
319+
public double? MachineSpeechEndThreshold;
320+
311321
/// <inheritdoc/>
312322
public override string ToString()
313323
{
@@ -319,63 +329,63 @@ public override string ToString()
319329
}
320330

321331
/// <summary>
322-
/// Marks the field to not be serailized.
332+
/// Marks the field to not be serialized.
323333
/// </summary>
324334
public void UnsetCallbackUrl()
325335
{
326336
this.shouldSerialize["callbackUrl"] = false;
327337
}
328338

329339
/// <summary>
330-
/// Marks the field to not be serailized.
340+
/// Marks the field to not be serialized.
331341
/// </summary>
332342
public void UnsetCallbackMethod()
333343
{
334344
this.shouldSerialize["callbackMethod"] = false;
335345
}
336346

337347
/// <summary>
338-
/// Marks the field to not be serailized.
348+
/// Marks the field to not be serialized.
339349
/// </summary>
340350
public void UnsetFallbackUrl()
341351
{
342352
this.shouldSerialize["fallbackUrl"] = false;
343353
}
344354

345355
/// <summary>
346-
/// Marks the field to not be serailized.
356+
/// Marks the field to not be serialized.
347357
/// </summary>
348358
public void UnsetFallbackMethod()
349359
{
350360
this.shouldSerialize["fallbackMethod"] = false;
351361
}
352362

353363
/// <summary>
354-
/// Marks the field to not be serailized.
364+
/// Marks the field to not be serialized.
355365
/// </summary>
356366
public void UnsetUsername()
357367
{
358368
this.shouldSerialize["username"] = false;
359369
}
360370

361371
/// <summary>
362-
/// Marks the field to not be serailized.
372+
/// Marks the field to not be serialized.
363373
/// </summary>
364374
public void UnsetPassword()
365375
{
366376
this.shouldSerialize["password"] = false;
367377
}
368378

369379
/// <summary>
370-
/// Marks the field to not be serailized.
380+
/// Marks the field to not be serialized.
371381
/// </summary>
372382
public void UnsetFallbackUsername()
373383
{
374384
this.shouldSerialize["fallbackUsername"] = false;
375385
}
376386

377387
/// <summary>
378-
/// Marks the field to not be serailized.
388+
/// Marks the field to not be serialized.
379389
/// </summary>
380390
public void UnsetFallbackPassword()
381391
{
@@ -385,7 +395,7 @@ public void UnsetFallbackPassword()
385395
/// <summary>
386396
/// Checks if the field should be serialized or not.
387397
/// </summary>
388-
/// <returns>A boolean weather the field should be serialized or not.</returns>
398+
/// <returns>A boolean whether the field should be serialized or not.</returns>
389399
public bool ShouldSerializeCallbackUrl()
390400
{
391401
return this.shouldSerialize["callbackUrl"];
@@ -394,7 +404,7 @@ public bool ShouldSerializeCallbackUrl()
394404
/// <summary>
395405
/// Checks if the field should be serialized or not.
396406
/// </summary>
397-
/// <returns>A boolean weather the field should be serialized or not.</returns>
407+
/// <returns>A boolean whether the field should be serialized or not.</returns>
398408
public bool ShouldSerializeCallbackMethod()
399409
{
400410
return this.shouldSerialize["callbackMethod"];
@@ -403,7 +413,7 @@ public bool ShouldSerializeCallbackMethod()
403413
/// <summary>
404414
/// Checks if the field should be serialized or not.
405415
/// </summary>
406-
/// <returns>A boolean weather the field should be serialized or not.</returns>
416+
/// <returns>A boolean whether the field should be serialized or not.</returns>
407417
public bool ShouldSerializeFallbackUrl()
408418
{
409419
return this.shouldSerialize["fallbackUrl"];
@@ -412,7 +422,7 @@ public bool ShouldSerializeFallbackUrl()
412422
/// <summary>
413423
/// Checks if the field should be serialized or not.
414424
/// </summary>
415-
/// <returns>A boolean weather the field should be serialized or not.</returns>
425+
/// <returns>A boolean whether the field should be serialized or not.</returns>
416426
public bool ShouldSerializeFallbackMethod()
417427
{
418428
return this.shouldSerialize["fallbackMethod"];
@@ -421,7 +431,7 @@ public bool ShouldSerializeFallbackMethod()
421431
/// <summary>
422432
/// Checks if the field should be serialized or not.
423433
/// </summary>
424-
/// <returns>A boolean weather the field should be serialized or not.</returns>
434+
/// <returns>A boolean whether the field should be serialized or not.</returns>
425435
public bool ShouldSerializeUsername()
426436
{
427437
return this.shouldSerialize["username"];
@@ -430,7 +440,7 @@ public bool ShouldSerializeUsername()
430440
/// <summary>
431441
/// Checks if the field should be serialized or not.
432442
/// </summary>
433-
/// <returns>A boolean weather the field should be serialized or not.</returns>
443+
/// <returns>A boolean whether the field should be serialized or not.</returns>
434444
public bool ShouldSerializePassword()
435445
{
436446
return this.shouldSerialize["password"];
@@ -439,7 +449,7 @@ public bool ShouldSerializePassword()
439449
/// <summary>
440450
/// Checks if the field should be serialized or not.
441451
/// </summary>
442-
/// <returns>A boolean weather the field should be serialized or not.</returns>
452+
/// <returns>A boolean whether the field should be serialized or not.</returns>
443453
public bool ShouldSerializeFallbackUsername()
444454
{
445455
return this.shouldSerialize["fallbackUsername"];
@@ -448,7 +458,7 @@ public bool ShouldSerializeFallbackUsername()
448458
/// <summary>
449459
/// Checks if the field should be serialized or not.
450460
/// </summary>
451-
/// <returns>A boolean weather the field should be serialized or not.</returns>
461+
/// <returns>A boolean whether the field should be serialized or not.</returns>
452462
public bool ShouldSerializeFallbackPassword()
453463
{
454464
return this.shouldSerialize["fallbackPassword"];
@@ -481,7 +491,8 @@ public override bool Equals(object obj)
481491
((this.Username == null && other.Username == null) || (this.Username?.Equals(other.Username) == true)) &&
482492
((this.Password == null && other.Password == null) || (this.Password?.Equals(other.Password) == true)) &&
483493
((this.FallbackUsername == null && other.FallbackUsername == null) || (this.FallbackUsername?.Equals(other.FallbackUsername) == true)) &&
484-
((this.FallbackPassword == null && other.FallbackPassword == null) || (this.FallbackPassword?.Equals(other.FallbackPassword) == true));
494+
((this.FallbackPassword == null && other.FallbackPassword == null) || (this.FallbackPassword?.Equals(other.FallbackPassword) == true)) &&
495+
((this.MachineSpeechEndThreshold == null && other.MachineSpeechEndThreshold == null) || (this.MachineSpeechEndThreshold?.Equals(other.MachineSpeechEndThreshold) == true));
485496
}
486497

487498
/// <inheritdoc/>
@@ -559,6 +570,11 @@ public override int GetHashCode()
559570
hashCode += this.FallbackPassword.GetHashCode();
560571
}
561572

573+
if (this.MachineSpeechEndThreshold != null)
574+
{
575+
hashCode += this.MachineSpeechEndThreshold.GetHashCode();
576+
}
577+
562578
return hashCode;
563579
}
564580

@@ -582,6 +598,7 @@ protected void ToString(List<string> toStringOutput)
582598
toStringOutput.Add($"this.Password = {(this.Password == null ? "null" : this.Password == string.Empty ? "" : this.Password)}");
583599
toStringOutput.Add($"this.FallbackUsername = {(this.FallbackUsername == null ? "null" : this.FallbackUsername == string.Empty ? "" : this.FallbackUsername)}");
584600
toStringOutput.Add($"this.FallbackPassword = {(this.FallbackPassword == null ? "null" : this.FallbackPassword == string.Empty ? "" : this.FallbackPassword)}");
601+
toStringOutput.Add($"this.MachineSpeechEndThreshold = {(this.MachineSpeechEndThreshold == null ? "null" : this.MachineSpeechEndThreshold.ToString())}");
585602
}
586603
}
587604
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
using Bandwidth.Standard.Voice.Models;
2+
using Newtonsoft.Json;
3+
using Xunit;
4+
5+
namespace Bandwidth.StandardTests.Voice
6+
{
7+
public class ModelTests
8+
{
9+
[Fact]
10+
public void PopulateMachineDetectionConfiguration()
11+
{
12+
var machineDetectionConfiguration = new MachineDetectionConfiguration
13+
{
14+
Mode = ModeEnum.Async,
15+
DetectionTimeout = 3.2,
16+
SilenceTimeout = 5.6,
17+
SpeechThreshold = 1.2,
18+
SpeechEndThreshold = 7.6,
19+
DelayResult = false,
20+
CallbackUrl = "https://www.example.com/",
21+
CallbackMethod = CallbackMethodEnum.GET,
22+
FallbackUrl = "https://www.example-fallback.com/",
23+
FallbackMethod = FallbackMethodEnum.GET,
24+
Username = "neato-username",
25+
Password = "neato-password",
26+
FallbackUsername = "neato-username-fallback",
27+
FallbackPassword = "neato-password-fallback",
28+
MachineSpeechEndThreshold = 3.4
29+
};
30+
31+
Assert.Equal(ModeEnum.Async, machineDetectionConfiguration.Mode);
32+
Assert.Equal(3.2, machineDetectionConfiguration.DetectionTimeout);
33+
Assert.Equal(5.6, machineDetectionConfiguration.SilenceTimeout);
34+
Assert.Equal(1.2, machineDetectionConfiguration.SpeechThreshold);
35+
Assert.Equal(7.6, machineDetectionConfiguration.SpeechEndThreshold);
36+
Assert.False(machineDetectionConfiguration.DelayResult);
37+
Assert.Equal("https://www.example.com/", machineDetectionConfiguration.CallbackUrl);
38+
Assert.Equal(CallbackMethodEnum.GET, machineDetectionConfiguration.CallbackMethod);
39+
Assert.Equal("https://www.example-fallback.com/", machineDetectionConfiguration.FallbackUrl);
40+
Assert.Equal(FallbackMethodEnum.GET, machineDetectionConfiguration.FallbackMethod);
41+
Assert.Equal("neato-username", machineDetectionConfiguration.Username);
42+
Assert.Equal("neato-password", machineDetectionConfiguration.Password);
43+
Assert.Equal("neato-username-fallback", machineDetectionConfiguration.FallbackUsername);
44+
Assert.Equal("neato-password-fallback", machineDetectionConfiguration.FallbackPassword);
45+
Assert.Equal(3.4, machineDetectionConfiguration.MachineSpeechEndThreshold);
46+
}
47+
48+
[Fact]
49+
public void SerializeMachineDetectionConfiguration()
50+
{
51+
var machineDetectionConfiguration = new MachineDetectionConfiguration
52+
{
53+
Mode = ModeEnum.Async,
54+
DetectionTimeout = 3.2,
55+
SilenceTimeout = 5.6,
56+
SpeechThreshold = 1.2,
57+
SpeechEndThreshold = 7.6,
58+
DelayResult = false,
59+
CallbackUrl = "https://www.example.com/",
60+
CallbackMethod = CallbackMethodEnum.GET,
61+
FallbackUrl = "https://www.example-fallback.com/",
62+
FallbackMethod = FallbackMethodEnum.GET,
63+
Username = "neato-username",
64+
Password = "neato-password",
65+
FallbackUsername = "neato-username-fallback",
66+
FallbackPassword = "neato-password-fallback",
67+
MachineSpeechEndThreshold = 3.4
68+
};
69+
70+
var json = JsonConvert.SerializeObject(machineDetectionConfiguration);
71+
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);
72+
}
73+
74+
[Fact]
75+
public void SerializeMachineDetectionConfigurationUnsetMachineSpeechEndThreshold()
76+
{
77+
var machineDetectionConfiguration = new MachineDetectionConfiguration
78+
{
79+
Mode = ModeEnum.Async,
80+
DetectionTimeout = 3.2,
81+
SilenceTimeout = 5.6,
82+
SpeechThreshold = 1.2,
83+
SpeechEndThreshold = 7.6,
84+
DelayResult = false,
85+
CallbackUrl = "https://www.example.com/",
86+
CallbackMethod = CallbackMethodEnum.GET,
87+
FallbackUrl = "https://www.example-fallback.com/",
88+
FallbackMethod = FallbackMethodEnum.GET,
89+
Username = "neato-username",
90+
Password = "neato-password",
91+
FallbackUsername = "neato-username-fallback",
92+
FallbackPassword = "neato-password-fallback"
93+
};
94+
95+
var json = JsonConvert.SerializeObject(machineDetectionConfiguration);
96+
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);
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)