using Ombi.Api; using Ombi.Core.Settings; using Ombi.Core.Settings.Models.External; using System.Threading.Tasks; namespace Ombi.Api.Jellyfin { public class JellyfinApiFactory : IJellyfinApiFactory { private readonly ISettingsService _jellyfinSettings; private readonly IApi _api; // TODO, if we need to derive futher, need to rework public JellyfinApiFactory(ISettingsService jellyfinSettings, IApi api) { _jellyfinSettings = jellyfinSettings; _api = api; } public async Task CreateClient() { var settings = await _jellyfinSettings.GetSettingsAsync(); return CreateClient(settings); } public IJellyfinApi CreateClient(JellyfinSettings settings) { return new JellyfinApi(_api); } } public interface IJellyfinApiFactory { Task CreateClient(); IJellyfinApi CreateClient(JellyfinSettings settings); } }