2013-07-28 00:07:15 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using IF.Lastfm.Core.Api.Enums;
|
|
|
|
|
using IF.Lastfm.Core.Api.Helpers;
|
|
|
|
|
using IF.Lastfm.Core.Objects;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
|
|
|
|
|
namespace IF.Lastfm.Core.Api.Commands.AlbumApi
|
|
|
|
|
{
|
|
|
|
|
internal class GetAlbumShoutsCommand : GetAsyncCommandBase<PageResponse<Shout>>
|
|
|
|
|
{
|
|
|
|
|
public string AlbumName { get; set; }
|
|
|
|
|
public string ArtistName { get; set; }
|
|
|
|
|
public bool Autocorrect { get; set; }
|
|
|
|
|
|
|
|
|
|
public GetAlbumShoutsCommand(IAuth auth, string albumname, string artistname)
|
|
|
|
|
: base(auth)
|
|
|
|
|
{
|
|
|
|
|
Method = "album.getShouts";
|
|
|
|
|
AlbumName = albumname;
|
|
|
|
|
ArtistName = artistname;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-01 20:52:44 +01:00
|
|
|
|
public override void SetParameters()
|
2013-07-28 00:07:15 +01:00
|
|
|
|
{
|
2013-09-01 20:52:44 +01:00
|
|
|
|
Parameters.Add("album", AlbumName);
|
|
|
|
|
Parameters.Add("artist", ArtistName);
|
|
|
|
|
Parameters.Add("autocorrect", Convert.ToInt32(Autocorrect).ToString());
|
2013-07-28 00:07:15 +01:00
|
|
|
|
|
2013-09-01 20:52:44 +01:00
|
|
|
|
base.AddPagingParameters();
|
|
|
|
|
base.DisableCaching();
|
2013-07-28 00:07:15 +01:00
|
|
|
|
}
|
2013-09-01 20:52:44 +01:00
|
|
|
|
|
2013-07-28 00:07:15 +01:00
|
|
|
|
public async override Task<PageResponse<Shout>> HandleResponse(HttpResponseMessage response)
|
|
|
|
|
{
|
|
|
|
|
string json = await response.Content.ReadAsStringAsync();
|
|
|
|
|
|
|
|
|
|
LastFmApiError error;
|
|
|
|
|
if (LastFm.IsResponseValid(json, out error) && response.IsSuccessStatusCode)
|
|
|
|
|
{
|
|
|
|
|
JToken jtoken = JsonConvert.DeserializeObject<JToken>(json).SelectToken("shouts");
|
|
|
|
|
|
|
|
|
|
return Shout.ParsePageJToken(jtoken);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return PageResponse<Shout>.CreateErrorResponse(error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|