c# - Twilio total call duration does not match with billing minutes -
in attached image , total voice minutes july 30 minutes. if pull call logs same month july 2014 (using instruction in https://www.twilio.com/docs/api/rest/call) , total duration 17 minutes. shouldn't value of usage , total call duration in log equal ?.
here test source code finding call log files month july 2014. 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 round calls nearest minute. should same. this:
voiceminutes += (call.duration + 60)/ 60;
and then:
console.writeline("total voice:" + int.parse ((voiceminutes).tostring() ));
Comments
Post a Comment