using Musify.Application.Contracts; using Musify.Domain.ValueObjects; namespace Musify.Application.Albums.Responses { /// One item of a combined local/external album listing. Exactly one of /// or is populated: for /// anything already in the catalog (locally created albums and external albums materialized /// earlier), for a live external search hit that hasn't been /// materialized yet, so it has no album id. public record AlbumSearchItemResponse( TrackSource Source, AlbumApplicationResponse? Album, YouTubeAlbumResult? YouTubeAlbum) { public static AlbumSearchItemResponse FromAlbum(AlbumApplicationResponse album) => new(album is ExternalAlbumApplicationResponse ? TrackSource.YouTube : TrackSource.Local, album, null); public static AlbumSearchItemResponse FromYouTubeAlbum(YouTubeAlbumResult album) => new(TrackSource.YouTube, null, album); } }