import abc from app.dsp.enums import DSPId from app.dsp.types import ( FollowedArtistsResult, PlaylistsResult, ProfileResult, RecentlyPlayedResult, SavedAlbumsResult, SavedTracksResult, TokenResult, TopArtistsResult, TopTracksResult, ) class DSPBackend(abc.ABC): dsp_id: DSPId def close(self) -> None: # noqa: B027 """Release any resources held by the DSP backend.""" def __enter__(self) -> DSPBackend: return self def __exit__(self, *_: object) -> None: self.close() @abc.abstractmethod def refresh_token(self, refresh_token: str) -> TokenResult: """Refresh OAuth token.""" @abc.abstractmethod def get_profile(self, access_token: str) -> ProfileResult: """Fetch profile data for the authenticated user.""" @abc.abstractmethod def get_top_artists(self, access_token: str) -> TopArtistsResult: """Fetch top artists for the authenticated user.""" @abc.abstractmethod def get_top_tracks(self, access_token: str) -> TopTracksResult: """Fetch top tracks for the authenticated user.""" @abc.abstractmethod def get_recently_played( self, access_token: str, *, after: int | None = None ) -> RecentlyPlayedResult: """Fetch recently played tracks for the authenticated user.""" @abc.abstractmethod def get_playlists(self, access_token: str) -> PlaylistsResult: """Fetch playlists for the authenticated user.""" @abc.abstractmethod def get_saved_albums(self, access_token: str) -> SavedAlbumsResult: """Fetch saved albums for the authenticated user.""" @abc.abstractmethod def get_saved_tracks(self, access_token: str) -> SavedTracksResult: """Fetch saved tracks for the authenticated user.""" @abc.abstractmethod def get_followed_artists(self, access_token: str) -> FollowedArtistsResult: """Fetch followed artists for the authenticated user."""