#  VKMusix — VK Music API Client Library for Python
#  Copyright (C) 2024—present to4no4sv <https://github.com/to4no4sv/VKMusix>
#
#  This file is part of VKMusix.
#
#  VKMusix is free software: you can redistribute it and/or modify
#  it under the terms of the GNU Lesser General Public License as published
#  by the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  VKMusix is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public License
#  along with VKMusix. If not, see <http://www.gnu.org/licenses/>.

class GetSection:
    from typing import Union

    from vkmusix.aio import async_
    from vkmusix.types import Section

    @async_
    async def getSection(self, sectionId: str, offset: str = None) -> Union[Section, None]:
        """
        Получает треки из раздела музыки.

        `Пример использования`:

        section = client.getSection(
            sectionId="PUlQVA8GR0R3W0tMF1kSOSceDR9aRzQEKgQKHRcYSV5kUUREDQ1bU35cXFoXAFtEfEZYWhcBSVxkDAwYUEYKCmRHS0IXDlpKZFpcVA8FR0R0XUtMGAZTX3ZeUUEASQ",
        )

        print(section)

        :param sectionId: идентификатор раздела музыки. (``str``)
        :param offset: уникальное значение, содержащееся в атрибуте ``nextOffset`` объекта класса ``types.Section``. Необходимо для получения следующих результатов в разделе. (``str``, `optional`)
        :return: `При успехе`: информация о разделе музыки (``types.Section``). `Если раздел не найден`: ``None``.
        """

        from vkmusix.types import Section

        section = await self._req(
            "catalog.getSection",
            {
                "section_id": sectionId,
                **({
                    "start_from": offset,
                } if offset else dict()),
            },
        )

        if not section:
            return

        return self._finalizeResponse(section, Section)

    get_section = getSection