#region ========================================================================= USING ===================================================================================== using Nemera.Domain.SharedKernel.Common.Enums.Plugins; using Nemera.Plugins.Contracts.Common.Models.DTO.Settings; using Nemera.Plugins.Contracts.Core.Plugins; using Nemera.Plugins.OpenLibrary.Common.DependencyInjection; using Nemera.Plugins.OpenLibrary.Core.Settings; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; #endregion namespace Nemera.Plugins.OpenLibrary.Core; /// /// Plugin that provides book metadata retrieval from Open Library. /// public sealed class OpenLibraryPlugin : IPlugin, IPluginServiceRegistrator { /// /// The unique identifier of the plugin. /// public static readonly Guid s_pluginId = new("08b17802-7f9c-4c4b-9d7f-b507bbed3e58"); /// /// Gets the unique identifier of the plugin. /// public Guid Id => s_pluginId; /// /// Gets the display name of the plugin. /// public string Name => "Open Library Metadata"; /// /// Gets the author of the plugin. /// public string Author => "Nemera"; /// /// Gets the version of the plugin. /// public Version Version => new(1, 0, 0); /// /// Gets the description of the plugin. /// public string Description => "Retrieves book and edition metadata from Open Library."; /// /// Gets the settings schema of the plugin. /// /// The settings descriptors of the plugin. public IReadOnlyList GetSettingsSchema() { return [ new PluginSettingDescriptorDto( Key: OpenLibrarySettingsKeys.CONTACT_EMAIL, Label: "Contact Email", Type: PluginSettingType.Text), new PluginSettingDescriptorDto( Key: OpenLibrarySettingsKeys.SEARCH_RESULT_LIMIT, Label: "Search Result Limit", Type: PluginSettingType.Number, DefaultValue: "10"), new PluginSettingDescriptorDto( Key: OpenLibrarySettingsKeys.WORK_EDITION_LIMIT, Label: "Work Edition Limit", Type: PluginSettingType.Number, DefaultValue: "50"), new PluginSettingDescriptorDto( Key: OpenLibrarySettingsKeys.MINIMUM_REQUEST_INTERVAL_SECONDS, Label: "Minimum Request Interval (seconds)", Type: PluginSettingType.Number, DefaultValue: "1.1") ]; } /// /// Registers the services required by the plugin. /// /// The service collection to register the services into. public void RegisterServices(IServiceCollection services) { services.AddOpenLibraryBookMetadataProvider(pluginId: Id); } }