using RadarrSharp.Services.Interface; using RadarrSharp.Models; using System; using System.Collections.Generic; using System.Linq; using RadarrSharp.Helpers; using System.Threading.Tasks; using System.Web; namespace RadarrSharp.Services.Implementation { public class MovieService : BaseRadarrService, IMovieService { public MovieService(string ip, string port, string apiKey) : base(ip, port, apiKey) { } public async Task> GetMovies(string tmdbId = null) { var movies = await base.GetAsync>("movie", tmdbId.ToTuple("tmdbId").ToList()); return movies; } public async Task AddMovie(Movie movie) { var resp = await base.PostAsync("movie", movie); return resp; } public async Task PutMovie(Movie movie, bool moveFiles) { var resp = await base.PutAsync("movie", movie, moveFiles.ToTuple("moveFiles").ToList()); return resp; } public async Task> GetMovie(int id) { var movies = await base.GetAsync>($"movie/{id}"); return movies; } public async Task DeleteMovie(int id, bool addImportExclusion, bool deleteFiles) { var responseMessage = await base.DeleteAsync($"movie/{id}", RadarrExtensions.ParamList( addImportExclusion.ToTuple("addImportExclusion"), deleteFiles.ToTuple("deleteFiles"))); return responseMessage.IsSuccessStatusCode; } public async Task> MovieLookup(string searchTerm) { searchTerm = HttpUtility.UrlEncode(searchTerm); var movies = await base.GetAsync>("movie/lookup", searchTerm.ToTuple("term").ToList()); return movies; } } }