mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-14 02:26:55 -07:00
parent
5c72d585f4
commit
863df6e1cc
26 changed files with 303 additions and 23 deletions
10
src/Ombi.Api.Service/IOmbiService.cs
Normal file
10
src/Ombi.Api.Service/IOmbiService.cs
Normal 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);
|
||||
}
|
||||
}
|
47
src/Ombi.Api.Service/Models/Updates.cs
Normal file
47
src/Ombi.Api.Service/Models/Updates.cs
Normal 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; }
|
||||
}
|
||||
}
|
18
src/Ombi.Api.Service/Ombi.Api.Service.csproj
Normal file
18
src/Ombi.Api.Service/Ombi.Api.Service.csproj
Normal 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>
|
33
src/Ombi.Api.Service/OmbiService.cs
Normal file
33
src/Ombi.Api.Service/OmbiService.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue