mirror of
https://github.com/fergalmoran/Readarr.git
synced 2026-01-06 00:36:58 +00:00
Change API Version from V3 to V1
This commit is contained in:
63
src/Lidarr.Api.V1/Profiles/Delay/DelayProfileResource.cs
Normal file
63
src/Lidarr.Api.V1/Profiles/Delay/DelayProfileResource.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.Profiles.Delay;
|
||||
using Lidarr.Http.REST;
|
||||
|
||||
namespace Lidarr.Api.V1.Profiles.Delay
|
||||
{
|
||||
public class DelayProfileResource : RestResource
|
||||
{
|
||||
public bool EnableUsenet { get; set; }
|
||||
public bool EnableTorrent { get; set; }
|
||||
public DownloadProtocol PreferredProtocol { get; set; }
|
||||
public int UsenetDelay { get; set; }
|
||||
public int TorrentDelay { get; set; }
|
||||
public int Order { get; set; }
|
||||
public HashSet<int> Tags { get; set; }
|
||||
}
|
||||
|
||||
public static class DelayProfileResourceMapper
|
||||
{
|
||||
public static DelayProfileResource ToResource(this DelayProfile model)
|
||||
{
|
||||
if (model == null) return null;
|
||||
|
||||
return new DelayProfileResource
|
||||
{
|
||||
Id = model.Id,
|
||||
|
||||
EnableUsenet = model.EnableUsenet,
|
||||
EnableTorrent = model.EnableTorrent,
|
||||
PreferredProtocol = model.PreferredProtocol,
|
||||
UsenetDelay = model.UsenetDelay,
|
||||
TorrentDelay = model.TorrentDelay,
|
||||
Order = model.Order,
|
||||
Tags = new HashSet<int>(model.Tags)
|
||||
};
|
||||
}
|
||||
|
||||
public static DelayProfile ToModel(this DelayProfileResource resource)
|
||||
{
|
||||
if (resource == null) return null;
|
||||
|
||||
return new DelayProfile
|
||||
{
|
||||
Id = resource.Id,
|
||||
|
||||
EnableUsenet = resource.EnableUsenet,
|
||||
EnableTorrent = resource.EnableTorrent,
|
||||
PreferredProtocol = resource.PreferredProtocol,
|
||||
UsenetDelay = resource.UsenetDelay,
|
||||
TorrentDelay = resource.TorrentDelay,
|
||||
Order = resource.Order,
|
||||
Tags = new HashSet<int>(resource.Tags)
|
||||
};
|
||||
}
|
||||
|
||||
public static List<DelayProfileResource> ToResource(this IEnumerable<DelayProfile> models)
|
||||
{
|
||||
return models.Select(ToResource).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user