#![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,
future_copy_trading_api_client: FutureCopyTradingApiClient,
}
impl RestApi {
pub fn new(configuration: ConfigurationRestApi) -> Self {
let future_copy_trading_api_client = FutureCopyTradingApiClient::new(configuration.clone());
Self {
configuration,
future_copy_trading_api_client,
}
}
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
}
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
}
pub async fn get_futures_lead_trader_status(
&self,
params: GetFuturesLeadTraderStatusParams,
) -> anyhow::Result<RestApiResponse<models::GetFuturesLeadTraderStatusResponse>> {
self.future_copy_trading_api_client
.get_futures_lead_trader_status(params)
.await
}
pub async fn get_futures_lead_trading_symbol_whitelist(
&self,
params: GetFuturesLeadTradingSymbolWhitelistParams,
) -> anyhow::Result<RestApiResponse<models::GetFuturesLeadTradingSymbolWhitelistResponse>> {
self.future_copy_trading_api_client
.get_futures_lead_trading_symbol_whitelist(params)
.await
}
}