"""
Binance Spot WebSocket API

OpenAPI Specifications for the Binance Spot WebSocket API

API documents:
  - [Github web-socket-api documentation file](https://github.com/binance/binance-spot-api-docs/blob/master/web-socket-api.md)
  - [General API information for web-socket-api on website](https://developers.binance.com/docs/binance-spot-api-docs/web-socket-api/general-api-information)

The version of the OpenAPI document: 1.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
"""

from binance_common.models import WebsocketApiResponse
from binance_common.signature import Signers
from binance_common.websocket import WebSocketAPIBase

from ..models import ExchangeInfoResponse
from ..models import PingResponse
from ..models import TimeResponse


from ..models import ExchangeInfoSymbolStatusEnum

from typing import List, Optional


class GeneralApi:
    """API Client for GeneralApi endpoints."""

    def __init__(
        self,
        websocket_api: WebSocketAPIBase,
        signer: Signers = None,
    ) -> None:
        self.websocket_api = websocket_api
        self.signer = signer

    async def exchange_info(
        self,
        id: Optional[str] = None,
        symbol: Optional[str] = None,
        symbols: Optional[List[str]] = None,
        permissions: Optional[List[str]] = None,
        show_permission_sets: Optional[bool] = None,
        symbol_status: Optional[ExchangeInfoSymbolStatusEnum] = None,
    ) -> WebsocketApiResponse[ExchangeInfoResponse]:
        """
            WebSocket Exchange information
            /exchangeInfo
            https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/general-requests#exchange-information

            Query current exchange trading rules, rate limits, and symbol information.
        Weight: 20

            Args:
                    id (Optional[str] = None): Unique WebSocket request ID.
                    symbol (Optional[str] = None): Describe a single symbol
                    symbols (Optional[List[str]] = None): List of symbols to query
                    permissions (Optional[List[str]] = None):
                    show_permission_sets (Optional[bool] = None):
                    symbol_status (Optional[ExchangeInfoSymbolStatusEnum] = None):

            Returns:
                WebsocketApiResponse[ExchangeInfoResponse]

            Raises:
                RequiredError: If a required parameter is missing.

        """

        params = {
            **({"id": id} if id is not None else {}),
            **({"symbol": symbol} if symbol is not None else {}),
            **({"symbols": symbols} if symbols is not None else {}),
            **({"permissions": permissions} if permissions is not None else {}),
            **(
                {"show_permission_sets": show_permission_sets}
                if show_permission_sets is not None
                else {}
            ),
            **({"symbol_status": symbol_status} if symbol_status is not None else {}),
        }

        payload = {
            "method": "/exchangeInfo".replace("/", "", 1),
            "params": params,
        }

        return await self.websocket_api.send_message(
            payload=payload, response_model=ExchangeInfoResponse
        )

    async def ping(
        self,
        id: Optional[str] = None,
    ) -> WebsocketApiResponse[PingResponse]:
        """
            WebSocket Test connectivity
            /ping
            https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/general-requests#test-connectivity

            Test connectivity to the WebSocket API.
        Weight: 1

            Args:
                    id (Optional[str] = None): Unique WebSocket request ID.

            Returns:
                WebsocketApiResponse[PingResponse]

            Raises:
                RequiredError: If a required parameter is missing.

        """

        params = {
            **({"id": id} if id is not None else {}),
        }

        payload = {
            "method": "/ping".replace("/", "", 1),
            "params": params,
        }

        return await self.websocket_api.send_message(
            payload=payload, response_model=PingResponse
        )

    async def time(
        self,
        id: Optional[str] = None,
    ) -> WebsocketApiResponse[TimeResponse]:
        """
            WebSocket Check server time
            /time
            https://developers.binance.com/docs/binance-spot-api-docs/websocket-api/general-requests#check-server-time

            Test connectivity to the WebSocket API and get the current server time.
        Weight: 1

            Args:
                    id (Optional[str] = None): Unique WebSocket request ID.

            Returns:
                WebsocketApiResponse[TimeResponse]

            Raises:
                RequiredError: If a required parameter is missing.

        """

        params = {
            **({"id": id} if id is not None else {}),
        }

        payload = {
            "method": "/time".replace("/", "", 1),
            "params": params,
        }

        return await self.websocket_api.send_message(
            payload=payload, response_model=TimeResponse
        )
