You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Readarr/src/NzbDrone.Core/Update/UpdatePackageProvider.cs

46 lines
1.3 KiB

using System;
using System.Collections.Generic;
using NzbDrone.Common;
11 years ago
using RestSharp;
using NzbDrone.Core.Rest;
namespace NzbDrone.Core.Update
{
public interface IUpdatePackageProvider
{
11 years ago
UpdatePackage GetLatestUpdate(string branch, Version currentVersion);
List<UpdatePackage> GetRecentUpdates(string branch);
}
public class UpdatePackageProvider : IUpdatePackageProvider
{
11 years ago
public UpdatePackage GetLatestUpdate(string branch, Version currentVersion)
{
11 years ago
var restClient = new RestClient(Services.RootUrl);
11 years ago
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;
}
public List<UpdatePackage> GetRecentUpdates(string branch)
{
var restClient = new RestClient(Services.RootUrl);
var request = new RestRequest("/v1/update/{branch}/changes");
request.AddUrlSegment("branch", branch);
var updates = restClient.ExecuteAndValidate<List<UpdatePackage>>(request);
return updates;
}
}
}