use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::derivatives::cmfutures::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetAggTradesV1Params {
pub symbol: String,
pub from_id: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetConstituentsV1Params {
pub symbol: String
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetContinuousKlinesV1Params {
pub pair: String,
pub contract_type: String,
pub interval: String,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetDepthV1Params {
pub symbol: String,
pub limit: Option<i32>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetFundingRateV1Params {
pub symbol: String,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetFuturesDataBasisParams {
pub pair: String,
pub contract_type: String,
pub period: String,
pub limit: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetFuturesDataGlobalLongShortAccountRatioParams {
pub pair: String,
pub period: String,
pub limit: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetFuturesDataOpenInterestHistParams {
pub pair: String,
pub contract_type: String,
pub period: String,
pub limit: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetFuturesDataTakerBuySellVolParams {
pub pair: String,
pub contract_type: String,
pub period: String,
pub limit: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetFuturesDataTopLongShortAccountRatioParams {
pub symbol: String,
pub period: String,
pub limit: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetFuturesDataTopLongShortPositionRatioParams {
pub pair: String,
pub period: String,
pub limit: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetHistoricalTradesV1Params {
pub symbol: String,
pub limit: Option<i32>,
pub from_id: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetIndexPriceKlinesV1Params {
pub pair: String,
pub interval: String,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetKlinesV1Params {
pub symbol: String,
pub interval: String,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetMarkPriceKlinesV1Params {
pub symbol: String,
pub interval: String,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetOpenInterestV1Params {
pub symbol: String
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetPremiumIndexKlinesV1Params {
pub symbol: String,
pub interval: String,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetPremiumIndexV1Params {
pub symbol: Option<String>,
pub pair: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetTicker24hrV1Params {
pub symbol: Option<String>,
pub pair: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetTickerBookTickerV1Params {
pub symbol: Option<String>,
pub pair: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetTickerPriceV1Params {
pub symbol: Option<String>,
pub pair: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CmfuturesGetTradesV1Params {
pub symbol: String,
pub limit: Option<i32>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetAggTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetConstituentsV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetContinuousKlinesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetDepthV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetExchangeInfoV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetFundingInfoV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetFundingRateV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetFuturesDataBasisError {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetFuturesDataGlobalLongShortAccountRatioError {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetFuturesDataOpenInterestHistError {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetFuturesDataTakerBuySellVolError {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetFuturesDataTopLongShortAccountRatioError {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetFuturesDataTopLongShortPositionRatioError {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetHistoricalTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetIndexPriceKlinesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetKlinesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetMarkPriceKlinesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetOpenInterestV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetPingV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetPremiumIndexKlinesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetPremiumIndexV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetTicker24hrV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetTickerBookTickerV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetTickerPriceV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetTimeV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CmfuturesGetTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
pub async fn cmfutures_get_agg_trades_v1(configuration: &configuration::Configuration, params: CmfuturesGetAggTradesV1Params) -> Result<Vec<models::CmfuturesGetAggTradesV1RespItem>, Error<CmfuturesGetAggTradesV1Error>> {
let uri_str = format!("{}/dapi/v1/aggTrades", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.from_id {
query_params.push(("fromId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetAggTradesV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetAggTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetAggTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_constituents_v1(configuration: &configuration::Configuration, params: CmfuturesGetConstituentsV1Params) -> Result<models::CmfuturesGetConstituentsV1Resp, Error<CmfuturesGetConstituentsV1Error>> {
let uri_str = format!("{}/dapi/v1/constituents", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CmfuturesGetConstituentsV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CmfuturesGetConstituentsV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetConstituentsV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_continuous_klines_v1(configuration: &configuration::Configuration, params: CmfuturesGetContinuousKlinesV1Params) -> Result<Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>, Error<CmfuturesGetContinuousKlinesV1Error>> {
let uri_str = format!("{}/dapi/v1/continuousKlines", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("pair".to_string(), params.pair.to_string()));
query_params.push(("contractType".to_string(), params.contract_type.to_string()));
query_params.push(("interval".to_string(), params.interval.to_string()));
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetContinuousKlinesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_depth_v1(configuration: &configuration::Configuration, params: CmfuturesGetDepthV1Params) -> Result<models::CmfuturesGetDepthV1Resp, Error<CmfuturesGetDepthV1Error>> {
let uri_str = format!("{}/dapi/v1/depth", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CmfuturesGetDepthV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CmfuturesGetDepthV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetDepthV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_exchange_info_v1(configuration: &configuration::Configuration) -> Result<models::CmfuturesGetExchangeInfoV1Resp, Error<CmfuturesGetExchangeInfoV1Error>> {
let uri_str = format!("{}/dapi/v1/exchangeInfo", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CmfuturesGetExchangeInfoV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CmfuturesGetExchangeInfoV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetExchangeInfoV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_funding_info_v1(configuration: &configuration::Configuration) -> Result<Vec<models::CmfuturesGetFundingInfoV1RespItem>, Error<CmfuturesGetFundingInfoV1Error>> {
let uri_str = format!("{}/dapi/v1/fundingInfo", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetFundingInfoV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetFundingInfoV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetFundingInfoV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_funding_rate_v1(configuration: &configuration::Configuration, params: CmfuturesGetFundingRateV1Params) -> Result<Vec<models::CmfuturesGetFundingRateV1RespItem>, Error<CmfuturesGetFundingRateV1Error>> {
let uri_str = format!("{}/dapi/v1/fundingRate", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetFundingRateV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetFundingRateV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetFundingRateV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_futures_data_basis(configuration: &configuration::Configuration, params: CmfuturesGetFuturesDataBasisParams) -> Result<Vec<models::CmfuturesGetFuturesDataBasisRespItem>, Error<CmfuturesGetFuturesDataBasisError>> {
let uri_str = format!("{}/futures/data/basis", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("pair".to_string(), params.pair.to_string()));
query_params.push(("contractType".to_string(), params.contract_type.to_string()));
query_params.push(("period".to_string(), params.period.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataBasisRespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataBasisRespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetFuturesDataBasisError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_futures_data_global_long_short_account_ratio(configuration: &configuration::Configuration, params: CmfuturesGetFuturesDataGlobalLongShortAccountRatioParams) -> Result<Vec<models::CmfuturesGetFuturesDataGlobalLongShortAccountRatioRespItem>, Error<CmfuturesGetFuturesDataGlobalLongShortAccountRatioError>> {
let uri_str = format!("{}/futures/data/globalLongShortAccountRatio", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("pair".to_string(), params.pair.to_string()));
query_params.push(("period".to_string(), params.period.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataGlobalLongShortAccountRatioRespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataGlobalLongShortAccountRatioRespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetFuturesDataGlobalLongShortAccountRatioError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_futures_data_open_interest_hist(configuration: &configuration::Configuration, params: CmfuturesGetFuturesDataOpenInterestHistParams) -> Result<Vec<models::CmfuturesGetFuturesDataOpenInterestHistRespItem>, Error<CmfuturesGetFuturesDataOpenInterestHistError>> {
let uri_str = format!("{}/futures/data/openInterestHist", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("pair".to_string(), params.pair.to_string()));
query_params.push(("contractType".to_string(), params.contract_type.to_string()));
query_params.push(("period".to_string(), params.period.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataOpenInterestHistRespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataOpenInterestHistRespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetFuturesDataOpenInterestHistError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_futures_data_taker_buy_sell_vol(configuration: &configuration::Configuration, params: CmfuturesGetFuturesDataTakerBuySellVolParams) -> Result<Vec<models::CmfuturesGetFuturesDataTakerBuySellVolRespItem>, Error<CmfuturesGetFuturesDataTakerBuySellVolError>> {
let uri_str = format!("{}/futures/data/takerBuySellVol", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("pair".to_string(), params.pair.to_string()));
query_params.push(("contractType".to_string(), params.contract_type.to_string()));
query_params.push(("period".to_string(), params.period.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataTakerBuySellVolRespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataTakerBuySellVolRespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetFuturesDataTakerBuySellVolError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_futures_data_top_long_short_account_ratio(configuration: &configuration::Configuration, params: CmfuturesGetFuturesDataTopLongShortAccountRatioParams) -> Result<Vec<models::CmfuturesGetFuturesDataTopLongShortAccountRatioRespItem>, Error<CmfuturesGetFuturesDataTopLongShortAccountRatioError>> {
let uri_str = format!("{}/futures/data/topLongShortAccountRatio", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
query_params.push(("period".to_string(), params.period.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataTopLongShortAccountRatioRespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataTopLongShortAccountRatioRespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetFuturesDataTopLongShortAccountRatioError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_futures_data_top_long_short_position_ratio(configuration: &configuration::Configuration, params: CmfuturesGetFuturesDataTopLongShortPositionRatioParams) -> Result<Vec<models::CmfuturesGetFuturesDataTopLongShortPositionRatioRespItem>, Error<CmfuturesGetFuturesDataTopLongShortPositionRatioError>> {
let uri_str = format!("{}/futures/data/topLongShortPositionRatio", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("pair".to_string(), params.pair.to_string()));
query_params.push(("period".to_string(), params.period.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataTopLongShortPositionRatioRespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetFuturesDataTopLongShortPositionRatioRespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetFuturesDataTopLongShortPositionRatioError> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_historical_trades_v1(configuration: &configuration::Configuration, params: CmfuturesGetHistoricalTradesV1Params) -> Result<Vec<models::CmfuturesGetHistoricalTradesV1RespItem>, Error<CmfuturesGetHistoricalTradesV1Error>> {
let uri_str = format!("{}/dapi/v1/historicalTrades", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.from_id {
query_params.push(("fromId".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetHistoricalTradesV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetHistoricalTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetHistoricalTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_index_price_klines_v1(configuration: &configuration::Configuration, params: CmfuturesGetIndexPriceKlinesV1Params) -> Result<Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>, Error<CmfuturesGetIndexPriceKlinesV1Error>> {
let uri_str = format!("{}/dapi/v1/indexPriceKlines", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("pair".to_string(), params.pair.to_string()));
query_params.push(("interval".to_string(), params.interval.to_string()));
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetIndexPriceKlinesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_klines_v1(configuration: &configuration::Configuration, params: CmfuturesGetKlinesV1Params) -> Result<Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>, Error<CmfuturesGetKlinesV1Error>> {
let uri_str = format!("{}/dapi/v1/klines", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
query_params.push(("interval".to_string(), params.interval.to_string()));
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetKlinesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_mark_price_klines_v1(configuration: &configuration::Configuration, params: CmfuturesGetMarkPriceKlinesV1Params) -> Result<Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>, Error<CmfuturesGetMarkPriceKlinesV1Error>> {
let uri_str = format!("{}/dapi/v1/markPriceKlines", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
query_params.push(("interval".to_string(), params.interval.to_string()));
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetMarkPriceKlinesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_open_interest_v1(configuration: &configuration::Configuration, params: CmfuturesGetOpenInterestV1Params) -> Result<models::CmfuturesGetOpenInterestV1Resp, Error<CmfuturesGetOpenInterestV1Error>> {
let uri_str = format!("{}/dapi/v1/openInterest", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CmfuturesGetOpenInterestV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CmfuturesGetOpenInterestV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetOpenInterestV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_ping_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<CmfuturesGetPingV1Error>> {
let uri_str = format!("{}/dapi/v1/ping", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetPingV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_premium_index_klines_v1(configuration: &configuration::Configuration, params: CmfuturesGetPremiumIndexKlinesV1Params) -> Result<Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>, Error<CmfuturesGetPremiumIndexKlinesV1Error>> {
let uri_str = format!("{}/dapi/v1/premiumIndexKlines", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
query_params.push(("interval".to_string(), params.interval.to_string()));
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<Vec<models::CmfuturesGetContinuousKlinesV1RespInnerInner>>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetPremiumIndexKlinesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_premium_index_v1(configuration: &configuration::Configuration, params: CmfuturesGetPremiumIndexV1Params) -> Result<Vec<models::CmfuturesGetPremiumIndexV1RespItem>, Error<CmfuturesGetPremiumIndexV1Error>> {
let uri_str = format!("{}/dapi/v1/premiumIndex", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.pair {
query_params.push(("pair".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetPremiumIndexV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetPremiumIndexV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetPremiumIndexV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_ticker24hr_v1(configuration: &configuration::Configuration, params: CmfuturesGetTicker24hrV1Params) -> Result<Vec<models::CmfuturesGetTicker24hrV1RespItem>, Error<CmfuturesGetTicker24hrV1Error>> {
let uri_str = format!("{}/dapi/v1/ticker/24hr", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.pair {
query_params.push(("pair".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetTicker24hrV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetTicker24hrV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetTicker24hrV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_ticker_book_ticker_v1(configuration: &configuration::Configuration, params: CmfuturesGetTickerBookTickerV1Params) -> Result<Vec<models::CmfuturesGetTickerBookTickerV1RespItem>, Error<CmfuturesGetTickerBookTickerV1Error>> {
let uri_str = format!("{}/dapi/v1/ticker/bookTicker", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.pair {
query_params.push(("pair".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetTickerBookTickerV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetTickerBookTickerV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetTickerBookTickerV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_ticker_price_v1(configuration: &configuration::Configuration, params: CmfuturesGetTickerPriceV1Params) -> Result<Vec<models::CmfuturesGetTickerPriceV1RespItem>, Error<CmfuturesGetTickerPriceV1Error>> {
let uri_str = format!("{}/dapi/v1/ticker/price", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.pair {
query_params.push(("pair".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetTickerPriceV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetTickerPriceV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetTickerPriceV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_time_v1(configuration: &configuration::Configuration) -> Result<models::CmfuturesGetTimeV1Resp, Error<CmfuturesGetTimeV1Error>> {
let uri_str = format!("{}/dapi/v1/time", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CmfuturesGetTimeV1Resp`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CmfuturesGetTimeV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetTimeV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn cmfutures_get_trades_v1(configuration: &configuration::Configuration, params: CmfuturesGetTradesV1Params) -> Result<Vec<models::CmfuturesGetTradesV1RespItem>, Error<CmfuturesGetTradesV1Error>> {
let uri_str = format!("{}/dapi/v1/trades", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec<models::CmfuturesGetTradesV1RespItem>`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec<models::CmfuturesGetTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CmfuturesGetTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}