using SWAD.API.Consts.Enums;
using SWAD.API.Controllers.DTOs;
using SWAD.API.Models.Config.ApiServices.Structure;
namespace SWAD.API.Services.MusicAPI.Api;
///
/// Abstract ApiService of music services
///
public abstract class ApiService
{
public ApiServiceData Config { get; protected init; } = null!;
public MusicService ServiceType { get; protected init; }
public abstract Task GetLinkByQuery(TrackDto query);
public abstract Task GetQueryObject(string link, string CountryCode = "US");
protected string GetQuery(TrackDto dto) => $"{dto.Name} - {dto.Artist}";
///
/// Get all implemented API Services
///
/// API Services types
public static IEnumerable GetAllImplementations()
{
var type = typeof(ApiService);
var types = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(s => s.GetTypes())
.Where(p => type.IsAssignableFrom(p) && !p.IsInterface && !p.IsAbstract);
return types;
}
protected struct Messages
{
public const string AuthFailMessage = "Update token request for service {0} failed";
}
}