Полностью переписанное 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,43 +1,21 @@
|
||||
using YandexMusic.API.Common;
|
||||
using YandexMusic.API.Models.Common;
|
||||
using YandexMusic.API.Models.Feed;
|
||||
using YandexMusic.API.Models.Feed;
|
||||
using YandexMusic.API.Models.Landing;
|
||||
using YandexMusic.API.Requests.Feed;
|
||||
using YandexMusic.API.Requests.Landing;
|
||||
|
||||
namespace YandexMusic.API;
|
||||
|
||||
/// <summary>API для взаимодействия с главной страницей (лендингом).</summary>
|
||||
/// <summary>API для работы с главной страницей (лендингом).</summary>
|
||||
public class YLandingAPI : YCommonAPI
|
||||
{
|
||||
/// <summary>Инициализирует новый экземпляр API лендинга.</summary>
|
||||
/// <param name="yandex">Экземпляр основного API.</param>
|
||||
public YLandingAPI(YandexMusicApi yandex) : base(yandex) { }
|
||||
public YLandingAPI(YandexMusicApi api) : base(api) { }
|
||||
|
||||
/// <summary>Получает персональные блоки лендинга.</summary>
|
||||
/// <param name="storage">Хранилище авторизации.</param>
|
||||
/// <param name="blocks">Типы запрашиваемых блоков.</param>
|
||||
/// <returns>Ответ API с лендингом.</returns>
|
||||
/// <exception cref="ArgumentNullException">Если массив blocks равен null.</exception>
|
||||
public Task<YResponse<YLanding>> GetAsync(AuthStorage storage, params YLandingBlockType[] blocks)
|
||||
{
|
||||
if (blocks == null)
|
||||
throw new ArgumentNullException(nameof(blocks), "Массив блоков не может быть null");
|
||||
public Task<YLanding?> GetAsync(params YLandingBlockType[] blocks)
|
||||
=> new YGetLandingBuilder(Api).ExecuteAsync(blocks);
|
||||
|
||||
return new YGetLandingBuilder(api, storage)
|
||||
.Build(blocks)
|
||||
.GetResponseAsync();
|
||||
}
|
||||
public Task<YFeed?> GetFeedAsync()
|
||||
=> new YGetFeedBuilder(Api).ExecuteAsync(null!);
|
||||
|
||||
/// <summary>Получает ленту событий (фид).</summary>
|
||||
/// <param name="storage">Хранилище авторизации.</param>
|
||||
/// <returns>Ответ API с лентой.</returns>
|
||||
public Task<YResponse<YFeed>> GetFeedAsync(AuthStorage storage)
|
||||
=> new YGetFeedBuilder(api, storage).Build(null!).GetResponseAsync();
|
||||
|
||||
/// <summary>Получает лендинг детского раздела.</summary>
|
||||
/// <param name="storage">Хранилище авторизации.</param>
|
||||
/// <returns>Ответ API с детским лендингом.</returns>
|
||||
public Task<YResponse<YChildrenLanding>> GetChildrenLandingAsync(AuthStorage storage)
|
||||
=> new YGetChildrenLandingBuilder(api, storage).Build(null!).GetResponseAsync();
|
||||
public Task<YChildrenLanding?> GetChildrenLandingAsync()
|
||||
=> new YGetChildrenLandingBuilder(Api).ExecuteAsync(null!);
|
||||
}
|
||||
Reference in New Issue
Block a user