Skip to content

Commit

Permalink
Merge pull request #73 from plivo/feature-queued-call
Browse files Browse the repository at this point in the history
Feature queued call
  • Loading branch information
Sachin Kulshrestha authored Sep 12, 2018
2 parents c1edd54 + f6de48c commit 33ecc04
Show file tree
Hide file tree
Showing 10 changed files with 232 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/Plivo/Resource/Call/CallInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,30 @@ public LiveCall GetLive(string liveCallUuid)
return liveCall;
}

/// <summary>
/// Gets the Queued call.
/// </summary>
/// <returns>Queued call details.</returns>
/// <param name="callUuid">Call UUID.</param>
public QueuedCall GetQueued(string callUuid)
{
var queuedCall = GetResource<QueuedCall>(
callUuid, new Dictionary<string, object>() {{"status", "queued"}});
queuedCall.Interface = this;
return queuedCall;
}

/// <summary>
/// Lists the queued calls.
/// </summary>
/// <returns>queued calls list</returns>
public QueuedCallListResponse ListQueued()
{
return
ListResources<QueuedCallListResponse>(
new Dictionary<string, object>() {{"status", "queued"}});
}

/// <summary>
/// Delete Call with the specified callUuid.
/// </summary>
Expand Down
13 changes: 13 additions & 0 deletions src/Plivo/Resource/Call/LiveCall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
}
7 changes: 7 additions & 0 deletions src/Plivo/Resource/Call/LiveCallListResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,12 @@ public class LiveCallListResponse
{
public string ApiId { get; set; }
public List<string> Calls { get; set; }

public override string ToString()
{
return base.ToString() +
"ApiId: \n" + ApiId + "\n" +
"Calls: \n" + string.Join(",\n", Calls ) + "\n";
}
}
}
30 changes: 30 additions & 0 deletions src/Plivo/Resource/Call/QueuedCall.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace Plivo.Resource.Call
{
/// <summary>
/// Queued call.
/// </summary>
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";
}
}

}
17 changes: 17 additions & 0 deletions src/Plivo/Resource/Call/QueuedCallListResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Collections.Generic;

namespace Plivo.Resource.Call
{
public class QueuedCallListResponse
{
public string ApiId { get; set; }
public List<string> Calls { get; set; }

public override string ToString()
{
return base.ToString() +
"ApiId: \n" + ApiId + "\n" +
"Calls: \n" + string.Join(",\n", Calls ) + "\n";
}
}
}
9 changes: 9 additions & 0 deletions tests/Plivo.Test/Mocks/queuedCallGetResponse.json
Original file line number Diff line number Diff line change
@@ -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"
}
1 change: 1 addition & 0 deletions tests/Plivo.Test/Plivo.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
<Content Include="Mocks\endpointUpdateResponse.json" />
<Content Include="Mocks\liveCallDtmfCreateResponse.json" />
<Content Include="Mocks\liveCallGetResponse.json" />
<Content Include="Mocks\queuedCallGetResponse.json" />
<Content Include="Mocks\liveCallListGetResponse.json" />
<Content Include="Mocks\liveCallPlayCreateResponse.json" />
<Content Include="Mocks\liveCallRecordCreateResponse.json" />
Expand Down
61 changes: 61 additions & 0 deletions tests/Plivo.Test/Resources/TestCall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,67 @@ public void TestLiveCallGet()
AssertRequest(request);
}

[Test]
public void TestQueuedCallList()
{
var request =
new PlivoRequest(
"GET",
"Account/MAXXXXXXXXXXXXXXXXXX/Call/",
"",
new Dictionary<string, object>()
{
{"status", "queued"}
});

var response =
System.IO.File.ReadAllText(
SOURCE_DIR + @"Mocks/liveCallListGetResponse.json"
);
Setup<QueuedCallListResponse>(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<string, object>()
{
{"status", "queued"}
});

var response =
System.IO.File.ReadAllText(
SOURCE_DIR + @"Mocks/queuedCallGetResponse.json"
);
Assert.IsNotEmpty(response);

Setup<QueuedCall>(200, response);

Assert.IsEmpty(
ComparisonUtilities.Compare(
response,
Api.Call.GetQueued(id)
)
);

AssertRequest(request);
}

[Test]
public void TestCallTranfer()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
}
61 changes: 61 additions & 0 deletions tests_netcore/Plivo.NetCore.Test/Resources/TestCall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,35 @@ public void TestLiveCallList()
AssertRequest(request);
}

[Fact]
public void TestQueuedCallList()
{
var request =
new PlivoRequest(
"GET",
"Account/MAXXXXXXXXXXXXXXXXXX/Call/",
"",
new Dictionary<string, object>()
{
{"status", "queued"}
});

var response =
System.IO.File.ReadAllText(
SOURCE_DIR + @"../Mocks/liveCallListGetResponse.json"
);
Setup<QueuedCallListResponse>(200, response);

Assert.Empty(
ComparisonUtilities.Compare(
response,
Api.Call.ListQueued()
)
);

AssertRequest(request);
}

[Fact]
public void TestLiveCallGet()
{
Expand Down Expand Up @@ -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<string, object>()
{
{"status", "queued"}
});

var response =
System.IO.File.ReadAllText(
SOURCE_DIR + @"../Mocks/queuedCallGetResponse.json"
);
Assert.NotEmpty(response);

Setup<QueuedCall>(200, response);

Assert.Empty(
ComparisonUtilities.Compare(
response,
Api.Call.GetQueued(id)
)
);

AssertRequest(request);
}

[Fact]
public void TestCallTranfer()
{
Expand Down

0 comments on commit 33ecc04

Please sign in to comment.