IF.Lastfm/IF.Lastfm.Core/Api/UserApi.cs

93 lines
3.1 KiB
C#
Raw Normal View History

using System;
using System.Threading.Tasks;
2013-06-23 20:10:57 +01:00
using IF.Lastfm.Core.Api.Commands.UserApi;
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.
/// </summary>
2013-07-23 15:48:03 +01:00
/// <param name="username"></param>
/// <param name="span"></param>
2013-07-23 15:48:03 +01:00
/// <param name="pagenumber"></param>
/// <param name="count"></param>
/// <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-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-23 20:10:57 +01:00
return await command.ExecuteAsync();
}
/// <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>
/// <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-23 20:10:57 +01:00
var command = new GetRecentScrobblesCommand(Auth, username, since)
{
Page = pagenumber,
Count = count
};
2013-06-23 20:10:57 +01:00
return await command.ExecuteAsync();
}
2013-06-15 17:02:11 +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
{
var command = new GetRecentStationsCommand(Auth, username)
{
Page = pagenumber,
Count = count
};
return await command.ExecuteAsync();
}
2013-06-15 17:02:11 +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
return await command.ExecuteAsync();
}
2013-06-15 17:02:11 +01:00
public async Task<LastResponse<User>> GetInfoAsync(string username)
{
var command = new GetUserInfoCommand(Auth, username);
2013-06-15 17:02:11 +01:00
return await command.ExecuteAsync();
2013-06-15 17:02:11 +01:00
}
public async Task<LastResponse> AddShoutAsync(string recipient, string message)
{
var command = new AddShoutCommand(Auth, recipient, message);
return await command.ExecuteAsync();
}
}
}