-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from Bandwidth/DX-2404
DX-2404 Update `CallCallback` model to machineDetectionComplete
- Loading branch information
Showing
4 changed files
with
195 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
Bandwidth.Standard/Voice/Models/MachineDetectionResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// <copyright file="Diversion.cs" company="APIMatic"> | ||
// Copyright (c) APIMatic. All rights reserved. | ||
// </copyright> | ||
namespace Bandwidth.Standard.Voice.Models | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Bandwidth.Standard; | ||
using Bandwidth.Standard.Utilities; | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
|
||
/// <summary> | ||
/// Diversion. | ||
/// </summary> | ||
public class MachineDetectionResult | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MachineDetectionResult"/> class. | ||
/// </summary> | ||
public MachineDetectionResult() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MachineDetectionResult"/> class. | ||
/// </summary> | ||
/// <param name="value">value.</param> | ||
/// <param name="duration">duration.</param> | ||
public MachineDetectionResult( | ||
string value = null, | ||
string duration = null) | ||
{ | ||
this.Value = value; | ||
this.Duration = duration; | ||
} | ||
|
||
/// <summary> | ||
/// Gets or sets Value. | ||
/// </summary> | ||
[JsonProperty("value", NullValueHandling = NullValueHandling.Ignore)] | ||
public string Value { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets Duration. | ||
/// </summary> | ||
[JsonProperty("duration", NullValueHandling = NullValueHandling.Ignore)] | ||
public string Duration { get; set; } | ||
|
||
/// <inheritdoc/> | ||
public override bool Equals(object obj) | ||
{ | ||
if (obj == null) | ||
{ | ||
return false; | ||
} | ||
|
||
if (obj == this) | ||
{ | ||
return true; | ||
} | ||
|
||
return obj is MachineDetectionResult other && | ||
((this.Value == null && other.Value == null) || (this.Value?.Equals(other.Value) == true)) && | ||
((this.Duration == null && other.Duration == null) || (this.Duration?.Equals(other.Duration) == true)); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override int GetHashCode() | ||
{ | ||
int hashCode = 2065332573; | ||
|
||
if (this.Value != null) | ||
{ | ||
hashCode += this.Value.GetHashCode(); | ||
} | ||
|
||
if (this.Duration != null) | ||
{ | ||
hashCode += this.Duration.GetHashCode(); | ||
} | ||
|
||
return hashCode; | ||
} | ||
|
||
/// <summary> | ||
/// ToString overload. | ||
/// </summary> | ||
/// <param name="toStringOutput">List of strings.</param> | ||
protected void ToString(List<string> toStringOutput) | ||
{ | ||
toStringOutput.Add($"this.Value = {(this.Value == null ? "null" : this.Value == string.Empty ? "" : this.Value)}"); | ||
toStringOutput.Add($"this.Duration = {(this.Duration == null ? "null" : this.Duration == string.Empty ? "" : this.Duration)}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Bandwidth.Standard; | ||
using Bandwidth.Standard.Voice.Exceptions; | ||
using Bandwidth.Standard.Voice.Models; | ||
using Xunit; | ||
|
||
namespace Bandwidth.StandardTests.Voice | ||
{ | ||
public class CallCallbackUnitTest | ||
{ | ||
[Fact] | ||
public void InitiateEvent() | ||
{ | ||
var initiateEvent = new CallCallback() | ||
{ | ||
EventType = "initiate", | ||
EventTime = "2019-06-20T15:56:11.554Z", | ||
AccountId = "55555555", | ||
ApplicationId = "7fc9698a-b04a-468b-9e8f-91238c0d0086", | ||
From = "+15551112222", | ||
To = "+15553334444", | ||
Direction = "inbound", | ||
CallId = "c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", | ||
CallUrl = "https://voice.bandwidth.com/api/v2/accounts/55555555/calls/c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", | ||
StartTime = "2019-06-20T15:54:22.234Z" | ||
}; | ||
|
||
Assert.Equal("initiate", initiateEvent.EventType); | ||
Assert.Equal("2019-06-20T15:56:11.554Z", initiateEvent.EventTime); | ||
Assert.Equal("55555555", initiateEvent.AccountId); | ||
Assert.Equal("7fc9698a-b04a-468b-9e8f-91238c0d0086", initiateEvent.ApplicationId); | ||
Assert.Equal("+15551112222", initiateEvent.From); | ||
Assert.Equal("+15553334444", initiateEvent.To); | ||
Assert.Equal("inbound", initiateEvent.Direction); | ||
Assert.Equal("c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", initiateEvent.CallId); | ||
Assert.Equal("https://voice.bandwidth.com/api/v2/accounts/55555555/calls/c-95ac8d6e-1a31c52e-b38f-4198-93c1-51633ec68f8d", initiateEvent.CallUrl); | ||
Assert.Equal("2019-06-20T15:54:22.234Z", initiateEvent.StartTime); | ||
} | ||
|
||
[Fact] | ||
public void MachineDetectionCompleteEvent() | ||
{ | ||
var machineDetectionCompleteEvent = new CallCallback() | ||
{ | ||
EventType = "machineDetectionComplete", | ||
EventTime = "2019-06-20T15:56:11.554Z", | ||
AccountId = "55555555", | ||
ApplicationId = "7fc9698a-b04a-468b-9e8f-91238c0d0086", | ||
From = "+15551112222", | ||
To = "+15553334444", | ||
Direction = "inbound", | ||
CallId = "c-6a0d8e3e-1c71aa98-fb05-46ca-acf8-f735db20fa28", | ||
CallUrl = "https://voice.bandwidth.com/api/v2/accounts/55555555/calls/c-6a0d8e3e-1c71aa98-fb05-46ca-acf8-f735db20fa28", | ||
AnswerTime = "2019-06-20T15:54:22.234Z", | ||
MachineDetectionResult = new MachineDetectionResult() {Value = "answering-machine", Duration = "PT4.9891287S"} | ||
}; | ||
|
||
Assert.Equal("machineDetectionComplete", machineDetectionCompleteEvent.EventType); | ||
Assert.Equal("2019-06-20T15:56:11.554Z", machineDetectionCompleteEvent.EventTime); | ||
Assert.Equal("55555555", machineDetectionCompleteEvent.AccountId); | ||
Assert.Equal("7fc9698a-b04a-468b-9e8f-91238c0d0086", machineDetectionCompleteEvent.ApplicationId); | ||
Assert.Equal("+15551112222", machineDetectionCompleteEvent.From); | ||
Assert.Equal("+15553334444", machineDetectionCompleteEvent.To); | ||
Assert.Equal("inbound", machineDetectionCompleteEvent.Direction); | ||
Assert.Equal("c-6a0d8e3e-1c71aa98-fb05-46ca-acf8-f735db20fa28", machineDetectionCompleteEvent.CallId); | ||
Assert.Equal("https://voice.bandwidth.com/api/v2/accounts/55555555/calls/c-6a0d8e3e-1c71aa98-fb05-46ca-acf8-f735db20fa28", machineDetectionCompleteEvent.CallUrl); | ||
Assert.Equal("2019-06-20T15:54:22.234Z", machineDetectionCompleteEvent.AnswerTime); | ||
Assert.Equal("answering-machine", machineDetectionCompleteEvent.MachineDetectionResult.Value); | ||
Assert.Equal("PT4.9891287S", machineDetectionCompleteEvent.MachineDetectionResult.Duration); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters