In the attached image , the total voice minutes for July is 30 minutes. However if I pull the call logs for the same month July 2014 (using the instruction in https://www.twilio.com/docs/api/rest/call) , I get total duration as 17 minutes. Shouldn't the value of usage and total call duration in Log be equal ?.
Here is my test source code for finding the call log files for month July 2014. Any help is greatly appreciated.
public static void callLogs(string AccountSid, string AuthToken)
{
var twilio = new TwilioRestClient(AccountSid, AuthToken);
var request = new CallListRequest();
request.StartTimeComparison = ComparisonType.GreaterThanOrEqualTo;
request.StartTime = new DateTime(2014, 07, 01);
request.EndTimeComparison = ComparisonType.LessThanOrEqualTo;
request.EndTime = new DateTime(2014, 07, 31);
var calls = twilio.ListCalls(request);
int? voiceMinutes = 0;
decimal? totalCost = 0;
foreach (var call in calls.Calls)
{
if ( call.Price != null)
{
voiceMinutes += call.Duration;
totalCost += call.Price ;
}
Console.WriteLine(call.Price +"-" + call.DateCreated + "-" + call.From + "-" + call.To + "-" + call.Status + "-" + call.Duration );
}
Console.WriteLine("Total Voice:" + int.Parse ((voiceMinutes/60).ToString() ));
Console.WriteLine("Total Cost :" + totalCost);
}
For billing minutes, Twilio will round all calls up to the nearest minute. So you should do the same. Something like this:
voiceMinutes += (call.Duration + 60)/ 60;
And then:
Console.WriteLine("Total Voice:" + int.Parse ((voiceMinutes).ToString() ));