"""
Binance Derivatives Trading COIN Futures WebSocket API

OpenAPI Specification for the Binance Derivatives Trading COIN Futures WebSocket API
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 AccountInformationResponse
from ..models import FuturesAccountBalanceResponse


from typing import Optional


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

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

    async def account_information(
        self,
        id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> WebsocketApiResponse[AccountInformationResponse]:
        """
            Account Information(USER_DATA)
            /account.status
            https://developers.binance.com/docs/derivatives/coin-margined-futures/account/websocket-api/Account-Information

            Get current account information. User in single-asset/ multi-assets mode will see different value, see comments in response section for detail.

        Weight: 5

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

            Returns:
                WebsocketApiResponse[AccountInformationResponse]

            Raises:
                RequiredError: If a required parameter is missing.

        """

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

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

        return await self.websocket_api.send_signed_message(
            payload=payload,
            response_model=AccountInformationResponse,
            signer=self.signer,
        )

    async def futures_account_balance(
        self,
        id: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> WebsocketApiResponse[FuturesAccountBalanceResponse]:
        """
            Futures Account Balance(USER_DATA)
            /account.balance
            https://developers.binance.com/docs/derivatives/coin-margined-futures/account/websocket-api/Futures-Account-Balance

            Query account balance info

        Weight: 5

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

            Returns:
                WebsocketApiResponse[FuturesAccountBalanceResponse]

            Raises:
                RequiredError: If a required parameter is missing.

        """

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

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

        return await self.websocket_api.send_signed_message(
            payload=payload,
            response_model=FuturesAccountBalanceResponse,
            signer=self.signer,
        )
