This commit is contained in:
tidusjar 2017-04-04 23:07:13 +01:00
commit 1c301f2c54
26 changed files with 522 additions and 12 deletions

29
Ombi/Ombi.Api/Api.cs Normal file
View file

@ -0,0 +1,29 @@
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Ombi.Api
{
public class Api
{
public static JsonSerializerSettings Settings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
};
public async Task<T> Get<T>(Uri uri)
{
var h = new HttpClient();
var response = await h.GetAsync(uri);
if (!response.IsSuccessStatusCode)
{
// Logging
}
var receiveString = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<T>(receiveString, Settings);
}
}
}