"""
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
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 ClaimBoostRewardsResponse
from ..models import GetBnsolRateHistoryResponse
from ..models import GetBnsolRewardsHistoryResponse
from ..models import GetBoostRewardsHistoryResponse
from ..models import GetSolRedemptionHistoryResponse
from ..models import GetSolStakingHistoryResponse
from ..models import GetSolStakingQuotaDetailsResponse
from ..models import GetUnclaimedRewardsResponse
from ..models import RedeemSolResponse
from ..models import SolStakingAccountResponse
from ..models import SubscribeSolStakingResponse


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

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

    def claim_boost_rewards(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[ClaimBoostRewardsResponse]:
        """
                Claim Boost Rewards(TRADE)
                POST /sapi/v1/sol-staking/sol/claim
                https://developers.binance.com/docs/staking/sol-staking/staking/Claim-Boost-Rewards

                Claim Boost APR Airdrop Rewards

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

        Weight: 150

                Args:
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[ClaimBoostRewardsResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        payload = {"recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/sol-staking/sol/claim",
            payload=payload,
            time_unit=self._configuration.time_unit,
            response_model=ClaimBoostRewardsResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_bnsol_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[GetBnsolRateHistoryResponse]:
        """
                Get BNSOL Rate History(USER_DATA)
                GET /sapi/v1/sol-staking/sol/history/rateHistory
                https://developers.binance.com/docs/staking/sol-staking/history/Get-BNSOL-Rate-History

                Get BNSOL 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]):
                    end_time (Optional[int]):
                    current (Optional[int]): Currently querying page. Start from 1. Default:1
                    size (Optional[int]): Default:10, Max:100
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[GetBnsolRateHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        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/sol-staking/sol/history/rateHistory",
            payload=payload,
            time_unit=self._configuration.time_unit,
            response_model=GetBnsolRateHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_bnsol_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[GetBnsolRewardsHistoryResponse]:
        """
                Get BNSOL rewards history(USER_DATA)
                GET /sapi/v1/sol-staking/sol/history/bnsolRewardsHistory
                https://developers.binance.com/docs/staking/sol-staking/history/Get-BNSOL-rewards-history

                Get BNSOL 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]):
                    end_time (Optional[int]):
                    current (Optional[int]): Currently querying page. Start from 1. Default:1
                    size (Optional[int]): Default:10, Max:100
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[GetBnsolRewardsHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        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/sol-staking/sol/history/bnsolRewardsHistory",
            payload=payload,
            time_unit=self._configuration.time_unit,
            response_model=GetBnsolRewardsHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_boost_rewards_history(
        self,
        type: str = None,
        start_time: Optional[int] = None,
        end_time: Optional[int] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetBoostRewardsHistoryResponse]:
        """
                Get Boost Rewards History(USER_DATA)
                GET /sapi/v1/sol-staking/sol/history/boostRewardsHistory
                https://developers.binance.com/docs/staking/sol-staking/history/Get-Boost-Rewards-History

                Get Boost 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:
                    type (str): "CLAIM", "DISTRIBUTE", default "CLAIM"
                    start_time (Optional[int]):
                    end_time (Optional[int]):
                    current (Optional[int]): Currently querying page. Start from 1. Default:1
                    size (Optional[int]): Default:10, Max:100
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[GetBoostRewardsHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        payload = {
            "type": type,
            "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/sol-staking/sol/history/boostRewardsHistory",
            payload=payload,
            time_unit=self._configuration.time_unit,
            response_model=GetBoostRewardsHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_sol_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[GetSolRedemptionHistoryResponse]:
        """
                Get SOL redemption history(USER_DATA)
                GET /sapi/v1/sol-staking/sol/history/redemptionHistory
                https://developers.binance.com/docs/staking/sol-staking/history/Get-SOL-redemption-history

                Get SOL 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]):
                    end_time (Optional[int]):
                    current (Optional[int]): Currently querying page. Start from 1. Default:1
                    size (Optional[int]): Default:10, Max:100
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[GetSolRedemptionHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        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/sol-staking/sol/history/redemptionHistory",
            payload=payload,
            time_unit=self._configuration.time_unit,
            response_model=GetSolRedemptionHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_sol_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[GetSolStakingHistoryResponse]:
        """
                Get SOL staking history(USER_DATA)
                GET /sapi/v1/sol-staking/sol/history/stakingHistory
                https://developers.binance.com/docs/staking/sol-staking/history/Get-SOL-staking-history

                Get SOL 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]):
                    end_time (Optional[int]):
                    current (Optional[int]): Currently querying page. Start from 1. Default:1
                    size (Optional[int]): Default:10, Max:100
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[GetSolStakingHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        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/sol-staking/sol/history/stakingHistory",
            payload=payload,
            time_unit=self._configuration.time_unit,
            response_model=GetSolStakingHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_sol_staking_quota_details(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetSolStakingQuotaDetailsResponse]:
        """
                Get SOL staking quota details(USER_DATA)
                GET /sapi/v1/sol-staking/sol/quota
                https://developers.binance.com/docs/staking/sol-staking/account/Get-SOL-staking-quota-details

                Get SOL staking quota

        Weight: 150

                Args:
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[GetSolStakingQuotaDetailsResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        payload = {"recv_window": recv_window}

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

    def get_unclaimed_rewards(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetUnclaimedRewardsResponse]:
        """
                Get Unclaimed Rewards(USER_DATA)
                GET /sapi/v1/sol-staking/sol/history/unclaimedRewards
                https://developers.binance.com/docs/staking/sol-staking/history/Get-Unclaimed-Rewards

                Get Unclaimed rewards

        * 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:
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[GetUnclaimedRewardsResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        payload = {"recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/sol-staking/sol/history/unclaimedRewards",
            payload=payload,
            time_unit=self._configuration.time_unit,
            response_model=GetUnclaimedRewardsResponse,
            is_signed=True,
            signer=self._signer,
        )

    def redeem_sol(
        self,
        amount: float = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[RedeemSolResponse]:
        """
                Redeem SOL(TRADE)
                POST /sapi/v1/sol-staking/sol/redeem
                https://developers.binance.com/docs/staking/sol-staking/staking/Redeem-SOL

                Redeem BNSOL get SOL

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

        Weight: 150

                Args:
                    amount (float): Amount in SOL.
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[RedeemSolResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

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

    def sol_staking_account(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[SolStakingAccountResponse]:
        """
                SOL Staking account(USER_DATA)
                GET /sapi/v1/sol-staking/account
                https://developers.binance.com/docs/staking/sol-staking/account/SOL-Staking-account

                SOL Staking account

        Weight: 150

                Args:
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[SolStakingAccountResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        payload = {"recv_window": recv_window}

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/sol-staking/account",
            payload=payload,
            time_unit=self._configuration.time_unit,
            response_model=SolStakingAccountResponse,
            is_signed=True,
            signer=self._signer,
        )

    def subscribe_sol_staking(
        self,
        amount: float = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[SubscribeSolStakingResponse]:
        """
                Subscribe SOL Staking(TRADE)
                POST /sapi/v1/sol-staking/sol/stake
                https://developers.binance.com/docs/staking/sol-staking/staking/Subscribe-SOL-Staking

                Subscribe SOL Staking

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

        Weight: 150

                Args:
                    amount (float): Amount in SOL.
                    recv_window (Optional[int]):

                Returns:
                    ApiResponse[SubscribeSolStakingResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="POST",
            path="/sapi/v1/sol-staking/sol/stake",
            payload=payload,
            time_unit=self._configuration.time_unit,
            response_model=SubscribeSolStakingResponse,
            is_signed=True,
            signer=self._signer,
        )
