Полностью переписанное api
All checks were successful
Release / pack-and-publish (release) Successful in 36s
All checks were successful
Release / pack-and-publish (release) Successful in 36s
This commit is contained in:
@@ -1,25 +1,13 @@
|
||||
using System.Net;
|
||||
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Playlist;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Get, "users/{user}/playlists/{kind}")]
|
||||
public class YGetPlaylistBuilder : YRequestBuilder<YResponse<YPlaylist>, (string user, string kind)>
|
||||
public class YGetPlaylistBuilder : YMusicRequestBuilder<YPlaylist?, (string user, string kind)>
|
||||
{
|
||||
public YGetPlaylistBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
public YGetPlaylistBuilder(YandexMusicApi api) : base(api) { }
|
||||
protected override string Method => WebRequestMethods.Http.Get;
|
||||
protected override string PathTemplate => "users/{user}/playlists/{kind}";
|
||||
protected override Dictionary<string, string> GetSubstitutions((string user, string kind) tuple)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "user", tuple.user },
|
||||
{ "kind", tuple.kind },
|
||||
};
|
||||
}
|
||||
=> new() { { "user", tuple.user }, { "kind", tuple.kind } };
|
||||
}
|
||||
@@ -1,24 +1,13 @@
|
||||
using System.Net;
|
||||
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Playlist;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Get, "playlist/{uuid}")]
|
||||
public class YGetPlaylistByUuidBuilder : YRequestBuilder<YResponse<YPlaylist>, string>
|
||||
public class YGetPlaylistByUuidBuilder : YMusicRequestBuilder<YPlaylist?, string>
|
||||
{
|
||||
public YGetPlaylistByUuidBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
public YGetPlaylistByUuidBuilder(YandexMusicApi api) : base(api) { }
|
||||
protected override string Method => WebRequestMethods.Http.Get;
|
||||
protected override string PathTemplate => "playlist/{uuid}";
|
||||
protected override Dictionary<string, string> GetSubstitutions(string uuid)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "uuid", uuid },
|
||||
};
|
||||
}
|
||||
=> new() { { "uuid", uuid } };
|
||||
}
|
||||
@@ -1,24 +1,13 @@
|
||||
using System.Net;
|
||||
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Playlist;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Get, "users/{uid}/playlists/list")]
|
||||
public class YGetPlaylistFavoritesBuilder : YRequestBuilder<YResponse<List<YPlaylist>>, object>
|
||||
public class YGetPlaylistFavoritesBuilder : YMusicRequestBuilder<List<YPlaylist>?, object>
|
||||
{
|
||||
public YGetPlaylistFavoritesBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions(object tuple)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "uid", storage.User.Uid }
|
||||
};
|
||||
}
|
||||
public YGetPlaylistFavoritesBuilder(YandexMusicApi api) : base(api) { }
|
||||
protected override string Method => WebRequestMethods.Http.Get;
|
||||
protected override string PathTemplate => "users/{uid}/playlists/list";
|
||||
protected override Dictionary<string, string> GetSubstitutions(object _)
|
||||
=> new() { { "uid", Api.Storage.User.Uid } };
|
||||
}
|
||||
@@ -1,24 +1,16 @@
|
||||
using System.Net;
|
||||
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Playlist;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "playlists/list")]
|
||||
public class YGetPlaylistsBuilder : YRequestBuilder<YResponse<List<YPlaylist>>, IEnumerable<(string User, string Kind)>>
|
||||
public class YGetPlaylistsBuilder : YMusicRequestBuilder<List<YPlaylist>?, IEnumerable<(string User, string Kind)>>
|
||||
{
|
||||
public YGetPlaylistsBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
protected override HttpContent GetContent(IEnumerable<(string User, string Kind)> playlistIds)
|
||||
{
|
||||
return new FormUrlEncodedContent(new Dictionary<string, string> {
|
||||
public YGetPlaylistsBuilder(YandexMusicApi api) : base(api) { }
|
||||
protected override string Method => WebRequestMethods.Http.Post;
|
||||
protected override string PathTemplate => "playlists/list";
|
||||
protected override HttpContent? GetContent(IEnumerable<(string User, string Kind)> playlistIds)
|
||||
=> new FormUrlEncodedContent(new Dictionary<string, string>
|
||||
{
|
||||
{ "playlist-Ids", string.Join(",", playlistIds.Select(t => $"{t.User}:{t.Kind}")) }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,20 @@
|
||||
using System.Net;
|
||||
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Playlist;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "users/{uid}/playlists/{kind}/change")]
|
||||
public class YPlaylistChangeBuilder : YRequestBuilder<YResponse<YPlaylist>, (YPlaylist playlist, IEnumerable<YPlaylistChange> changes)>
|
||||
public class YPlaylistChangeBuilder : YMusicRequestBuilder<YPlaylist?, (YPlaylist playlist, IEnumerable<YPlaylistChange> changes)>
|
||||
{
|
||||
public YPlaylistChangeBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
public YPlaylistChangeBuilder(YandexMusicApi api) : base(api) { }
|
||||
protected override string Method => WebRequestMethods.Http.Post;
|
||||
protected override string PathTemplate => "users/{uid}/playlists/{kind}/change";
|
||||
protected override Dictionary<string, string> GetSubstitutions((YPlaylist playlist, IEnumerable<YPlaylistChange> changes) tuple)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "uid", storage.User.Uid },
|
||||
{ "kind", tuple.playlist.Kind }
|
||||
};
|
||||
}
|
||||
|
||||
protected override HttpContent GetContent((YPlaylist playlist, IEnumerable<YPlaylistChange> changes) tuple)
|
||||
{
|
||||
return new FormUrlEncodedContent(new Dictionary<string, string> {
|
||||
=> new() { { "uid", Api.Storage.User.Uid }, { "kind", tuple.playlist.Kind } };
|
||||
protected override HttpContent? GetContent((YPlaylist playlist, IEnumerable<YPlaylistChange> changes) tuple)
|
||||
=> new FormUrlEncodedContent(new Dictionary<string, string>
|
||||
{
|
||||
{ "kind", tuple.playlist.Kind },
|
||||
{ "revision", tuple.playlist.Revision.ToString() },
|
||||
{ "diff", SerializeJson(tuple.changes) }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,15 @@
|
||||
using System.Net;
|
||||
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Playlist;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "users/{uid}/playlists/create")]
|
||||
public class YPlaylistCreateBuilder : YRequestBuilder<YResponse<YPlaylist>, string>
|
||||
public class YPlaylistCreateBuilder : YMusicRequestBuilder<YPlaylist?, string>
|
||||
{
|
||||
public YPlaylistCreateBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
public YPlaylistCreateBuilder(YandexMusicApi api) : base(api) { }
|
||||
protected override string Method => WebRequestMethods.Http.Post;
|
||||
protected override string PathTemplate => "users/{uid}/playlists/create";
|
||||
protected override Dictionary<string, string> GetSubstitutions(string name)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "uid", storage.User.Uid }
|
||||
};
|
||||
}
|
||||
|
||||
protected override HttpContent GetContent(string name)
|
||||
{
|
||||
return new FormUrlEncodedContent(new Dictionary<string, string> {
|
||||
{ "title", name },
|
||||
{ "visibility", "public" }
|
||||
});
|
||||
}
|
||||
=> new() { { "uid", Api.Storage.User.Uid } };
|
||||
protected override HttpContent? GetContent(string name)
|
||||
=> new FormUrlEncodedContent(new Dictionary<string, string> { { "title", name }, { "visibility", "public" } });
|
||||
}
|
||||
@@ -1,32 +1,12 @@
|
||||
using System.Net;
|
||||
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
|
||||
namespace YandexMusic.API.Requests.Playlist;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "users/{uid}/playlists/{kind}/name")]
|
||||
public class YPlaylistRenameBuilder : YRequestBuilder<YResponse<YPlaylist>, (string kind, string name)>
|
||||
public class YPlaylistRemoveBuilder : YMusicRequestBuilder<HttpResponseMessage, string>
|
||||
{
|
||||
public YPlaylistRenameBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions((string kind, string name) tuple)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "uid", storage.User.Uid },
|
||||
{ "kind", tuple.kind }
|
||||
};
|
||||
}
|
||||
|
||||
protected override HttpContent GetContent((string kind, string name) tuple)
|
||||
{
|
||||
return new FormUrlEncodedContent(new Dictionary<string, string> {
|
||||
{ "value", tuple.name }
|
||||
});
|
||||
}
|
||||
public YPlaylistRemoveBuilder(YandexMusicApi api) : base(api) { }
|
||||
protected override string Method => WebRequestMethods.Http.Post;
|
||||
protected override string PathTemplate => "users/{uid}/playlists/{kind}/delete";
|
||||
protected override Dictionary<string, string> GetSubstitutions(string kind)
|
||||
=> new() { { "uid", Api.Storage.User.Uid }, { "kind", kind } };
|
||||
}
|
||||
@@ -1,23 +1,15 @@
|
||||
using System.Net;
|
||||
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Requests.Common;
|
||||
using YandexMusic.API.Requests.Common.Attributes;
|
||||
using YandexMusic.API.Models.Playlist;
|
||||
|
||||
namespace YandexMusic.API.Requests.Playlist;
|
||||
|
||||
[YApiRequest(WebRequestMethods.Http.Post, "users/{uid}/playlists/{kind}/delete")]
|
||||
public class YPlaylistRemoveBuilder : YRequestBuilder<HttpResponseMessage, string>
|
||||
public class YPlaylistRenameBuilder : YMusicRequestBuilder<YPlaylist?, (string kind, string name)>
|
||||
{
|
||||
public YPlaylistRemoveBuilder(YandexMusicApi yandex, AuthStorage auth) : base(yandex, auth)
|
||||
{
|
||||
}
|
||||
|
||||
protected override Dictionary<string, string> GetSubstitutions(string kind)
|
||||
{
|
||||
return new Dictionary<string, string> {
|
||||
{ "uid", storage.User.Uid },
|
||||
{ "kind", kind }
|
||||
};
|
||||
}
|
||||
public YPlaylistRenameBuilder(YandexMusicApi api) : base(api) { }
|
||||
protected override string Method => WebRequestMethods.Http.Post;
|
||||
protected override string PathTemplate => "users/{uid}/playlists/{kind}/name";
|
||||
protected override Dictionary<string, string> GetSubstitutions((string kind, string name) tuple)
|
||||
=> new() { { "uid", Api.Storage.User.Uid }, { "kind", tuple.kind } };
|
||||
protected override HttpContent? GetContent((string kind, string name) tuple)
|
||||
=> new FormUrlEncodedContent(new Dictionary<string, string> { { "value", tuple.name } });
|
||||
}
|
||||
Reference in New Issue
Block a user