Skip to content

Commit 371cb62

Browse files
authored
Merge pull request #43 from Bandwidth/DX-2404
DX-2404 Update `CallCallback` model to machineDetectionComplete
2 parents cbb3c9f + 54556dc commit 371cb62

File tree

4 files changed

+195
-4
lines changed

4 files changed

+195
-4
lines changed

Bandwidth.Standard/Voice/Models/CallCallback.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ public CallCallback()
6060
/// <param name="terminatingDigit">terminatingDigit.</param>
6161
/// <param name="transcription">transcription.</param>
6262
/// <param name="diversion">diversion.</param>
63+
/// <param name="machineDetectionResult">machineDetectionResult.</param>
6364
public CallCallback(
6465
string eventType = null,
6566
string eventTime = null,
@@ -90,7 +91,8 @@ public CallCallback(
9091
string digits = null,
9192
string terminatingDigit = null,
9293
Models.Transcription transcription = null,
93-
Models.Diversion diversion = null)
94+
Models.Diversion diversion = null,
95+
Models.MachineDetectionResult machineDetectionResult = null)
9496
{
9597
this.EventType = eventType;
9698
this.EventTime = eventTime;
@@ -122,6 +124,7 @@ public CallCallback(
122124
this.TerminatingDigit = terminatingDigit;
123125
this.Transcription = transcription;
124126
this.Diversion = diversion;
127+
this.MachineDetectionResult = machineDetectionResult;
125128
}
126129

127130
/// <summary>
@@ -304,6 +307,12 @@ public CallCallback(
304307
[JsonProperty("diversion", NullValueHandling = NullValueHandling.Ignore)]
305308
public Models.Diversion Diversion { get; set; }
306309

310+
/// <summary>
311+
/// Gets or sets MachineDetectionResult.
312+
/// </summary>
313+
[JsonProperty("machineDetectionResult", NullValueHandling = NullValueHandling.Ignore)]
314+
public Models.MachineDetectionResult MachineDetectionResult { get; set; }
315+
307316
/// <inheritdoc/>
308317
public override string ToString()
309318
{
@@ -357,7 +366,8 @@ public override bool Equals(object obj)
357366
((this.Digits == null && other.Digits == null) || (this.Digits?.Equals(other.Digits) == true)) &&
358367
((this.TerminatingDigit == null && other.TerminatingDigit == null) || (this.TerminatingDigit?.Equals(other.TerminatingDigit) == true)) &&
359368
((this.Transcription == null && other.Transcription == null) || (this.Transcription?.Equals(other.Transcription) == true)) &&
360-
((this.Diversion == null && other.Diversion == null) || (this.Diversion?.Equals(other.Diversion) == true));
369+
((this.Diversion == null && other.Diversion == null) || (this.Diversion?.Equals(other.Diversion) == true)) &&
370+
((this.MachineDetectionResult == null && other.MachineDetectionResult == null) || (this.MachineDetectionResult?.Equals(other.MachineDetectionResult) == true));
361371
}
362372

363373
/// <inheritdoc/>
@@ -515,6 +525,11 @@ public override int GetHashCode()
515525
hashCode += this.Diversion.GetHashCode();
516526
}
517527

528+
if (this.MachineDetectionResult != null)
529+
{
530+
hashCode += this.MachineDetectionResult.GetHashCode();
531+
}
532+
518533
return hashCode;
519534
}
520535

@@ -554,6 +569,7 @@ protected void ToString(List<string> toStringOutput)
554569
toStringOutput.Add($"this.TerminatingDigit = {(this.TerminatingDigit == null ? "null" : this.TerminatingDigit == string.Empty ? "" : this.TerminatingDigit)}");
555570
toStringOutput.Add($"this.Transcription = {(this.Transcription == null ? "null" : this.Transcription.ToString())}");
556571
toStringOutput.Add($"this.Diversion = {(this.Diversion == null ? "null" : this.Diversion.ToString())}");
572+
toStringOutput.Add($"this.MachineDetectionResult = {(this.MachineDetectionResult == null ? "null" : this.MachineDetectionResult.ToString())}");
557573
}
558574
}
559-
}
575+
}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// <copyright file="Diversion.cs" company="APIMatic">
2+
// Copyright (c) APIMatic. All rights reserved.
3+
// </copyright>
4+
namespace Bandwidth.Standard.Voice.Models
5+
{
6+
using System;
7+
using System.Collections.Generic;
8+
using System.ComponentModel;
9+
using System.IO;
10+
using System.Linq;
11+
using System.Text;
12+
using System.Threading.Tasks;
13+
using Bandwidth.Standard;
14+
using Bandwidth.Standard.Utilities;
15+
using Newtonsoft.Json;
16+
using Newtonsoft.Json.Converters;
17+
18+
/// <summary>
19+
/// Diversion.
20+
/// </summary>
21+
public class MachineDetectionResult
22+
{
23+
/// <summary>
24+
/// Initializes a new instance of the <see cref="MachineDetectionResult"/> class.
25+
/// </summary>
26+
public MachineDetectionResult()
27+
{
28+
}
29+
30+
/// <summary>
31+
/// Initializes a new instance of the <see cref="MachineDetectionResult"/> class.
32+
/// </summary>
33+
/// <param name="value">value.</param>
34+
/// <param name="duration">duration.</param>
35+
public MachineDetectionResult(
36+
string value = null,
37+
string duration = null)
38+
{
39+
this.Value = value;
40+
this.Duration = duration;
41+
}
42+
43+
/// <summary>
44+
/// Gets or sets Value.
45+
/// </summary>
46+
[JsonProperty("value", NullValueHandling = NullValueHandling.Ignore)]
47+
public string Value { get; set; }
48+
49+
/// <summary>
50+
/// Gets or sets Duration.
51+
/// </summary>
52+
[JsonProperty("duration", NullValueHandling = NullValueHandling.Ignore)]
53+
public string Duration { get; set; }
54+
55+
/// <inheritdoc/>
56+
public override bool Equals(object obj)
57+
{
58+
if (obj == null)
59+
{
60+
return false;
61+
}
62+
63+
if (obj == this)
64+
{
65+
return true;
66+
}
67+
68+
return obj is MachineDetectionResult other &&
69+
((this.Value == null && other.Value == null) || (this.Value?.Equals(other.Value) == true)) &&
70+
((this.Duration == null && other.Duration == null) || (this.Duration?.Equals(other.Duration) == true));
71+
}
72+
73+
/// <inheritdoc/>
74+
public override int GetHashCode()
75+
{
76+
int hashCode = 2065332573;
77+
78+
if (this.Value != null)
79+
{
80+
hashCode += this.Value.GetHashCode();
81+
}
82+
83+
if (this.Duration != null)
84+
{
85+
hashCode += this.Duration.GetHashCode();
86+
}
87+
88+
return hashCode;
89+
}
90+
91+
/// <summary>
92+
/// ToString overload.
93+
/// </summary>
94+
/// <param name="toStringOutput">List of strings.</param>
95+
protected void ToString(List<string> toStringOutput)
96+
{
97+
toStringOutput.Add($"this.Value = {(this.Value == null ? "null" : this.Value == string.Empty ? "" : this.Value)}");
98+
toStringOutput.Add($"this.Duration = {(this.Duration == null ? "null" : this.Duration == string.Empty ? "" : this.Duration)}");
99+
}
100+
}
101+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Bandwidth.Standard;
4+
using Bandwidth.Standard.Voice.Exceptions;
5+
using Bandwidth.Standard.Voice.Models;
6+
using Xunit;
7+
8+
namespace Bandwidth.StandardTests.Voice
9+
{
10+
public class CallCallbackUnitTest
11+
{
12+
[Fact]
13+
public void InitiateEvent()
14+
{
15+
var initiateEvent = new CallCallback()
16+
{
17+
EventType = "initiate",
18+
EventTime = "2019-06-20T15:56:11.554Z",
19+
AccountId = "55555555",
20+
ApplicationId = "7fc9698a-b04a-468b-9e8f-91238c0d0086",
21+
From = "+15551112222",
22+
To = "+15553334444",
23+
Direction = "inbound",
24+
CallId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
25+
CallUrl = "https://voice.bandwidth.com/api/v2/accounts/55555555/calls/c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d",
26+
StartTime = "2019-06-20T15:54:22.234Z"
27+
};
28+
29+
Assert.Equal("initiate", initiateEvent.EventType);
30+
Assert.Equal("2019-06-20T15:56:11.554Z", initiateEvent.EventTime);
31+
Assert.Equal("55555555", initiateEvent.AccountId);
32+
Assert.Equal("7fc9698a-b04a-468b-9e8f-91238c0d0086", initiateEvent.ApplicationId);
33+
Assert.Equal("+15551112222", initiateEvent.From);
34+
Assert.Equal("+15553334444", initiateEvent.To);
35+
Assert.Equal("inbound", initiateEvent.Direction);
36+
Assert.Equal("c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", initiateEvent.CallId);
37+
Assert.Equal("https://voice.bandwidth.com/api/v2/accounts/55555555/calls/c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", initiateEvent.CallUrl);
38+
Assert.Equal("2019-06-20T15:54:22.234Z", initiateEvent.StartTime);
39+
}
40+
41+
[Fact]
42+
public void MachineDetectionCompleteEvent()
43+
{
44+
var machineDetectionCompleteEvent = new CallCallback()
45+
{
46+
EventType = "machineDetectionComplete",
47+
EventTime = "2019-06-20T15:56:11.554Z",
48+
AccountId = "55555555",
49+
ApplicationId = "7fc9698a-b04a-468b-9e8f-91238c0d0086",
50+
From = "+15551112222",
51+
To = "+15553334444",
52+
Direction = "inbound",
53+
CallId = "c-6a0d8e3e-1c71aa98-fb05-46ca-acf8-f735db20fa28",
54+
CallUrl = "https://voice.bandwidth.com/api/v2/accounts/55555555/calls/c-6a0d8e3e-1c71aa98-fb05-46ca-acf8-f735db20fa28",
55+
AnswerTime = "2019-06-20T15:54:22.234Z",
56+
MachineDetectionResult = new MachineDetectionResult() {Value = "answering-machine", Duration = "PT4.9891287S"}
57+
};
58+
59+
Assert.Equal("machineDetectionComplete", machineDetectionCompleteEvent.EventType);
60+
Assert.Equal("2019-06-20T15:56:11.554Z", machineDetectionCompleteEvent.EventTime);
61+
Assert.Equal("55555555", machineDetectionCompleteEvent.AccountId);
62+
Assert.Equal("7fc9698a-b04a-468b-9e8f-91238c0d0086", machineDetectionCompleteEvent.ApplicationId);
63+
Assert.Equal("+15551112222", machineDetectionCompleteEvent.From);
64+
Assert.Equal("+15553334444", machineDetectionCompleteEvent.To);
65+
Assert.Equal("inbound", machineDetectionCompleteEvent.Direction);
66+
Assert.Equal("c-6a0d8e3e-1c71aa98-fb05-46ca-acf8-f735db20fa28", machineDetectionCompleteEvent.CallId);
67+
Assert.Equal("https://voice.bandwidth.com/api/v2/accounts/55555555/calls/c-6a0d8e3e-1c71aa98-fb05-46ca-acf8-f735db20fa28", machineDetectionCompleteEvent.CallUrl);
68+
Assert.Equal("2019-06-20T15:54:22.234Z", machineDetectionCompleteEvent.AnswerTime);
69+
Assert.Equal("answering-machine", machineDetectionCompleteEvent.MachineDetectionResult.Value);
70+
Assert.Equal("PT4.9891287S", machineDetectionCompleteEvent.MachineDetectionResult.Duration);
71+
}
72+
}
73+
74+
}

Bandwidth.StandardTests/Voice/CreateCallTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,4 @@ public async Task CreateCallInvalidFromPhoneNumberThrows()
125125
Assert.Equal("Something's not quite right... Your request is invalid. Please fix it before trying again.", ex.Message);
126126
}
127127
}
128-
}
128+
}

0 commit comments

Comments
 (0)