mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
This commit is contained in:
parent
9e004dc57b
commit
1c301f2c54
26 changed files with 522 additions and 12 deletions
29
Ombi/Ombi.Api/Api.cs
Normal file
29
Ombi/Ombi.Api/Api.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue