2013-05-20 00:30:02 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using NzbDrone.Api.REST;
|
|
|
|
|
using NzbDrone.Core.Update;
|
|
|
|
|
using NzbDrone.Api.Mapping;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Update
|
|
|
|
|
{
|
|
|
|
|
public class UpdateModule : NzbDroneRestModule<UpdateResource>
|
|
|
|
|
{
|
2013-06-28 00:04:52 +00:00
|
|
|
|
private readonly ICheckUpdateService _checkUpdateService;
|
2013-05-20 00:30:02 +00:00
|
|
|
|
|
2013-06-28 00:04:52 +00:00
|
|
|
|
public UpdateModule(ICheckUpdateService checkUpdateService)
|
2013-05-20 00:30:02 +00:00
|
|
|
|
{
|
2013-06-28 00:04:52 +00:00
|
|
|
|
_checkUpdateService = checkUpdateService;
|
2013-05-20 00:30:02 +00:00
|
|
|
|
GetResourceAll = GetAvailableUpdate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<UpdateResource> GetAvailableUpdate()
|
|
|
|
|
{
|
2013-06-28 00:04:52 +00:00
|
|
|
|
var update = _checkUpdateService.AvailableUpdate();
|
2013-05-20 00:30:02 +00:00
|
|
|
|
var response = new List<UpdateResource>();
|
|
|
|
|
|
|
|
|
|
if (update != null)
|
|
|
|
|
{
|
|
|
|
|
response.Add(update.InjectTo<UpdateResource>());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class UpdateResource : RestResource
|
|
|
|
|
{
|
|
|
|
|
public Version Version { get; set; }
|
|
|
|
|
public String FileName { get; set; }
|
|
|
|
|
public String Url { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|