"""
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 GetSoftStakingProductListResponse
from ..models import GetSoftStakingRewardsHistoryResponse
from ..models import SetSoftStakingResponse


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

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

    def get_soft_staking_product_list(
        self,
        asset: Optional[str] = None,
        current: Optional[int] = None,
        size: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetSoftStakingProductListResponse]:
        """
                Get Soft Staking Product List (USER_DATA)
                GET /sapi/v1/soft-staking/list
                https://developers.binance.com/docs/staking/soft-staking/

                Get the available Soft Staking product list.

        Weight: 50

                Args:
                    asset (Optional[str] = None): WBETH or BETH, default to BETH
                    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[GetSoftStakingProductListResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "asset": asset,
            "current": current,
            "size": size,
            "recv_window": recv_window,
        }

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

    def get_soft_staking_rewards_history(
        self,
        asset: Optional[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[GetSoftStakingRewardsHistoryResponse]:
        """
                Get Soft Staking Rewards History(USER_DATA)
                GET /sapi/v1/soft-staking/history/rewardsRecord
                https://developers.binance.com/docs/staking/soft-staking/Get-Soft-Staking-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: 50

                Args:
                    asset (Optional[str] = None): WBETH or BETH, default to BETH
                    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[GetSoftStakingRewardsHistoryResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "asset": asset,
            "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/soft-staking/history/rewardsRecord",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetSoftStakingRewardsHistoryResponse,
            is_signed=True,
            signer=self._signer,
        )

    def set_soft_staking(
        self,
        soft_staking: Union[bool, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[SetSoftStakingResponse]:
        """
                Set Soft Staking (USER_DATA)
                GET /sapi/v1/soft-staking/set
                https://developers.binance.com/docs/staking/soft-staking/Set-Soft-Staking

                Enable or disable Soft Staking.

        Weight: 50

                Args:
                    soft_staking (Union[bool, None]): true or false
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[SetSoftStakingResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

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