public async Task<Result<List<ParticleDevice>>> GetDevicesAsync()
{
try
{
var response = await MakeGetRequestWithAuthTestAsync("devices");
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
List<ParticleDevice> items = new List<ParticleDevice>();
await Task.Run(() =>
{
foreach (JObject obj in (JArray)response.Response)
{
items.Add(new ParticleDevice(this, obj));
}
});
return new Result<List<ParticleDevice>>(true, items);
}
else
{
return response.AsResult<List<ParticleDevice>>();
}
}
catch (HttpRequestException re)
{
return new Result<List<ParticleDevice>>(false, new List<ParticleDevice>())
{
Error = re.Message,
Exception = re
};
}
}