1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-15 07:22:35 +01:00
Radarr/NzbDrone.Core/Update/UpdatePackageProvider.cs
2013-09-11 17:42:53 -07:00

33 lines
933 B
C#

using System;
using NzbDrone.Common;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Configuration;
using RestSharp;
using NzbDrone.Core.Rest;
namespace NzbDrone.Core.Update
{
public interface IUpdatePackageProvider
{
UpdatePackage GetLatestUpdate(string branch, Version currentVersion);
}
public class UpdatePackageProvider : IUpdatePackageProvider
{
public UpdatePackage GetLatestUpdate(string branch, Version currentVersion)
{
var restClient = new RestClient(Services.RootUrl);
var request = new RestRequest("/v1/update/{branch}");
request.AddParameter("version", currentVersion);
request.AddUrlSegment("branch", branch);
var update = restClient.ExecuteAndValidate<UpdatePackageAvailable>(request);
if (!update.Available) return null;
return update.UpdatePackage;
}
}
}