From c77566fc43378a0b6c039d97d567d548182e05e4 Mon Sep 17 00:00:00 2001 From: Michael Feinbier Date: Sun, 17 Sep 2023 11:14:37 +0200 Subject: [PATCH] Restructure responses and remove File entity File does not exist on Put.io API anymore --- .../PutioTests/PutioFixture.cs | 9 --------- src/NzbDrone.Core/Download/Clients/Putio/Putio.cs | 15 ++++++++------- .../Download/Clients/Putio/PutioFile.cs | 8 -------- .../Download/Clients/Putio/PutioFileResponse.cs | 7 ------- .../Download/Clients/Putio/PutioPriority.cs | 8 -------- .../Download/Clients/Putio/PutioProxy.cs | 14 ++------------ .../{PutioGenericResponse.cs => PutioResponse.cs} | 8 +++++++- .../Clients/Putio/PutioTransfersResponse.cs | 8 -------- 8 files changed, 17 insertions(+), 60 deletions(-) delete mode 100644 src/NzbDrone.Core/Download/Clients/Putio/PutioFile.cs delete mode 100644 src/NzbDrone.Core/Download/Clients/Putio/PutioFileResponse.cs delete mode 100644 src/NzbDrone.Core/Download/Clients/Putio/PutioPriority.cs rename src/NzbDrone.Core/Download/Clients/Putio/{PutioGenericResponse.cs => PutioResponse.cs} (56%) delete mode 100644 src/NzbDrone.Core/Download/Clients/Putio/PutioTransfersResponse.cs diff --git a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PutioTests/PutioFixture.cs b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PutioTests/PutioFixture.cs index 54607677e..9cad2262a 100644 --- a/src/NzbDrone.Core.Test/Download/DownloadClientTests/PutioTests/PutioFixture.cs +++ b/src/NzbDrone.Core.Test/Download/DownloadClientTests/PutioTests/PutioFixture.cs @@ -137,15 +137,6 @@ namespace NzbDrone.Core.Test.Download.DownloadClientTests.PutioTests .Returns(torrents); } - protected virtual void GivenFile(PutioFile file) - { - file ??= new PutioFile(); - - Mocker.GetMock() - .Setup(s => s.GetFile(file.Id, It.IsAny())) - .Returns(file); - } - [Test] public void getItems_contains_all_items() { diff --git a/src/NzbDrone.Core/Download/Clients/Putio/Putio.cs b/src/NzbDrone.Core/Download/Clients/Putio/Putio.cs index 0f43f90d1..f211bf3bd 100644 --- a/src/NzbDrone.Core/Download/Clients/Putio/Putio.cs +++ b/src/NzbDrone.Core/Download/Clients/Putio/Putio.cs @@ -18,13 +18,14 @@ namespace NzbDrone.Core.Download.Clients.Putio { private readonly IPutioProxy _proxy; - public Putio(IPutioProxy proxy, - ITorrentFileInfoReader torrentFileInfoReader, - IHttpClient httpClient, - IConfigService configService, - IDiskProvider diskProvider, - IRemotePathMappingService remotePathMappingService, - Logger logger) + public Putio( + IPutioProxy proxy, + ITorrentFileInfoReader torrentFileInfoReader, + IHttpClient httpClient, + IConfigService configService, + IDiskProvider diskProvider, + IRemotePathMappingService remotePathMappingService, + Logger logger) : base(torrentFileInfoReader, httpClient, configService, diskProvider, remotePathMappingService, logger) { _proxy = proxy; diff --git a/src/NzbDrone.Core/Download/Clients/Putio/PutioFile.cs b/src/NzbDrone.Core/Download/Clients/Putio/PutioFile.cs deleted file mode 100644 index f8de1733f..000000000 --- a/src/NzbDrone.Core/Download/Clients/Putio/PutioFile.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NzbDrone.Core.Download.Clients.Putio -{ - public class PutioFile - { - public long Id { get; set; } - public string Name { get; set; } - } -} diff --git a/src/NzbDrone.Core/Download/Clients/Putio/PutioFileResponse.cs b/src/NzbDrone.Core/Download/Clients/Putio/PutioFileResponse.cs deleted file mode 100644 index 8bd40351e..000000000 --- a/src/NzbDrone.Core/Download/Clients/Putio/PutioFileResponse.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace NzbDrone.Core.Download.Clients.Putio -{ - public class PutioFileResponse : PutioGenericResponse - { - public PutioFile File { get; set; } - } -} diff --git a/src/NzbDrone.Core/Download/Clients/Putio/PutioPriority.cs b/src/NzbDrone.Core/Download/Clients/Putio/PutioPriority.cs deleted file mode 100644 index e5e69b121..000000000 --- a/src/NzbDrone.Core/Download/Clients/Putio/PutioPriority.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace NzbDrone.Core.Download.Clients.Putio -{ - public enum PutioPriority - { - Last = 0, - First = 1 - } -} diff --git a/src/NzbDrone.Core/Download/Clients/Putio/PutioProxy.cs b/src/NzbDrone.Core/Download/Clients/Putio/PutioProxy.cs index 26f2f922c..c12878567 100644 --- a/src/NzbDrone.Core/Download/Clients/Putio/PutioProxy.cs +++ b/src/NzbDrone.Core/Download/Clients/Putio/PutioProxy.cs @@ -10,7 +10,6 @@ namespace NzbDrone.Core.Download.Clients.Putio public interface IPutioProxy { List GetTorrents(PutioSettings settings); - PutioFile GetFile(long fileId, PutioSettings settings); void AddTorrentFromUrl(string torrentUrl, PutioSettings settings); void AddTorrentFromData(byte[] torrentData, PutioSettings settings); void RemoveTorrent(string hash, PutioSettings settings); @@ -30,16 +29,8 @@ namespace NzbDrone.Core.Download.Clients.Putio public List GetTorrents(PutioSettings settings) { - // var result = ProcessRequest(Method.GET, "transfers/list", null, settings); - // return result.Transfers; - return new List(); - } - - public PutioFile GetFile(long fileId, PutioSettings settings) - { - // var result = ProcessRequest(Method.GET, "files/" + fileId, null, settings); - // return result.File; - return new PutioFile(); + var result = Execute(BuildRequest(HttpMethod.Get, "transfers/list", settings)); + return result.Resource.Transfers; } public void AddTorrentFromUrl(string torrentUrl, PutioSettings settings) @@ -65,7 +56,6 @@ namespace NzbDrone.Core.Download.Clients.Putio public void GetAccountSettings(PutioSettings settings) { - // ProcessRequest(Method.GET, "account/settings", null, settings); Execute(BuildRequest(HttpMethod.Get, "account/settings", settings)); } diff --git a/src/NzbDrone.Core/Download/Clients/Putio/PutioGenericResponse.cs b/src/NzbDrone.Core/Download/Clients/Putio/PutioResponse.cs similarity index 56% rename from src/NzbDrone.Core/Download/Clients/Putio/PutioGenericResponse.cs rename to src/NzbDrone.Core/Download/Clients/Putio/PutioResponse.cs index 4e0624fb9..b92df4441 100644 --- a/src/NzbDrone.Core/Download/Clients/Putio/PutioGenericResponse.cs +++ b/src/NzbDrone.Core/Download/Clients/Putio/PutioResponse.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using System.Collections.Generic; +using Newtonsoft.Json; namespace NzbDrone.Core.Download.Clients.Putio { @@ -9,4 +10,9 @@ namespace NzbDrone.Core.Download.Clients.Putio public string Status { get; set; } } + + public class PutioTransfersResponse : PutioGenericResponse + { + public List Transfers { get; set; } + } } diff --git a/src/NzbDrone.Core/Download/Clients/Putio/PutioTransfersResponse.cs b/src/NzbDrone.Core/Download/Clients/Putio/PutioTransfersResponse.cs deleted file mode 100644 index d54d6a5ff..000000000 --- a/src/NzbDrone.Core/Download/Clients/Putio/PutioTransfersResponse.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System.Collections.Generic; -namespace NzbDrone.Core.Download.Clients.Putio -{ - public class PutioTransfersResponse : PutioGenericResponse - { - public List Transfers { get; set; } - } -}