/// <summary> /// Fetches a genre by its ID. /// </summary> /// <param name="genreId">Genre ID</param> /// <param name="onSuccess">On success</param> /// <param name="onFailure">On failure</param> /// <param name="onError">On error</param> public static void FetchById(int genreId, Action <Genre> onSuccess, Action <NetworkResponse> onFailure, Action onError) { RestSharpTools.GetAsync <Genre>("/genre/" + genreId, null, JSON_EQUIVALENTS, (response) => { onSuccess(response.Model); }, (errorResponse) => { onFailure?.Invoke(errorResponse); }, () => { Console.WriteLine("Exception@Genre->FetchById()"); onError(); }); }
/// <summary> /// Fetches an artist by its ID. /// </summary> /// <param name="artistId">Artist ID</param> /// <param name="onSuccess">On success</param> /// <param name="onFailure">On failure</param> /// <param name="onError">On error</param> public static void FetchById(int artistId, Action <Artist> onSuccess, Action <NetworkResponse> onFailure, Action onError) { RestSharpTools.GetAsync <Artist>("/artist/" + artistId, null, JSON_EQUIVALENTS, (response) => { onSuccess(response.Model); }, (errorResponse) => { onFailure?.Invoke(errorResponse); }, () => { Console.WriteLine("Exception@Artist->FetchById()"); onError?.Invoke(); }); }
/// <summary> /// Fetches an active subscription. /// </summary> /// <param name="onSuccess">On success</param> /// <param name="onFailure">On failure</param> /// <param name="onError">On error</param> /// <param name="onFinish">It's executed at the end of every case</param> public void FetchSubscription(Action <Subscription> onSuccess, Action <NetworkResponse> onFailure, Action onError, Action onFinish = null) { RestSharpTools.GetAsync <Subscription>("/subscription", null, Subscription.JSON_EQUIVALENTS, (response) => { onSuccess(response.Model); onFinish?.Invoke(); }, (errorResponse) => { onFailure?.Invoke(errorResponse); onFinish?.Invoke(); }, () => { Console.WriteLine("Exception@Account->FetchSubscription()"); onError?.Invoke(); onFinish?.Invoke(); }); }
/// <summary> /// Checks if the song is in this playlist. /// </summary> /// <param name="song">Song to check</param> /// <param name="onSuccess">On success</param> /// <param name="onFailure">On failure</param> /// <param name="onError">On error</param> public void ContainsSong(Song song, Action onSuccess, Action <NetworkResponse> onFailure, Action onError) { RestSharpTools.GetAsync <Song>( "/playlist/" + PlaylistId + "/songs/" + song.SongId, null, Song.JSON_EQUIVALENTS, (response) => { onSuccess(); }, (errorResponse) => { onFailure?.Invoke(errorResponse); }, () => { Console.WriteLine("Exception@Playlist->ContainsSong()"); onError(); } ); }
/// <summary> /// Fetches a account song by its ID. /// </summary> /// <param name="SongId">Song ID</param> /// <param name="onSuccess">On success</param> /// <param name="onFailure">On failure</param> /// <param name="onError">On error</param> public static void FetchById(int accountSongId, Action <AccountSong> onSuccess, Action <NetworkResponse> onFailure, Action onError) { RestSharpTools.GetAsync <AccountSong>( "/account/" + Session.Account.AccountId + "/accountsong/" + accountSongId, null, JSON_EQUIVALENTS, (response) => { onSuccess(response.Model); }, (errorResponse) => { onFailure?.Invoke(errorResponse); }, () => { Console.WriteLine("Exception@Song->FetchById()"); onError?.Invoke(); } ); }
/// <summary> /// Checks if song was disliked before. /// </summary> /// <param name="song">Song</param> /// <param name="onSuccess">On success</param> /// <param name="onFailure">On failure</param> /// <param name="onError">On error</param> public void HasDislikedSong(Song song, Action onSuccess, Action <NetworkResponse> onFailure, Action onError) { var data = new { account_id = AccountId }; RestSharpTools.GetAsync("/song/" + song.SongId + "/songdislike", data, (response) => { onSuccess(); }, (errorResponse) => { onFailure?.Invoke(errorResponse); }, () => { Console.WriteLine("Exception@Account->HasDislikedSong()"); onError?.Invoke(); }); }
/// <summary> /// Fetches artist data attached to this account. /// </summary> /// <param name="onSuccess">On success</param> /// <param name="onFailure">On failure</param> /// <param name="onError">On error</param> /// <param name="onFinish">It's executed at the end of every case</param> public void FetchArtist(Action onSuccess, Action <NetworkResponse> onFailure, Action onError, Action onFinish = null) { RestSharpTools.GetAsync <Artist>("/account/" + AccountId + "/artist", null, Artist.JSON_EQUIVALENTS, (response) => { this.Artist = response.Model; onSuccess(); onFinish?.Invoke(); }, (errorResponse) => { onFailure?.Invoke(errorResponse); onFinish?.Invoke(); }, () => { Console.WriteLine("Exception@Account->FetchArtist()"); onError(); onFinish?.Invoke(); }); }
/// <summary> /// Fetches a song by its ID. /// </summary> /// <param name="SongId">Song ID</param> /// <param name="onSuccess">On success</param> /// <param name="onFailure">On failure</param> /// <param name="onError">On error</param> public static void FetchById(int songId, Action <Song> onSuccess, Action <NetworkResponse> onFailure, Action onError) { RestSharpTools.GetAsync <Song>("/song/" + songId, null, JSON_EQUIVALENTS, (response) => { Album.FetchById(response.Model.AlbumId, (album) => { response.Model.Album = album; Genre.FetchById(response.Model.GenreId, (genre) => { response.Model.Genre = genre; response.Model.FetchArtists(() => { onSuccess(response.Model); }, null, null); }, null, null); }, null, null); }, (errorResponse) => { onFailure?.Invoke(errorResponse); }, () => { Console.WriteLine("Exception@Song->FetchById()"); onError?.Invoke(); }); }