Some work around the Auto Updater and other small changes #1460 #865

This commit is contained in:
Jamie.Rees 2017-07-27 08:13:43 +01:00
commit 863df6e1cc
26 changed files with 303 additions and 23 deletions

View file

@ -0,0 +1,10 @@
using System.Threading.Tasks;
using Ombi.Api.Service.Models;
namespace Ombi.Api.Service
{
public interface IOmbiService
{
Task<Updates> GetUpdates(string branch);
}
}

View file

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Ombi.Api.Service.Models
{
public class Updates
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("updateVersionString")]
public string UpdateVersionString { get; set; }
[JsonProperty("updateVersion")]
public int UpdateVersion { get; set; }
[JsonProperty("updateDate")]
public DateTime UpdateDate { get; set; }
[JsonProperty("changeLogs")]
public List<Changelog> ChangeLogs { get; set; }
[JsonProperty("downloads")]
public List<Download> Downloads { get; set; }
}
public class Changelog
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("descripion")]
public string Descripion { get; set; }
[JsonProperty("updateId")]
public int UpdateId { get; set; }
}
public class Download
{
[JsonProperty("id")]
public int Id { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("url")]
public string Url { get; set; }
[JsonProperty("updateId")]
public int UpdateId { get; set; }
}
}

View file

@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
<AssemblyName>Ombi.Api.Service</AssemblyName>
<RootNamespace>Ombi.Api.Service</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Options" Version="1.1.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Ombi.Api\Ombi.Api.csproj" />
<ProjectReference Include="..\Ombi.Helpers\Ombi.Helpers.csproj" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,33 @@
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Ombi.Api.Service.Models;
using Ombi.Helpers;
namespace Ombi.Api.Service
{
public class OmbiService : IOmbiService
{
public OmbiService(IOptions<ApplicationSettings> settings, IApi api, ILogger<OmbiService> log)
{
Settings = settings.Value;
Api = api;
Logger = log;
}
private ApplicationSettings Settings { get; }
private ILogger<OmbiService> Logger { get; }
private IApi Api { get; }
public async Task<Updates> GetUpdates(string branch)
{
var request = new Request($"api/update/{branch}", Settings.OmbiService, HttpMethod.Get);
request.ContentHeaders.Add(new KeyValuePair<string, string>("Content-Type", "application/json"));
return await Api.Request<Updates>(request);
}
}
}