public async Task<MonitorInformation> GetMonitorInformationAsync(List<int> rblList, IHttpClient client=null)
{
if (null == rblList || !rblList.Any())
{
return new MonitorInformation(MonitorInformationErrorCode.RblNotSpecified);
}
var rbls = String.Join("&", rblList.Select(rbl => String.Format("rbl={0}", rbl)));
var url = String.Format(MonitorApiUrl, rbls, _apiKey, GenerateVrtNoCacheParameterValue());
if (null == client)
client = new DefaultHttpClient();
var response = await client.GetStringAsync(url).ConfigureAwait(false);
if (null == response)
{
return new MonitorInformation(MonitorInformationErrorCode.DownloadingFailed);
}
try
{
return ParseMonitorResponse(response);
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
}
return
new MonitorInformation(MonitorInformationErrorCode.ResponseParsingFailed);
}