2017-09-04 02:20:56 +00:00
|
|
|
|
using NzbDrone.Core.Download;
|
|
|
|
|
|
2017-10-31 01:28:29 +00:00
|
|
|
|
namespace Lidarr.Api.V1.DownloadClient
|
2017-09-04 02:20:56 +00:00
|
|
|
|
{
|
2021-04-26 20:56:39 +00:00
|
|
|
|
public class DownloadClientResource : ProviderResource<DownloadClientResource>
|
2017-09-04 02:20:56 +00:00
|
|
|
|
{
|
|
|
|
|
public bool Enable { get; set; }
|
2022-07-19 20:08:53 +00:00
|
|
|
|
public string Protocol { get; set; }
|
2019-05-29 23:42:34 +00:00
|
|
|
|
public int Priority { get; set; }
|
2021-11-24 16:58:51 +00:00
|
|
|
|
public bool RemoveCompletedDownloads { get; set; }
|
|
|
|
|
public bool RemoveFailedDownloads { get; set; }
|
2017-09-04 02:20:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DownloadClientResourceMapper : ProviderResourceMapper<DownloadClientResource, DownloadClientDefinition>
|
|
|
|
|
{
|
|
|
|
|
public override DownloadClientResource ToResource(DownloadClientDefinition definition)
|
|
|
|
|
{
|
2020-01-03 12:49:24 +00:00
|
|
|
|
if (definition == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2017-09-04 02:20:56 +00:00
|
|
|
|
|
|
|
|
|
var resource = base.ToResource(definition);
|
|
|
|
|
|
|
|
|
|
resource.Enable = definition.Enable;
|
|
|
|
|
resource.Protocol = definition.Protocol;
|
2019-05-29 23:42:34 +00:00
|
|
|
|
resource.Priority = definition.Priority;
|
2021-11-24 16:58:51 +00:00
|
|
|
|
resource.RemoveCompletedDownloads = definition.RemoveCompletedDownloads;
|
|
|
|
|
resource.RemoveFailedDownloads = definition.RemoveFailedDownloads;
|
2017-09-04 02:20:56 +00:00
|
|
|
|
|
|
|
|
|
return resource;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-24 03:41:50 +00:00
|
|
|
|
public override DownloadClientDefinition ToModel(DownloadClientResource resource, DownloadClientDefinition existingDefinition)
|
2017-09-04 02:20:56 +00:00
|
|
|
|
{
|
2020-01-03 12:49:24 +00:00
|
|
|
|
if (resource == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2017-09-04 02:20:56 +00:00
|
|
|
|
|
2022-05-24 03:41:50 +00:00
|
|
|
|
var definition = base.ToModel(resource, existingDefinition);
|
2017-09-04 02:20:56 +00:00
|
|
|
|
|
|
|
|
|
definition.Enable = resource.Enable;
|
|
|
|
|
definition.Protocol = resource.Protocol;
|
2019-05-29 23:42:34 +00:00
|
|
|
|
definition.Priority = resource.Priority;
|
2021-11-24 16:58:51 +00:00
|
|
|
|
definition.RemoveCompletedDownloads = resource.RemoveCompletedDownloads;
|
|
|
|
|
definition.RemoveFailedDownloads = resource.RemoveFailedDownloads;
|
2017-09-04 02:20:56 +00:00
|
|
|
|
|
|
|
|
|
return definition;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-03 12:49:24 +00:00
|
|
|
|
}
|