"""
Binance Staking REST API

OpenAPI Specification for the Binance Staking REST 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 typing import Optional, Union
from requests import Session
from binance_common.configuration import ConfigurationRestAPI
from binance_common.errors import RequiredError
from binance_common.models import ApiResponse
from binance_common.signature import Signers
from binance_common.utils import send_request

from ..models import EthStakingAccountResponse
from ..models import GetCurrentEthStakingQuotaResponse
from ..models import GetEthRedemptionHistoryResponse
from ..models import GetEthStakingHistoryResponse
from ..models import GetWbethRateHistoryResponse
from ..models import GetWbethRewardsHistoryResponse
from ..models import GetWbethUnwrapHistoryResponse
from ..models import GetWbethWrapHistoryResponse
from ..models import RedeemEthResponse
from ..models import SubscribeEthStakingResponse
from ..models import WrapBethResponse


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

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

    def eth_staking_account(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[EthStakingAccountResponse]:
        """
                ETH Staking account(USER_DATA)
                GET /sapi/v2/eth-staking/account
                https://developers.binance.com/docs/staking/eth-staking/account/ETH-Staking-account

                ETH Staking account

        Weight: 150

                Args:
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[EthStakingAccountResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {"recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v2/eth-staking/account",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=EthStakingAccountResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_current_eth_staking_quota(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetCurrentEthStakingQuotaResponse]:
        """
                Get current ETH staking quota(USER_DATA)
                GET /sapi/v1/eth-staking/eth/quota
                https://developers.binance.com/docs/staking/eth-staking/account/Get-current-ETH-staking-quota

                Get current ETH staking quota

        Weight: 150

                Args:
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetCurrentEthStakingQuotaResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {"recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/eth-staking/eth/quota",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetCurrentEthStakingQuotaResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_eth_redemption_history(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetEthRedemptionHistoryResponse]:
        """
                Get ETH redemption history(USER_DATA)
                GET /sapi/v1/eth-staking/eth/history/redemptionHistory
                https://developers.binance.com/docs/staking/eth-staking/history/Get-ETH-redemption-history

                Get ETH redemption history

        * The time between `startTime` and `endTime` cannot be longer than 3 months.
        * If `startTime` and `endTime` are both not sent, then the last 30 days' data will be returned.
        * If `startTime` is sent but `endTime` is not sent, the next 30 days' data beginning from `startTime` will be returned.
        * If `endTime` is sent but `startTime` is not sent, the 30 days' data before `endTime` will be returned.

        Weight: 150

                Args:
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    current (Optional[int] = None): Currently querying page. Start from 1. Default:1
                    size (Optional[int] = None): Default:10, Max:100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetEthRedemptionHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "start_time": start_time,
            "end_time": end_time,
            "current": current,
            "size": size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/eth-staking/eth/history/redemptionHistory",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetEthRedemptionHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_eth_staking_history(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetEthStakingHistoryResponse]:
        """
                Get ETH staking history(USER_DATA)
                GET /sapi/v1/eth-staking/eth/history/stakingHistory
                https://developers.binance.com/docs/staking/eth-staking/history/Get-ETH-staking-history

                Get ETH staking history

        * The time between `startTime` and `endTime` cannot be longer than 3 months.
        * If `startTime` and `endTime` are both not sent, then the last 30 days' data will be returned.
        * If `startTime` is sent but `endTime` is not sent, the next 30 days' data beginning from `startTime` will be returned.
        * If `endTime` is sent but `startTime` is not sent, the 30 days' data before `endTime` will be returned.

        Weight: 150

                Args:
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    current (Optional[int] = None): Currently querying page. Start from 1. Default:1
                    size (Optional[int] = None): Default:10, Max:100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetEthStakingHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "start_time": start_time,
            "end_time": end_time,
            "current": current,
            "size": size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/eth-staking/eth/history/stakingHistory",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetEthStakingHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_wbeth_rate_history(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetWbethRateHistoryResponse]:
        """
                Get WBETH Rate History(USER_DATA)
                GET /sapi/v1/eth-staking/eth/history/rateHistory
                https://developers.binance.com/docs/staking/eth-staking/history/Get-BETH-Rate-History

                Get WBETH Rate History

        * The time between `startTime` and `endTime` cannot be longer than 3 months.
        * If `startTime` and `endTime` are both not sent, then the last 30 days' data will be returned.
        * If `startTime` is sent but `endTime` is not sent, the next 30 days' data beginning from `startTime` will be returned.
        * If `endTime` is sent but `startTime` is not sent, the 30 days' data before `endTime` will be returned.

        Weight: 150

                Args:
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    current (Optional[int] = None): Currently querying page. Start from 1. Default:1
                    size (Optional[int] = None): Default:10, Max:100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetWbethRateHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "start_time": start_time,
            "end_time": end_time,
            "current": current,
            "size": size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/eth-staking/eth/history/rateHistory",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetWbethRateHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_wbeth_rewards_history(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetWbethRewardsHistoryResponse]:
        """
                Get WBETH rewards history(USER_DATA)
                GET /sapi/v1/eth-staking/eth/history/wbethRewardsHistory
                https://developers.binance.com/docs/staking/eth-staking/history/Get-WBETH-rewards-history

                Get WBETH rewards history

        * The time between `startTime` and `endTime` cannot be longer than 3 months.
        * If `startTime` and `endTime` are both not sent, then the last 30 days' data will be returned.
        * If `startTime` is sent but `endTime` is not sent, the next 30 days' data beginning from `startTime` will be returned.
        * If `endTime` is sent but `startTime` is not sent, the 30 days' data before `endTime` will be returned.

        Weight: 150

                Args:
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    current (Optional[int] = None): Currently querying page. Start from 1. Default:1
                    size (Optional[int] = None): Default:10, Max:100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetWbethRewardsHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "start_time": start_time,
            "end_time": end_time,
            "current": current,
            "size": size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/eth-staking/eth/history/wbethRewardsHistory",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetWbethRewardsHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_wbeth_unwrap_history(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetWbethUnwrapHistoryResponse]:
        """
                Get WBETH unwrap history(USER_DATA)
                GET /sapi/v1/eth-staking/wbeth/history/unwrapHistory
                https://developers.binance.com/docs/staking/eth-staking/history/Get-WBETH-unwrap-history

                Get WBETH unwrap history

        * The time between `startTime` and `endTime` cannot be longer than 3 months.
        * If `startTime` and `endTime` are both not sent, then the last 30 days' data will be returned.
        * If `startTime` is sent but `endTime` is not sent, the next 30 days' data beginning from `startTime` will be returned.
        * If `endTime` is sent but `startTime` is not sent, the 30 days' data before `endTime` will be returned.

        Weight: 150

                Args:
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    current (Optional[int] = None): Currently querying page. Start from 1. Default:1
                    size (Optional[int] = None): Default:10, Max:100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetWbethUnwrapHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "start_time": start_time,
            "end_time": end_time,
            "current": current,
            "size": size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/eth-staking/wbeth/history/unwrapHistory",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetWbethUnwrapHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_wbeth_wrap_history(
        self,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetWbethWrapHistoryResponse]:
        """
                Get WBETH wrap history(USER_DATA)
                GET /sapi/v1/eth-staking/wbeth/history/wrapHistory
                https://developers.binance.com/docs/staking/eth-staking/history/Get-WBETH-wrap-history

                Get WBETH wrap history

        * The time between `startTime` and `endTime` cannot be longer than 3 months.
        * If `startTime` and `endTime` are both not sent, then the last 30 days' data will be returned.
        * If `startTime` is sent but `endTime` is not sent, the next 30 days' data beginning from `startTime` will be returned.
        * If `endTime` is sent but `startTime` is not sent, the 30 days' data before `endTime` will be returned.

        Weight: 150

                Args:
                    start_time (Optional[int] = None):
                    end_time (Optional[int] = None):
                    current (Optional[int] = None): Currently querying page. Start from 1. Default:1
                    size (Optional[int] = None): Default:10, Max:100
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetWbethWrapHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "start_time": start_time,
            "end_time": end_time,
            "current": current,
            "size": size,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/eth-staking/wbeth/history/wrapHistory",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetWbethWrapHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def redeem_eth(
        self,
        amount: Union[float, None],
        asset: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[RedeemEthResponse]:
        """
                Redeem ETH(TRADE)
                POST /sapi/v1/eth-staking/eth/redeem
                https://developers.binance.com/docs/staking/eth-staking/staking/Redeem-ETH

                Redeem WBETH or BETH and get ETH

        * You need to open Enable Spot & Margin Trading permission for the API Key which requests this endpoint.

        Weight: 150

                Args:
                    amount (Union[float, None]): Amount in SOL.
                    asset (Optional[str] = None): WBETH or BETH, default to BETH
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[RedeemEthResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if amount is None:
            raise RequiredError(
                field="amount", error_message="Missing required parameter 'amount'"
            )

        body = {}
        payload = {"amount": amount, "asset": asset, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/eth-staking/eth/redeem",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=RedeemEthResponse,
            is_signed=True,
            signer=self._signer,
        )

    def subscribe_eth_staking(
        self,
        amount: Union[float, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[SubscribeEthStakingResponse]:
        """
                Subscribe ETH Staking(TRADE)
                POST /sapi/v2/eth-staking/eth/stake
                https://developers.binance.com/docs/staking/eth-staking/staking/Subscribe-ETH-Staking

                Subscribe ETH Staking

        * You need to open Enable Spot & Margin Trading permission for the API Key which requests this endpoint.

        Weight: 150

                Args:
                    amount (Union[float, None]): Amount in SOL.
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[SubscribeEthStakingResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if amount is None:
            raise RequiredError(
                field="amount", error_message="Missing required parameter 'amount'"
            )

        body = {}
        payload = {"amount": amount, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v2/eth-staking/eth/stake",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=SubscribeEthStakingResponse,
            is_signed=True,
            signer=self._signer,
        )

    def wrap_beth(
        self,
        amount: Union[float, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[WrapBethResponse]:
        """
                Wrap BETH(TRADE)
                POST /sapi/v1/eth-staking/wbeth/wrap
                https://developers.binance.com/docs/staking/eth-staking/staking/Wrap-BETH

                Wrap BETH

        * You need to open Enable Spot & Margin Trading permission for the API Key which requests this endpoint.

        Weight: 150

                Args:
                    amount (Union[float, None]): Amount in SOL.
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[WrapBethResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        if amount is None:
            raise RequiredError(
                field="amount", error_message="Missing required parameter 'amount'"
            )

        body = {}
        payload = {"amount": amount, "recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/eth-staking/wbeth/wrap",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=WrapBethResponse,
            is_signed=True,
            signer=self._signer,
        )
