/*
 * Binance Crypto Loan REST API
 *
 * OpenAPI Specification for the Binance Crypto Loan REST API
 *
 * The version of the OpenAPI document: 1.0.0
 *
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

#![allow(unused_imports)]
use http::Method;
use serde::de::DeserializeOwned;
use serde_json::Value;
use std::collections::BTreeMap;

use crate::common::{config::ConfigurationRestApi, models::RestApiResponse, utils::send_request};

mod apis;
mod models;

pub use apis::*;
pub use models::*;

#[derive(Debug, Clone)]
pub struct RestApi {
    configuration: ConfigurationRestApi,
    flexible_rate_api_client: FlexibleRateApiClient,
    stable_rate_api_client: StableRateApiClient,
}

impl RestApi {
    pub fn new(configuration: ConfigurationRestApi) -> Self {
        let flexible_rate_api_client = FlexibleRateApiClient::new(configuration.clone());
        let stable_rate_api_client = StableRateApiClient::new(configuration.clone());

        Self {
            configuration,
            flexible_rate_api_client,
            stable_rate_api_client,
        }
    }

    /// Send an unsigned request to the API
    ///
    /// # Arguments
    ///
    /// * `endpoint` - The API endpoint to send the request to
    /// * `method` - The HTTP method to use for the request
    /// * `query_params` - A map of query parameters to send with the request
    /// * `body_params` - A map of body parameters to send with the request
    ///
    /// # Returns
    ///
    /// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
    ///
    /// # Errors
    ///
    /// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
    pub async fn send_request<R: DeserializeOwned + Send + 'static>(
        &self,
        endpoint: &str,
        method: Method,
        query_params: BTreeMap<String, Value>,
        body_params: BTreeMap<String, Value>,
    ) -> anyhow::Result<RestApiResponse<R>> {
        send_request::<R>(
            &self.configuration,
            endpoint,
            method,
            query_params,
            body_params,
            None,
            false,
        )
        .await
    }

    /// Send a signed request to the API
    ///
    /// # Arguments
    ///
    /// * `endpoint` - The API endpoint to send the request to
    /// * `method` - The HTTP method to use for the request
    /// * `query_params` - A map of query parameters to send with the request
    /// * `body_params` - A map of body parameters to send with the request
    ///
    /// # Returns
    ///
    /// A `RestApiResponse` containing the deserialized response data on success, or an error if the request fails
    ///
    /// # Errors
    ///
    /// Returns an `anyhow::Error` if the HTTP request fails or if parsing the response fails
    pub async fn send_signed_request<R: DeserializeOwned + Send + 'static>(
        &self,
        endpoint: &str,
        method: Method,
        query_params: BTreeMap<String, Value>,
        body_params: BTreeMap<String, Value>,
    ) -> anyhow::Result<RestApiResponse<R>> {
        send_request::<R>(
            &self.configuration,
            endpoint,
            method,
            query_params,
            body_params,
            None,
            true,
        )
        .await
    }

    /// Check Collateral Repay Rate (`USER_DATA`)
    ///
    ///
    /// Weight: 6000
    ///
    /// # Arguments
    ///
    /// - `params`: [`CheckCollateralRepayRateParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::CheckCollateralRepayRateResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Check-Collateral-Repay-Rate).
    ///
    pub async fn check_collateral_repay_rate(
        &self,
        params: CheckCollateralRepayRateParams,
    ) -> anyhow::Result<RestApiResponse<models::CheckCollateralRepayRateResponse>> {
        self.flexible_rate_api_client
            .check_collateral_repay_rate(params)
            .await
    }

    /// Flexible Loan Adjust LTV(TRADE)
    ///
    /// Flexible Loan Adjust LTV
    ///
    /// * API Key needs Spot & Margin Trading permission for this endpoint
    ///
    /// Weight: 6000
    ///
    /// # Arguments
    ///
    /// - `params`: [`FlexibleLoanAdjustLtvParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::FlexibleLoanAdjustLtvResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/trade/Flexible-Loan-Adjust-LTV).
    ///
    pub async fn flexible_loan_adjust_ltv(
        &self,
        params: FlexibleLoanAdjustLtvParams,
    ) -> anyhow::Result<RestApiResponse<models::FlexibleLoanAdjustLtvResponse>> {
        self.flexible_rate_api_client
            .flexible_loan_adjust_ltv(params)
            .await
    }

    /// Flexible Loan Borrow(TRADE)
    ///
    /// Borrow Flexible Loan
    ///
    ///
    /// * This API endpoint is available for both the master account and the sub-account.
    /// * You can customize LTV by entering loanAmount and collateralAmount.
    ///
    /// Weight: 6000
    ///
    /// # Arguments
    ///
    /// - `params`: [`FlexibleLoanBorrowParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::FlexibleLoanBorrowResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/trade/Flexible-Loan-Borrow).
    ///
    pub async fn flexible_loan_borrow(
        &self,
        params: FlexibleLoanBorrowParams,
    ) -> anyhow::Result<RestApiResponse<models::FlexibleLoanBorrowResponse>> {
        self.flexible_rate_api_client
            .flexible_loan_borrow(params)
            .await
    }

    /// Flexible Loan Repay(TRADE)
    ///
    /// Flexible Loan Repay
    ///
    ///
    /// * repayAmount is mandatory even fullRepayment = FALSE
    ///
    /// Weight: 6000
    ///
    /// # Arguments
    ///
    /// - `params`: [`FlexibleLoanRepayParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::FlexibleLoanRepayResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/trade/Flexible-Loan-Repay).
    ///
    pub async fn flexible_loan_repay(
        &self,
        params: FlexibleLoanRepayParams,
    ) -> anyhow::Result<RestApiResponse<models::FlexibleLoanRepayResponse>> {
        self.flexible_rate_api_client
            .flexible_loan_repay(params)
            .await
    }

    /// Get Flexible Loan Assets `Data(USER_DATA)`
    ///
    /// Get interest rate and borrow limit of flexible loanable assets. The borrow limit is shown in USD value.
    ///
    /// Weight: 400
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFlexibleLoanAssetsDataParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFlexibleLoanAssetsDataResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/market-data/Get-Flexible-Loan-Assets-Data).
    ///
    pub async fn get_flexible_loan_assets_data(
        &self,
        params: GetFlexibleLoanAssetsDataParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFlexibleLoanAssetsDataResponse>> {
        self.flexible_rate_api_client
            .get_flexible_loan_assets_data(params)
            .await
    }

    /// Get Flexible Loan Borrow `History(USER_DATA)`
    ///
    /// Get Flexible Loan Borrow History
    ///
    /// * If startTime and endTime are not sent, the recent 90-day data will be returned.
    /// * The max interval between startTime and endTime is 180 days.
    ///
    /// Weight: 400
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFlexibleLoanBorrowHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFlexibleLoanBorrowHistoryResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-Borrow-History).
    ///
    pub async fn get_flexible_loan_borrow_history(
        &self,
        params: GetFlexibleLoanBorrowHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFlexibleLoanBorrowHistoryResponse>> {
        self.flexible_rate_api_client
            .get_flexible_loan_borrow_history(params)
            .await
    }

    /// Get Flexible Loan Collateral Assets `Data(USER_DATA)`
    ///
    /// Get LTV information and collateral limit of flexible loan's collateral assets. The collateral limit is shown in USD value.
    ///
    /// Weight: 400
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFlexibleLoanCollateralAssetsDataParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFlexibleLoanCollateralAssetsDataResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/market-data/Get-Flexible-Loan-Collateral-Assets-Data).
    ///
    pub async fn get_flexible_loan_collateral_assets_data(
        &self,
        params: GetFlexibleLoanCollateralAssetsDataParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFlexibleLoanCollateralAssetsDataResponse>> {
        self.flexible_rate_api_client
            .get_flexible_loan_collateral_assets_data(params)
            .await
    }

    /// Get Flexible Loan Interest Rate History (`USER_DATA`)
    ///
    /// Check Flexible Loan interest rate history
    ///
    /// * If startTime and endTime are not sent, the recent 90-day data will be returned
    /// * The max interval between startTime and endTime is 90 days.
    /// * Time based on UTC+0.
    ///
    /// Weight: 400
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFlexibleLoanInterestRateHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFlexibleLoanInterestRateHistoryResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/market-data/Get-Flexible-Loan-Interest-Rate-History).
    ///
    pub async fn get_flexible_loan_interest_rate_history(
        &self,
        params: GetFlexibleLoanInterestRateHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFlexibleLoanInterestRateHistoryResponse>> {
        self.flexible_rate_api_client
            .get_flexible_loan_interest_rate_history(params)
            .await
    }

    /// Get Flexible Loan Liquidation History (`USER_DATA`)
    ///
    ///
    /// Weight: 400
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFlexibleLoanLiquidationHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFlexibleLoanLiquidationHistoryResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-Liquidation-History).
    ///
    pub async fn get_flexible_loan_liquidation_history(
        &self,
        params: GetFlexibleLoanLiquidationHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFlexibleLoanLiquidationHistoryResponse>> {
        self.flexible_rate_api_client
            .get_flexible_loan_liquidation_history(params)
            .await
    }

    /// Get Flexible Loan LTV Adjustment `History(USER_DATA)`
    ///
    /// Get Flexible Loan LTV Adjustment History
    ///
    /// * If startTime and endTime are not sent, the recent 90-day data will be returned.
    /// * The max interval between startTime and endTime is 180 days.
    ///
    /// Weight: 400
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFlexibleLoanLtvAdjustmentHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFlexibleLoanLtvAdjustmentHistoryResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-LTV-Adjustment-History).
    ///
    pub async fn get_flexible_loan_ltv_adjustment_history(
        &self,
        params: GetFlexibleLoanLtvAdjustmentHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFlexibleLoanLtvAdjustmentHistoryResponse>> {
        self.flexible_rate_api_client
            .get_flexible_loan_ltv_adjustment_history(params)
            .await
    }

    /// Get Flexible Loan Ongoing `Orders(USER_DATA)`
    ///
    /// Get Flexible Loan Ongoing Orders
    ///
    /// Weight: 300
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFlexibleLoanOngoingOrdersParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFlexibleLoanOngoingOrdersResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-Ongoing-Orders).
    ///
    pub async fn get_flexible_loan_ongoing_orders(
        &self,
        params: GetFlexibleLoanOngoingOrdersParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFlexibleLoanOngoingOrdersResponse>> {
        self.flexible_rate_api_client
            .get_flexible_loan_ongoing_orders(params)
            .await
    }

    /// Get Flexible Loan Repayment `History(USER_DATA)`
    ///
    /// Get Flexible Loan Repayment History
    ///
    /// * If startTime and endTime are not sent, the recent 90-day data will be returned.
    /// * The max interval between startTime and endTime is 180 days.
    ///
    /// Weight: 400
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetFlexibleLoanRepaymentHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetFlexibleLoanRepaymentHistoryResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/flexible-rate/user-information/Get-Flexible-Loan-Repayment-History).
    ///
    pub async fn get_flexible_loan_repayment_history(
        &self,
        params: GetFlexibleLoanRepaymentHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetFlexibleLoanRepaymentHistoryResponse>> {
        self.flexible_rate_api_client
            .get_flexible_loan_repayment_history(params)
            .await
    }

    /// Check Collateral Repay `Rate(USER_DATA)`
    ///
    /// Get the the rate of collateral coin / loan coin when using collateral repay, the rate will be valid within 8 second.
    ///
    /// Weight: 6000
    ///
    /// # Arguments
    ///
    /// - `params`: [`CheckCollateralRepayRateStableRateParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::CheckCollateralRepayRateStableRateResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/stable-rate/market-data/Check-Collateral-Repay-Rate).
    ///
    pub async fn check_collateral_repay_rate_stable_rate(
        &self,
        params: CheckCollateralRepayRateStableRateParams,
    ) -> anyhow::Result<RestApiResponse<models::CheckCollateralRepayRateStableRateResponse>> {
        self.stable_rate_api_client
            .check_collateral_repay_rate_stable_rate(params)
            .await
    }

    /// Get Crypto Loans Income `History(USER_DATA)`
    ///
    /// Get Crypto Loans Income History
    ///
    /// * If startTime and endTime are not sent, the recent 7-day data will be returned.
    /// * The max interval between startTime and endTime is 30 days.
    ///
    /// Weight: 6000
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetCryptoLoansIncomeHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<Vec<models::GetCryptoLoansIncomeHistoryResponseInner>>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/stable-rate/market-data/Get-Crypto-Loans-Income-History).
    ///
    pub async fn get_crypto_loans_income_history(
        &self,
        params: GetCryptoLoansIncomeHistoryParams,
    ) -> anyhow::Result<RestApiResponse<Vec<models::GetCryptoLoansIncomeHistoryResponseInner>>>
    {
        self.stable_rate_api_client
            .get_crypto_loans_income_history(params)
            .await
    }

    /// Get Loan Borrow `History(USER_DATA)`
    ///
    /// Get Loan Borrow History
    ///
    /// * If startTime and endTime are not sent, the recent 90-day data will be returned.
    /// * The max interval between startTime and endTime is 180 days.
    ///
    /// Weight: 400
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetLoanBorrowHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetLoanBorrowHistoryResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/stable-rate/user-information/Get-Loan-Borrow-History).
    ///
    pub async fn get_loan_borrow_history(
        &self,
        params: GetLoanBorrowHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetLoanBorrowHistoryResponse>> {
        self.stable_rate_api_client
            .get_loan_borrow_history(params)
            .await
    }

    /// Get Loan LTV Adjustment `History(USER_DATA)`
    ///
    /// Get Loan LTV Adjustment History
    ///
    /// * If startTime and endTime are not sent, the recent 90-day data will be returned.
    /// * The max interval between startTime and endTime is 180 days.
    ///
    /// Weight: 400
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetLoanLtvAdjustmentHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetLoanLtvAdjustmentHistoryResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/stable-rate/user-information/Get-Loan-LTV-Adjustment-History).
    ///
    pub async fn get_loan_ltv_adjustment_history(
        &self,
        params: GetLoanLtvAdjustmentHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetLoanLtvAdjustmentHistoryResponse>> {
        self.stable_rate_api_client
            .get_loan_ltv_adjustment_history(params)
            .await
    }

    /// Get Loan Repayment `History(USER_DATA)`
    ///
    /// Get Loan Repayment History
    ///
    /// * If startTime and endTime are not sent, the recent 90-day data will be returned.
    /// * The max interval between startTime and endTime is 180 days.
    ///
    /// Weight: 400
    ///
    /// # Arguments
    ///
    /// - `params`: [`GetLoanRepaymentHistoryParams`]
    ///   The parameters for this operation.
    ///
    /// # Returns
    ///
    /// [`RestApiResponse<models::GetLoanRepaymentHistoryResponse>`] on success.
    ///
    /// # Errors
    ///
    /// This function will return an [`anyhow::Error`] if:
    /// - the HTTP request fails
    /// - any parameter is invalid
    /// - the response cannot be parsed
    /// - or one of the following occurs:
    ///   - `RequiredError`
    ///   - `ConnectorClientError`
    ///   - `UnauthorizedError`
    ///   - `ForbiddenError`
    ///   - `TooManyRequestsError`
    ///   - `RateLimitBanError`
    ///   - `ServerError`
    ///   - `NotFoundError`
    ///   - `NetworkError`
    ///   - `BadRequestError`
    ///
    ///
    /// For full API details, see the [Binance API Documentation](https://developers.binance.com/docs/crypto_loan/stable-rate/user-information/Get-Loan-Repayment-History).
    ///
    pub async fn get_loan_repayment_history(
        &self,
        params: GetLoanRepaymentHistoryParams,
    ) -> anyhow::Result<RestApiResponse<models::GetLoanRepaymentHistoryResponse>> {
        self.stable_rate_api_client
            .get_loan_repayment_history(params)
            .await
    }
}
