#  Rubio - Rubika API library for python
#  Copyright (C) 2025-present Rubio <https://github.com/RubioTeam>
#  Github - https://github.com/RubioTeam/rubio.core


from typing import Union
import rubio.core


class RequestSendFile:

    __slots__ = ()

    async def request_send_file(
        self: "rubio.core.Client",
        type: Union[str, "rubio.core.enums.FileType"] = rubio.core.enums.FileType.FILE
    ) -> str:
        """
        Request an upload URL from the Rubika server for sending a file.

        This method interacts with the Rubika API to obtain a temporary URL
        where a file can be uploaded. The URL is specific to the file type
        and is required before calling `send_file`.

        Parameters:
            type (Union[str, rubio.core.enums.FileType], default=FileType.FILE):
                The type of file to upload (e.g., FILE, VOICE, DOCUMENT). Can
                be provided as a string or `FileType` enum.

        Returns:
            str: A temporary upload URL provided by the Rubika server.

        Example:
        .. code-block:: python
            upload_url = await client.request_send_file(type=rubio.core.enums.FileType.FILE)
        """
        type = type if isinstance(type, str) else type.value
        response = await self.request("requestSendFile", {"type": type})
        return response["upload_url"]