Usage Report (Beta)
Service Method
Response (ReportType=1)
<UsageReportResponse>
<isSuccess>true</isSuccess>
<AccountName>Acme Corp</AccountName >
<AccountNumber>1234-5678-9012</AccountNumber >
<ReportType>1</ReportType>
<StartDateUTC>YYYY-MM-DD Thh:mm:ssZ</StartDateUTC>
<EndDateUTC>YYYY-MM-DD Thh:mm:ssZ</EndDateUTC>
<FaxLines>
<FaxLine>
<Name>ABC Fax Line</Name>
<FaxNumber>18881234567</FaxNumber>
<InboundPages>10000</InboundPages>
<OutboundPages>20000<OutboundPages>
<TotalPages>30000</TotalPages>
</FaxLine>
<FaxLine>
<Name>XYZ Fax Line</Name>
<FaxNumber>18889999999</FaxNumber>
<InboundPages>10000</InboundPages>
<OutboundPages>20000<OutboundPages>
<TotalPages>30000</TotalPages>
</FaxLine>
<FaxLine> repeats for each fax number assigned to the API User …
</FaxLines>
</UsageReportResponse >
Sample Code:
//Get Usage Report
private void buttontest_Click(object sender, EventArgs e)
{
var message = new HttpRequestMessage();
string Apikey = WebAPIKey.Text;
string xst = AESCrypto.GenerateSecurityTokenUrl(Username.Text, WebAPIKey.Text, EncryptionKey.Text, "x49e*wJVXr8BrALE", false);
//construct URL
string serviceEndpointUrl = CommonEndPoints.Text;//https://api.sfaxme.com/api/
string methodSignature = "UsageReport";
string token = xst;
string reportType = "1";
string startDateUTC = textBox7.Text.ToString(“yyyy-MM-ddTHH:mm:ssZ”);
string endDateUTC = textBox8.Text.Text.ToString(“yyyy-MM-ddTHH:mm:ssZ”);
// Construct the base service URL endpoint
String url = String.Concat
(
serviceEndpointUrl,
HttpUtility.UrlEncode(methodSignature),
"?",
"token=", HttpUtility.UrlEncode(token),
"&apikey=", HttpUtility.UrlEncode(Apikey),
"&ReportType=", HttpUtility.UrlEncode(reportType),
"&ReportParams=","StartDateUTC=", HttpUtility.UrlEncode(startDateUTC) + ";" + "EndDateUTC=", HttpUtility.UrlEncode(endDateUTC)
);
url = url + "&"; //end of url
Console.WriteLine("URL: " + url);
//construct and make call
message.Method = HttpMethod.Get;
message.RequestUri = new Uri(url);
message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/xml"));
var client = new HttpClient();
var task = client.SendAsync(message).ContinueWith((t) => ResponseUsageFinishedXML(t.Result));
task.Wait();
}
private void ResponseUsageFinishedXML(HttpResponseMessage response)
{
//get response message
var task = response.Content.ReadAsStringAsync().ContinueWith<string>(o =>
{
return o.Result;
});
task.Wait();
string jsonUsageResponseMessageXML = task.Result;
this.BeginInvoke(
(System.Windows.Forms.MethodInvoker)delegate() { textBox14.Text = jsonUsageResponseMessageXML; });
}
}