diff --git a/src/Plivo/Resource/Call/CallInterface.cs b/src/Plivo/Resource/Call/CallInterface.cs index 92bef151..6dbd5b6a 100644 --- a/src/Plivo/Resource/Call/CallInterface.cs +++ b/src/Plivo/Resource/Call/CallInterface.cs @@ -210,6 +210,30 @@ public LiveCall GetLive(string liveCallUuid) return liveCall; } + /// + /// Gets the Queued call. + /// + /// Queued call details. + /// Call UUID. + public QueuedCall GetQueued(string callUuid) + { + var queuedCall = GetResource( + callUuid, new Dictionary() {{"status", "queued"}}); + queuedCall.Interface = this; + return queuedCall; + } + + /// + /// Lists the queued calls. + /// + /// queued calls list + public QueuedCallListResponse ListQueued() + { + return + ListResources( + new Dictionary() {{"status", "queued"}}); + } + /// /// Delete Call with the specified callUuid. /// diff --git a/src/Plivo/Resource/Call/LiveCall.cs b/src/Plivo/Resource/Call/LiveCall.cs index 76077083..5cbb69dd 100644 --- a/src/Plivo/Resource/Call/LiveCall.cs +++ b/src/Plivo/Resource/Call/LiveCall.cs @@ -13,5 +13,18 @@ public class LiveCall : Resource public string CallUuid { get; set; } public string RequestUuid { get; set; } public string SessionStart { get; set; } + + public override string ToString() + { + return base.ToString() + + "Direction: " + Direction + "\n" + + "From: " + From + "\n" + + "CallStatus: " + CallStatus + "\n" + + "To: " + To + "\n" + + "CallerName: " + CallerName + "\n" + + "CallUuid: " + CallUuid + "\n" + + "RequestUuid: " + RequestUuid + "\n" + + "SessionStart: " + SessionStart + "\n"; + } } } \ No newline at end of file diff --git a/src/Plivo/Resource/Call/LiveCallListResponse.cs b/src/Plivo/Resource/Call/LiveCallListResponse.cs index 3900839c..1fbccb90 100644 --- a/src/Plivo/Resource/Call/LiveCallListResponse.cs +++ b/src/Plivo/Resource/Call/LiveCallListResponse.cs @@ -6,5 +6,12 @@ public class LiveCallListResponse { public string ApiId { get; set; } public List Calls { get; set; } + + public override string ToString() + { + return base.ToString() + + "ApiId: \n" + ApiId + "\n" + + "Calls: \n" + string.Join(",\n", Calls ) + "\n"; + } } } \ No newline at end of file diff --git a/src/Plivo/Resource/Call/QueuedCall.cs b/src/Plivo/Resource/Call/QueuedCall.cs new file mode 100644 index 00000000..0aa7d42d --- /dev/null +++ b/src/Plivo/Resource/Call/QueuedCall.cs @@ -0,0 +1,30 @@ +namespace Plivo.Resource.Call +{ + /// + /// Queued call. + /// + public class QueuedCall : Resource + { + public string Direction { get; set; } + public string From { get; set; } + public string CallStatus { get; set; } + public string To { get; set; } + public string CallerName { get; set; } + public string CallUuid { get; set; } + public string RequestUuid { get; set; } + + public override string ToString() + { + return base.ToString() + + "Direction: " + Direction + "\n" + + "From: " + From + "\n" + + "CallStatus: " + CallStatus + "\n" + + "To: " + To + "\n" + + "CallerName: " + CallerName + "\n" + + "CallUuid: " + CallUuid + "\n" + + "ApiId: " + ApiId + "\n" + + "RequestUuid: " + RequestUuid + "\n"; + } + } + +} \ No newline at end of file diff --git a/src/Plivo/Resource/Call/QueuedCallListResponse.cs b/src/Plivo/Resource/Call/QueuedCallListResponse.cs new file mode 100644 index 00000000..95d685ed --- /dev/null +++ b/src/Plivo/Resource/Call/QueuedCallListResponse.cs @@ -0,0 +1,17 @@ +using System.Collections.Generic; + +namespace Plivo.Resource.Call +{ + public class QueuedCallListResponse + { + public string ApiId { get; set; } + public List Calls { get; set; } + + public override string ToString() + { + return base.ToString() + + "ApiId: \n" + ApiId + "\n" + + "Calls: \n" + string.Join(",\n", Calls ) + "\n"; + } + } +} \ No newline at end of file diff --git a/tests/Plivo.Test/Mocks/queuedCallGetResponse.json b/tests/Plivo.Test/Mocks/queuedCallGetResponse.json new file mode 100644 index 00000000..f8e82e6a --- /dev/null +++ b/tests/Plivo.Test/Mocks/queuedCallGetResponse.json @@ -0,0 +1,9 @@ +{ + "api_id": "18f3bbb0-3ef1-11e7-a68e-02d2f90c026e", + "call_status": "queued", + "call_uuid": "d0a87a1a-b0e9-4ab2-ac07-c22ee87cd04a", + "caller_name": "", + "direction": "outbound", + "from": "+918687888990", + "to": "919798990001" +} diff --git a/tests/Plivo.Test/Plivo.Test.csproj b/tests/Plivo.Test/Plivo.Test.csproj index d0fc297e..8ff1f2fc 100644 --- a/tests/Plivo.Test/Plivo.Test.csproj +++ b/tests/Plivo.Test/Plivo.Test.csproj @@ -86,6 +86,7 @@ + diff --git a/tests/Plivo.Test/Resources/TestCall.cs b/tests/Plivo.Test/Resources/TestCall.cs index 1ba2cfbf..e185ed7b 100644 --- a/tests/Plivo.Test/Resources/TestCall.cs +++ b/tests/Plivo.Test/Resources/TestCall.cs @@ -199,6 +199,67 @@ public void TestLiveCallGet() AssertRequest(request); } + [Test] + public void TestQueuedCallList() + { + var request = + new PlivoRequest( + "GET", + "Account/MAXXXXXXXXXXXXXXXXXX/Call/", + "", + new Dictionary() + { + {"status", "queued"} + }); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"Mocks/liveCallListGetResponse.json" + ); + Setup(200, response); + + Assert.IsEmpty( + ComparisonUtilities.Compare( + response, + Api.Call.ListQueued() + ) + ); + + AssertRequest(request); + } + + [Test] + public void TestQueuedCallGet() + { + var id = "abcabcabc"; + var request = + new PlivoRequest( + "GET", + "Account/MAXXXXXXXXXXXXXXXXXX/Call/" + id + "/", + "", + new Dictionary() + { + {"status", "queued"} + }); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"Mocks/queuedCallGetResponse.json" + ); + Assert.IsNotEmpty(response); + + Setup(200, response); + + Assert.IsEmpty( + ComparisonUtilities.Compare( + response, + Api.Call.GetQueued(id) + ) + ); + + AssertRequest(request); + } + [Test] public void TestCallTranfer() { diff --git a/tests_netcore/Plivo.NetCore.Test/Mocks/queuedCallGetResponse.json b/tests_netcore/Plivo.NetCore.Test/Mocks/queuedCallGetResponse.json new file mode 100644 index 00000000..f8e82e6a --- /dev/null +++ b/tests_netcore/Plivo.NetCore.Test/Mocks/queuedCallGetResponse.json @@ -0,0 +1,9 @@ +{ + "api_id": "18f3bbb0-3ef1-11e7-a68e-02d2f90c026e", + "call_status": "queued", + "call_uuid": "d0a87a1a-b0e9-4ab2-ac07-c22ee87cd04a", + "caller_name": "", + "direction": "outbound", + "from": "+918687888990", + "to": "919798990001" +} diff --git a/tests_netcore/Plivo.NetCore.Test/Resources/TestCall.cs b/tests_netcore/Plivo.NetCore.Test/Resources/TestCall.cs index 443662c1..6dc9cc00 100644 --- a/tests_netcore/Plivo.NetCore.Test/Resources/TestCall.cs +++ b/tests_netcore/Plivo.NetCore.Test/Resources/TestCall.cs @@ -161,6 +161,35 @@ public void TestLiveCallList() AssertRequest(request); } + [Fact] + public void TestQueuedCallList() + { + var request = + new PlivoRequest( + "GET", + "Account/MAXXXXXXXXXXXXXXXXXX/Call/", + "", + new Dictionary() + { + {"status", "queued"} + }); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/liveCallListGetResponse.json" + ); + Setup(200, response); + + Assert.Empty( + ComparisonUtilities.Compare( + response, + Api.Call.ListQueued() + ) + ); + + AssertRequest(request); + } + [Fact] public void TestLiveCallGet() { @@ -193,6 +222,38 @@ public void TestLiveCallGet() AssertRequest(request); } + [Fact] + public void TestQueuedCallGet() + { + var id = "abcabcabc"; + var request = + new PlivoRequest( + "GET", + "Account/MAXXXXXXXXXXXXXXXXXX/Call/" + id + "/", + "", + new Dictionary() + { + {"status", "queued"} + }); + + var response = + System.IO.File.ReadAllText( + SOURCE_DIR + @"../Mocks/queuedCallGetResponse.json" + ); + Assert.NotEmpty(response); + + Setup(200, response); + + Assert.Empty( + ComparisonUtilities.Compare( + response, + Api.Call.GetQueued(id) + ) + ); + + AssertRequest(request); + } + [Fact] public void TestCallTranfer() {