"""
Binance Derivatives Trading Portfolio Margin Pro REST API

OpenAPI Specification for the Binance Derivatives Trading Portfolio Margin Pro 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.models import ApiResponse
from binance_common.signature import Signers
from binance_common.utils import send_request

from ..models import GetPortfolioMarginAssetLeverageResponse
from ..models import PortfolioMarginCollateralRateResponse
from ..models import PortfolioMarginProTieredCollateralRateResponse
from ..models import QueryPortfolioMarginAssetIndexPriceResponse


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_portfolio_margin_asset_leverage(
        self,
    ) -> ApiResponse[GetPortfolioMarginAssetLeverageResponse]:
        """
                Get Portfolio Margin Asset Leverage(USER_DATA)
                GET /sapi/v1/portfolio/margin-asset-leverage
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/market-data/Get-Portfolio-Margin-Asset-Leverage

                Get Portfolio Margin Asset Leverage

        Weight: 50

                Args:

                Returns:
                    ApiResponse[GetPortfolioMarginAssetLeverageResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = None
        payload = None

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/margin-asset-leverage",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=GetPortfolioMarginAssetLeverageResponse,
            is_signed=True,
            signer=self._signer,
        )

    def portfolio_margin_collateral_rate(
        self,
    ) -> ApiResponse[PortfolioMarginCollateralRateResponse]:
        """
                Portfolio Margin Collateral Rate(MARKET_DATA)
                GET /sapi/v1/portfolio/collateralRate
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/market-data/Classic-Portfolio-Margin-Collateral-Rate

                Portfolio Margin Collateral Rate

        Weight: 50

                Args:

                Returns:
                    ApiResponse[PortfolioMarginCollateralRateResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = None
        payload = None

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/collateralRate",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=PortfolioMarginCollateralRateResponse,
        )

    def portfolio_margin_pro_tiered_collateral_rate(
        self,
        recv_window: Optional[int] = None,
    ) -> ApiResponse[PortfolioMarginProTieredCollateralRateResponse]:
        """
                Portfolio Margin Pro Tiered Collateral Rate(USER_DATA)
                GET /sapi/v2/portfolio/collateralRate
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/market-data/Portfolio-Margin-Pro-Tiered-Collateral-Rate

                Portfolio Margin PRO Tiered Collateral Rate

        Weight: 50

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

                Returns:
                    ApiResponse[PortfolioMarginProTieredCollateralRateResponse]

                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/portfolio/collateralRate",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=PortfolioMarginProTieredCollateralRateResponse,
            is_signed=True,
            signer=self._signer,
        )

    def query_portfolio_margin_asset_index_price(
        self,
        asset: Optional[str] = None,
    ) -> ApiResponse[QueryPortfolioMarginAssetIndexPriceResponse]:
        """
                Query Portfolio Margin Asset Index Price (MARKET_DATA)
                GET /sapi/v1/portfolio/asset-index-price
                https://developers.binance.com/docs/derivatives/portfolio-margin-pro/market-data/Query-Portfolio-Margin-Asset-Index-Price

                Query Portfolio Margin Asset Index Price

        Weight: 1 if send asset or 50 if not send asset

                Args:
                    asset (Optional[str] = None):

                Returns:
                    ApiResponse[QueryPortfolioMarginAssetIndexPriceResponse]

                Raises:
                    RequiredError: If a required parameter is missing.

        """

        body = {}
        payload = {"asset": asset}

        return send_request(
            self._session,
            self._configuration,
            method="GET",
            path="/sapi/v1/portfolio/asset-index-price",
            payload=payload,
            body=body,
            time_unit=self._configuration.time_unit,
            response_model=QueryPortfolioMarginAssetIndexPriceResponse,
        )
