chore: init commit from GitHub
This commit is contained in:
35
SWAD.API/Services/MusicAPI/Api/ApiService.cs
Normal file
35
SWAD.API/Services/MusicAPI/Api/ApiService.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using SWAD.API.Consts.Enums;
|
||||
using SWAD.API.Controllers.DTOs;
|
||||
using SWAD.API.Models.Config.ApiServices.Structure;
|
||||
|
||||
namespace SWAD.API.Services.MusicAPI.Api;
|
||||
|
||||
/// <summary>
|
||||
/// Abstract ApiService of music services
|
||||
/// </summary>
|
||||
public abstract class ApiService
|
||||
{
|
||||
public ApiServiceData Config { get; protected init; } = null!;
|
||||
public MusicService ServiceType { get; protected init; }
|
||||
public abstract Task<string?> GetLinkByQuery(TrackDto query);
|
||||
public abstract Task<TrackDto> GetQueryObject(string link, string CountryCode = "US");
|
||||
protected string GetQuery(TrackDto dto) => $"{dto.Name} - {dto.Artist}";
|
||||
|
||||
/// <summary>
|
||||
/// Get all implemented API Services
|
||||
/// </summary>
|
||||
/// <returns>API Services types</returns>
|
||||
public static IEnumerable<Type> 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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user