"""
Binance VIP Loan REST API

OpenAPI Specification for the Binance VIP Loan 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 GetBorrowInterestRateResponse
from ..models import GetCollateralAssetDataResponse
from ..models import GetLoanableAssetsDataResponse


class MarketDataApi:
    """API Client for MarketDataApi 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_borrow_interest_rate(
        self,
        loan_coin: Union[str, None],
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetBorrowInterestRateResponse]:
        """
                Get Borrow Interest Rate(USER_DATA)
                GET /sapi/v1/loan/vip/request/interestRate
                https://developers.binance.com/docs/vip_loan/market-data/Get-Borrow-Interest-Rate

                Get Borrow Interest Rate

        Weight: 400

                Args:
                    loan_coin (Union[str, None]):
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetBorrowInterestRateResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

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

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/loan/vip/request/interestRate",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetBorrowInterestRateResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_collateral_asset_data(
        self,
        collateral_coin: Optional[str] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetCollateralAssetDataResponse]:
        """
                Get Collateral Asset Data(USER_DATA)
                GET /sapi/v1/loan/vip/collateral/data
                https://developers.binance.com/docs/vip_loan/market-data/Get-Collateral-Asset-Data

                Get Collateral Asset Data

        Weight: 400

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

                Returns:
                    ApiResponse[GetCollateralAssetDataResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

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

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/loan/vip/collateral/data",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetCollateralAssetDataResponse,
            is_signed=True,
            signer=self._signer,
        )

    def get_loanable_assets_data(
        self,
        loan_coin: Optional[str] = None,
        vip_level: Optional[int] = None,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[GetLoanableAssetsDataResponse]:
        """
                Get Loanable Assets Data(USER_DATA)
                GET /sapi/v1/loan/vip/loanable/data
                https://developers.binance.com/docs/vip_loan/market-data/Get-Loanable-Assets-Data

                Get interest rate and borrow limit of loanable assets. The borrow limit is shown in USD value.

        Weight: 400

                Args:
                    loan_coin (Optional[str] = None):
                    vip_level (Optional[int] = None): default:user's vip level
                    recv_window (Optional[int] = None):

                Returns:
                    ApiResponse[GetLoanableAssetsDataResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {
            "loan_coin": loan_coin,
            "vip_level": vip_level,
            "recv_window": recv_window,
        }

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/loan/vip/loanable/data",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetLoanableAssetsDataResponse,
            is_signed=True,
            signer=self._signer,
        )
