mirror of
https://github.com/Sarsoo/IF.Lastfm.git
synced 2024-10-17 07:13:09 +01:00
user.shout, artist.shout.
the api doesn't have album.shout and track.shout but i made commands for them anyway, not put them in AlbumApi or TrackApi though.
This commit is contained in:
parent
2235ba0753
commit
73e1831986
@ -56,5 +56,12 @@ public async Task<PageResponse<Shout>> GetShoutsAsync(string albumname, string a
|
||||
|
||||
return await command.ExecuteAsync();
|
||||
}
|
||||
|
||||
//public async Task<LastResponse> AddShoutAsync(string albumname, string artistname, string message)
|
||||
//{
|
||||
// var command = new AddShoutCommand(Auth, albumname, artistname, message);
|
||||
|
||||
// return await command.ExecuteAsync();
|
||||
//}
|
||||
}
|
||||
}
|
@ -61,5 +61,12 @@ public async Task<PageResponse<Shout>> GetShoutsForArtistAsync(string artist, in
|
||||
};
|
||||
return await command.ExecuteAsync();
|
||||
}
|
||||
|
||||
public async Task<LastResponse> AddShoutAsync(string artistname, string messaage)
|
||||
{
|
||||
var command = new AddShoutCommand(Auth, artistname, messaage);
|
||||
|
||||
return await command.ExecuteAsync();
|
||||
}
|
||||
}
|
||||
}
|
39
IF.Lastfm.Core/Api/Commands/AlbumApi/AddShoutCommand.cs
Normal file
39
IF.Lastfm.Core/Api/Commands/AlbumApi/AddShoutCommand.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using IF.Lastfm.Core.Api.Helpers;
|
||||
|
||||
namespace IF.Lastfm.Core.Api.Commands.AlbumApi
|
||||
{
|
||||
internal class AddShoutCommand : PostAsyncCommandBase<LastResponse>
|
||||
{
|
||||
public string Album { get; set; }
|
||||
public string Artist { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public AddShoutCommand(IAuth auth, string album, string artist, string message) : base(auth)
|
||||
{
|
||||
Method = "album.shout";
|
||||
Album = album;
|
||||
Artist = artist;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public async override Task<LastResponse> ExecuteAsync()
|
||||
{
|
||||
var parameters = new Dictionary<string, string>
|
||||
{
|
||||
{"album", Album},
|
||||
{"artist", Artist},
|
||||
{"message", Message}
|
||||
};
|
||||
|
||||
return await ExecuteInternal(parameters);
|
||||
}
|
||||
|
||||
public async override Task<LastResponse> HandleResponse(HttpResponseMessage response)
|
||||
{
|
||||
return await LastResponse.HandleResponse(response);
|
||||
}
|
||||
}
|
||||
}
|
36
IF.Lastfm.Core/Api/Commands/ArtistApi/AddShoutCommand.cs
Normal file
36
IF.Lastfm.Core/Api/Commands/ArtistApi/AddShoutCommand.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using IF.Lastfm.Core.Api.Helpers;
|
||||
|
||||
namespace IF.Lastfm.Core.Api.Commands.ArtistApi
|
||||
{
|
||||
internal class AddShoutCommand : PostAsyncCommandBase<LastResponse>
|
||||
{
|
||||
public string Artist { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public AddShoutCommand(IAuth auth, string artist, string message) : base(auth)
|
||||
{
|
||||
Method = "artist.shout";
|
||||
Artist = artist;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public async override Task<LastResponse> ExecuteAsync()
|
||||
{
|
||||
var parameters = new Dictionary<string, string>
|
||||
{
|
||||
{"artist", Artist},
|
||||
{"message", Message}
|
||||
};
|
||||
|
||||
return await ExecuteInternal(parameters);
|
||||
}
|
||||
|
||||
public async override Task<LastResponse> HandleResponse(HttpResponseMessage response)
|
||||
{
|
||||
return await LastResponse.HandleResponse(response);
|
||||
}
|
||||
}
|
||||
}
|
39
IF.Lastfm.Core/Api/Commands/TrackApi/AddShoutCommand.cs
Normal file
39
IF.Lastfm.Core/Api/Commands/TrackApi/AddShoutCommand.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using IF.Lastfm.Core.Api.Helpers;
|
||||
|
||||
namespace IF.Lastfm.Core.Api.Commands.TrackApi
|
||||
{
|
||||
internal class AddShoutCommand : PostAsyncCommandBase<LastResponse>
|
||||
{
|
||||
public string Track { get; set; }
|
||||
public string Artist { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public AddShoutCommand(IAuth auth, string track, string artist, string message) : base(auth)
|
||||
{
|
||||
Method = "track.shout";
|
||||
Track = track;
|
||||
Artist = artist;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public async override Task<LastResponse> ExecuteAsync()
|
||||
{
|
||||
var parameters = new Dictionary<string, string>
|
||||
{
|
||||
{"track", Track},
|
||||
{"artist", Artist},
|
||||
{"message", Message}
|
||||
};
|
||||
|
||||
return await ExecuteInternal(parameters);
|
||||
}
|
||||
|
||||
public async override Task<LastResponse> HandleResponse(HttpResponseMessage response)
|
||||
{
|
||||
return await LastResponse.HandleResponse(response);
|
||||
}
|
||||
}
|
||||
}
|
@ -33,17 +33,7 @@ public async override Task<LastResponse> ExecuteAsync()
|
||||
|
||||
public async override Task<LastResponse> HandleResponse(HttpResponseMessage response)
|
||||
{
|
||||
string json = await response.Content.ReadAsStringAsync();
|
||||
|
||||
LastFmApiError error;
|
||||
if (LastFm.IsResponseValid(json, out error) && response.IsSuccessStatusCode)
|
||||
{
|
||||
return LastResponse.CreateSuccessResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
return LastResponse.CreateErrorResponse(error);
|
||||
}
|
||||
return await LastResponse.HandleResponse(response);
|
||||
}
|
||||
}
|
||||
}
|
@ -33,17 +33,7 @@ public async override Task<LastResponse> ExecuteAsync()
|
||||
|
||||
public async override Task<LastResponse> HandleResponse(HttpResponseMessage response)
|
||||
{
|
||||
string json = await response.Content.ReadAsStringAsync();
|
||||
|
||||
LastFmApiError error;
|
||||
if (LastFm.IsResponseValid(json, out error) && response.IsSuccessStatusCode)
|
||||
{
|
||||
return LastResponse.CreateSuccessResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
return LastResponse.CreateErrorResponse(error);
|
||||
}
|
||||
return await LastResponse.HandleResponse(response);
|
||||
}
|
||||
}
|
||||
}
|
38
IF.Lastfm.Core/Api/Commands/UserApi/AddShoutCommand.cs
Normal file
38
IF.Lastfm.Core/Api/Commands/UserApi/AddShoutCommand.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using IF.Lastfm.Core.Api.Enums;
|
||||
using IF.Lastfm.Core.Api.Helpers;
|
||||
|
||||
namespace IF.Lastfm.Core.Api.Commands.UserApi
|
||||
{
|
||||
internal class AddShoutCommand : PostAsyncCommandBase<LastResponse>
|
||||
{
|
||||
public string Recipient { get; set; }
|
||||
public string Message { get; set; }
|
||||
|
||||
public AddShoutCommand(IAuth auth, string recipient, string message) : base(auth)
|
||||
{
|
||||
Method = "user.shout";
|
||||
Recipient = recipient;
|
||||
Message = message;
|
||||
}
|
||||
|
||||
public async override Task<LastResponse> ExecuteAsync()
|
||||
{
|
||||
var parameters = new Dictionary<string, string>
|
||||
{
|
||||
{"user", Recipient},
|
||||
{"message", Message}
|
||||
};
|
||||
|
||||
return await ExecuteInternal(parameters);
|
||||
}
|
||||
|
||||
public async override Task<LastResponse> HandleResponse(HttpResponseMessage response)
|
||||
{
|
||||
return await LastResponse.HandleResponse(response);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using IF.Lastfm.Core.Api.Enums;
|
||||
|
@ -1,4 +1,6 @@
|
||||
using IF.Lastfm.Core.Api.Enums;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using IF.Lastfm.Core.Api.Enums;
|
||||
|
||||
namespace IF.Lastfm.Core.Api.Helpers
|
||||
{
|
||||
@ -35,6 +37,21 @@ public static LastResponse CreateErrorResponse(LastFmApiError error)
|
||||
return r;
|
||||
}
|
||||
|
||||
public async static Task<LastResponse> HandleResponse(HttpResponseMessage response)
|
||||
{
|
||||
string json = await response.Content.ReadAsStringAsync();
|
||||
|
||||
LastFmApiError error;
|
||||
if (LastFm.IsResponseValid(json, out error) && response.IsSuccessStatusCode)
|
||||
{
|
||||
return LastResponse.CreateSuccessResponse();
|
||||
}
|
||||
else
|
||||
{
|
||||
return LastResponse.CreateErrorResponse(error);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -33,5 +33,7 @@ Task<PageResponse<Shout>> GetShoutsAsync(string albumname,
|
||||
bool autocorrect = false,
|
||||
int page = 1,
|
||||
int count = LastFm.DefaultPageLength);
|
||||
|
||||
//Task<LastResponse> AddShoutAsync(string albumname, string artistname, string message);
|
||||
}
|
||||
}
|
@ -32,5 +32,7 @@ Task<PageResponse<Shout>> GetShoutsForArtistAsync(string artistname,
|
||||
int page = 0,
|
||||
int count = LastFm.DefaultPageLength,
|
||||
bool autocorrect = false);
|
||||
|
||||
Task<LastResponse> AddShoutAsync(string artistname, string messaage);
|
||||
}
|
||||
}
|
||||
|
@ -22,5 +22,7 @@ Task<PageResponse<Shout>> GetShoutsForTrackAsync(string trackname,
|
||||
|
||||
Task<LastResponse> LoveTrackAsync(string trackname, string artistname);
|
||||
Task<LastResponse> UnloveTrackAsync(string trackname, string artistname);
|
||||
|
||||
//Task<LastResponse> AddShoutAsync(string trackname, string artistname, string message);
|
||||
}
|
||||
}
|
@ -29,5 +29,7 @@ Task<PageResponse<Shout>> GetShoutsAsync(string username,
|
||||
int count = LastFm.DefaultPageLength);
|
||||
|
||||
Task<LastResponse<User>> GetInfoAsync(string username);
|
||||
|
||||
Task<LastResponse> AddShoutAsync(string recipient, string message);
|
||||
}
|
||||
}
|
@ -92,5 +92,11 @@ public async Task<LastResponse> UnloveTrackAsync(string trackname, string artist
|
||||
var command = new UnloveTrackCommand(Auth, trackname, artistname);
|
||||
return await command.ExecuteAsync();
|
||||
}
|
||||
|
||||
//public Task<LastResponse> AddShoutAsync(string trackname, string artistname, string message)
|
||||
//{
|
||||
// var command = new AddShoutCommand(Auth, trackname, artistname, message);
|
||||
// return await command.ExecuteAsync();
|
||||
//}
|
||||
}
|
||||
}
|
@ -82,5 +82,12 @@ public async Task<LastResponse<User>> GetInfoAsync(string username)
|
||||
|
||||
return await command.ExecuteAsync();
|
||||
}
|
||||
|
||||
public async Task<LastResponse> AddShoutAsync(string recipient, string message)
|
||||
{
|
||||
var command = new AddShoutCommand(Auth, recipient, message);
|
||||
|
||||
return await command.ExecuteAsync();
|
||||
}
|
||||
}
|
||||
}
|
@ -41,16 +41,20 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Api\AlbumApi.cs" />
|
||||
<Compile Include="Api\ArtistApi.cs" />
|
||||
<Compile Include="Api\Commands\AlbumApi\AddShoutCommand.cs" />
|
||||
<Compile Include="Api\Commands\AlbumApi\GetAlbumInfoCommand.cs" />
|
||||
<Compile Include="Api\Commands\AlbumApi\GetAlbumShoutsCommand.cs" />
|
||||
<Compile Include="Api\Commands\ArtistApi\AddShoutCommand.cs" />
|
||||
<Compile Include="Api\Commands\ArtistApi\GetArtistInfoCommand.cs" />
|
||||
<Compile Include="Api\Commands\ArtistApi\GetArtistShoutsCommand.cs" />
|
||||
<Compile Include="Api\Commands\GetAsyncCommandBase.cs" />
|
||||
<Compile Include="Api\Commands\PostAsyncCommandBase.cs" />
|
||||
<Compile Include="Api\Commands\TrackApi\AddShoutCommand.cs" />
|
||||
<Compile Include="Api\Commands\TrackApi\GetTrackInfoCommand.cs" />
|
||||
<Compile Include="Api\Commands\TrackApi\GetTrackShoutsCommand.cs" />
|
||||
<Compile Include="Api\Commands\TrackApi\LoveTrackCommand.cs" />
|
||||
<Compile Include="Api\Commands\TrackApi\UnloveTrackCommand.cs" />
|
||||
<Compile Include="Api\Commands\UserApi\AddShoutCommand.cs" />
|
||||
<Compile Include="Api\Commands\UserApi\GetRecentScrobblesCommand.cs" />
|
||||
<Compile Include="Api\Commands\UserApi\GetRecentStationsCommand.cs" />
|
||||
<Compile Include="Api\Commands\UserApi\GetTopAlbumsCommand.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user