Added the Movie Sender, Movies will be sent to Radarr now #865

This commit is contained in:
Jamie.Rees 2017-06-07 15:07:41 +01:00
parent 2c4ef05af1
commit 4c797733ca
13 changed files with 223 additions and 59 deletions

View file

@ -13,7 +13,7 @@ namespace Ombi.Api
{
NullValueHandling = NullValueHandling.Ignore
};
public async Task<T> Request<T>(Request request)
{
using (var httpClient = new HttpClient())
@ -30,7 +30,7 @@ namespace Ombi.Api
foreach (var header in request.Headers)
{
httpRequestMessage.Headers.Add(header.Key, header.Value);
}
using (var httpResponseMessage = await httpClient.SendAsync(httpRequestMessage))
{
@ -60,6 +60,38 @@ namespace Ombi.Api
}
}
public async Task<string> Request(Request request)
{
using (var httpClient = new HttpClient())
{
using (var httpRequestMessage = new HttpRequestMessage(request.HttpMethod, request.FullUri))
{
// Add the Json Body
if (request.JsonBody != null)
{
httpRequestMessage.Content = new JsonContent(request.JsonBody);
}
// Add headers
foreach (var header in request.Headers)
{
httpRequestMessage.Headers.Add(header.Key, header.Value);
}
using (var httpResponseMessage = await httpClient.SendAsync(httpRequestMessage))
{
if (!httpResponseMessage.IsSuccessStatusCode)
{
// Logging
}
// do something with the response
var data = httpResponseMessage.Content;
return await data.ReadAsStringAsync();
}
}
}
}
}
}