Files
YandexMusic/YandexMusic.API/API/YLandingAPI.cs
2026-04-10 15:05:32 +03:00

43 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using YandexMusic.API.Common;
using YandexMusic.API.Models.Common;
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>
public class YLandingAPI : YCommonAPI
{
/// <summary>Инициализирует новый экземпляр API лендинга.</summary>
/// <param name="yandex">Экземпляр основного API.</param>
public YLandingAPI(YandexMusicApi yandex) : base(yandex) { }
/// <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");
return new YGetLandingBuilder(api, storage)
.Build(blocks)
.GetResponseAsync();
}
/// <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();
}