2013-06-13 21:30:18 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2013-06-23 20:10:57 +01:00
|
|
|
|
using IF.Lastfm.Core.Api.Commands.UserApi;
|
2013-06-13 21:30:18 +01:00
|
|
|
|
using IF.Lastfm.Core.Api.Enums;
|
|
|
|
|
using IF.Lastfm.Core.Api.Helpers;
|
|
|
|
|
using IF.Lastfm.Core.Objects;
|
|
|
|
|
|
|
|
|
|
namespace IF.Lastfm.Core.Api
|
|
|
|
|
{
|
|
|
|
|
public class UserApi : IUserApi
|
|
|
|
|
{
|
|
|
|
|
public IAuth Auth { get; private set; }
|
|
|
|
|
|
|
|
|
|
public UserApi(IAuth auth)
|
|
|
|
|
{
|
|
|
|
|
Auth = auth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2013-07-23 15:48:03 +01:00
|
|
|
|
/// Gets the top albums for the given user.
|
2013-06-13 21:30:18 +01:00
|
|
|
|
/// </summary>
|
2013-07-23 15:48:03 +01:00
|
|
|
|
/// <param name="username"></param>
|
2013-06-13 21:30:18 +01:00
|
|
|
|
/// <param name="span"></param>
|
2013-07-23 15:48:03 +01:00
|
|
|
|
/// <param name="pagenumber"></param>
|
|
|
|
|
/// <param name="count"></param>
|
2013-06-13 21:30:18 +01:00
|
|
|
|
/// <returns></returns>
|
2013-07-23 15:48:03 +01:00
|
|
|
|
public async Task<PageResponse<Album>> GetTopAlbums(string username, LastStatsTimeSpan span, int pagenumber = 0, int count = LastFm.DefaultPageLength)
|
2013-06-13 21:30:18 +01:00
|
|
|
|
{
|
2013-07-23 15:48:03 +01:00
|
|
|
|
var command = new GetTopAlbumsCommand(Auth, username, span)
|
2013-06-23 20:10:57 +01:00
|
|
|
|
{
|
|
|
|
|
Page = pagenumber,
|
|
|
|
|
Count = count
|
|
|
|
|
};
|
2013-06-13 21:30:18 +01:00
|
|
|
|
|
2013-06-23 20:10:57 +01:00
|
|
|
|
return await command.ExecuteAsync();
|
2013-06-15 16:17:37 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets scrobbles and stuff
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="username"></param>
|
|
|
|
|
/// <param name="since"></param>
|
|
|
|
|
/// <param name="pagenumber"></param>
|
2013-07-23 15:48:03 +01:00
|
|
|
|
/// <param name="count"></param>
|
2013-06-15 16:17:37 +01:00
|
|
|
|
/// <returns></returns>
|
2013-06-23 20:10:57 +01:00
|
|
|
|
public async Task<PageResponse<Track>> GetRecentScrobbles(string username, DateTime since, int pagenumber = 0, int count = LastFm.DefaultPageLength)
|
2013-06-15 16:17:37 +01:00
|
|
|
|
{
|
2013-06-23 20:10:57 +01:00
|
|
|
|
var command = new GetRecentScrobblesCommand(Auth, username, since)
|
|
|
|
|
{
|
|
|
|
|
Page = pagenumber,
|
|
|
|
|
Count = count
|
|
|
|
|
};
|
2013-06-15 16:17:37 +01:00
|
|
|
|
|
2013-06-23 20:10:57 +01:00
|
|
|
|
return await command.ExecuteAsync();
|
2013-06-13 21:30:18 +01:00
|
|
|
|
}
|
2013-06-15 17:02:11 +01:00
|
|
|
|
|
2013-07-23 22:34:51 +01:00
|
|
|
|
public async Task<PageResponse<Station>> GetRecentStations(string username, int pagenumber = 0, int count = LastFm.DefaultPageLength)
|
2013-06-15 17:02:11 +01:00
|
|
|
|
{
|
2013-07-23 22:34:51 +01:00
|
|
|
|
var command = new GetRecentStationsCommand(Auth, username)
|
|
|
|
|
{
|
|
|
|
|
Page = pagenumber,
|
|
|
|
|
Count = count
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return await command.ExecuteAsync();
|
2013-07-28 00:07:15 +01:00
|
|
|
|
}
|
2013-06-15 17:02:11 +01:00
|
|
|
|
|
2013-07-28 00:07:15 +01:00
|
|
|
|
public async Task<PageResponse<Shout>> GetShoutsAsync(string username, int pagenumber, int count = LastFm.DefaultPageLength)
|
|
|
|
|
{
|
|
|
|
|
var command = new GetUserShoutsCommand(Auth, username)
|
|
|
|
|
{
|
|
|
|
|
Page = pagenumber,
|
|
|
|
|
Count = count
|
|
|
|
|
};
|
2013-06-15 17:02:11 +01:00
|
|
|
|
|
2013-07-28 00:07:15 +01:00
|
|
|
|
return await command.ExecuteAsync();
|
|
|
|
|
}
|
2013-06-15 17:02:11 +01:00
|
|
|
|
|
2013-07-28 00:07:15 +01:00
|
|
|
|
public async Task<LastResponse<User>> GetInfoAsync(string username)
|
|
|
|
|
{
|
|
|
|
|
var command = new GetUserInfoCommand(Auth, username);
|
2013-06-15 17:02:11 +01:00
|
|
|
|
|
2013-07-28 00:07:15 +01:00
|
|
|
|
return await command.ExecuteAsync();
|
2013-06-15 17:02:11 +01:00
|
|
|
|
}
|
2013-06-13 21:30:18 +01:00
|
|
|
|
}
|
|
|
|
|
}
|