"""
Binance Spot REST API

OpenAPI Specifications for the Binance Spot REST API

API documents:
  - [Github rest-api documentation file](https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md)
  - [General API information for rest-api on website](https://developers.binance.com/docs/binance-spot-api-docs/rest-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 typing import List, Optional
from requests import Session
from binance_common.configuration import ConfigurationRestAPI
from binance_common.models import ApiResponse
from binance_common.signature import Signers
from binance_common.utils import send_request

from ..models import ExchangeInfoResponse

from ..models import TimeResponse


from ..models import ExchangeInfoSymbolStatusEnum


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

    def __init__(
        self,
        configuration: ConfigurationRestAPI = None,
        session: Session = None,
        signer: Signers = None,
    ) -> None:
        self._configuration = configuration
        self._session = session
        self._signer = signer

    def exchange_info(
        self,
        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,
    ) -> ApiResponse[ExchangeInfoResponse]:
        """
                Exchange information
                GET /api/v3/exchangeInfo
                https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#exchange-information

                Current exchange trading rules and symbol information
        Weight: 20

                Args:
                    symbol (Optional[str] = None): Symbol to query
                    symbols (Optional[List[str]] = None): List of symbols to query
                    permissions (Optional[List[str]] = None): List of permissions to query
                    show_permission_sets (Optional[bool] = None): Controls whether the content of the `permissionSets` field is populated or not. Defaults to `true`
                    symbol_status (Optional[ExchangeInfoSymbolStatusEnum] = None):

                Returns:
                    ApiResponse[ExchangeInfoResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "symbol": symbol,
            "symbols": symbols,
            "permissions": permissions,
            "show_permission_sets": show_permission_sets,
            "symbol_status": symbol_status,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/api/v3/exchangeInfo",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=ExchangeInfoResponse,
        )

    def ping(
        self,
    ) -> ApiResponse[None]:
        """
                Test connectivity
                GET /api/v3/ping
                https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#test-connectivity

                Test connectivity to the Rest API.
        Weight: 1

                Args:

                Returns:
                    ApiResponse[None]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = None
        payload = None

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/api/v3/ping",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
        )

    def time(
        self,
    ) -> ApiResponse[TimeResponse]:
        """
                Check server time
                GET /api/v3/time
                https://developers.binance.com/docs/binance-spot-api-docs/rest-api/general-endpoints#check-server-time

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

                Args:

                Returns:
                    ApiResponse[TimeResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = None
        payload = None

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/api/v3/time",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=TimeResponse,
        )
