use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::subaccount::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Clone, Debug, Default)]
pub struct SubaccountCreateSubAccountFuturesInternalTransferV1Params {
pub amount: String,
pub asset: String,
pub from_email: String,
pub futures_type: i64,
pub timestamp: i64,
pub to_email: String,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountCreateSubAccountFuturesMovePositionV1Params {
pub from_user_email: String,
pub order_args: Vec<serde_json::Value>,
pub product_type: String,
pub timestamp: i64,
pub to_user_email: String,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountCreateSubAccountFuturesTransferV1Params {
pub amount: String,
pub asset: String,
pub email: String,
pub timestamp: i64,
pub r#type: i32,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountCreateSubAccountMarginTransferV1Params {
pub amount: String,
pub asset: String,
pub email: String,
pub timestamp: i64,
pub r#type: i32,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountCreateSubAccountTransferSubToMasterV1Params {
pub amount: String,
pub asset: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountCreateSubAccountTransferSubToSubV1Params {
pub amount: String,
pub asset: String,
pub timestamp: i64,
pub to_email: String,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountCreateSubAccountUniversalTransferV1Params {
pub amount: String,
pub asset: String,
pub from_account_type: String,
pub timestamp: i64,
pub to_account_type: String,
pub client_tran_id: Option<String>,
pub from_email: Option<String>,
pub recv_window: Option<i64>,
pub symbol: Option<String>,
pub to_email: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetCapitalDepositSubAddressV1Params {
pub email: String,
pub coin: String,
pub timestamp: i64,
pub network: Option<String>,
pub amount: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetCapitalDepositSubHisrecV1Params {
pub email: String,
pub timestamp: i64,
pub coin: Option<String>,
pub status: Option<i32>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub offset: Option<i32>,
pub recv_window: Option<i64>,
pub tx_id: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountAssetsV3Params {
pub email: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountAssetsV4Params {
pub email: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountFuturesAccountSummaryV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountFuturesAccountSummaryV2Params {
pub futures_type: i32,
pub timestamp: i64,
pub page: Option<i32>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountFuturesAccountV1Params {
pub email: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountFuturesAccountV2Params {
pub email: String,
pub futures_type: i32,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountFuturesInternalTransferV1Params {
pub email: String,
pub futures_type: i64,
pub timestamp: i64,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub page: Option<i32>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountFuturesMovePositionV1Params {
pub symbol: String,
pub page: i32,
pub row: i32,
pub timestamp: i64,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountMarginAccountSummaryV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountMarginAccountV1Params {
pub email: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountSpotSummaryV1Params {
pub timestamp: i64,
pub email: Option<String>,
pub page: Option<i64>,
pub size: Option<i64>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountSubTransferHistoryV1Params {
pub timestamp: i64,
pub from_email: Option<String>,
pub to_email: Option<String>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub page: Option<i32>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountTransferSubUserHistoryV1Params {
pub timestamp: i64,
pub asset: Option<String>,
pub r#type: Option<i32>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub return_fail_history: Option<bool>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct SubaccountGetSubAccountUniversalTransferV1Params {
pub timestamp: i64,
pub from_email: Option<String>,
pub to_email: Option<String>,
pub client_tran_id: Option<String>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub page: Option<i32>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountCreateSubAccountFuturesInternalTransferV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountCreateSubAccountFuturesMovePositionV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountCreateSubAccountFuturesTransferV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountCreateSubAccountMarginTransferV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountCreateSubAccountTransferSubToMasterV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountCreateSubAccountTransferSubToSubV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountCreateSubAccountUniversalTransferV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetCapitalDepositSubAddressV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetCapitalDepositSubHisrecV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountAssetsV3Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountAssetsV4Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountFuturesAccountSummaryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountFuturesAccountSummaryV2Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountFuturesAccountV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountFuturesAccountV2Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountFuturesInternalTransferV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountFuturesMovePositionV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountMarginAccountSummaryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountMarginAccountV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountSpotSummaryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountSubTransferHistoryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountTransferSubUserHistoryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum SubaccountGetSubAccountUniversalTransferV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
pub async fn subaccount_create_sub_account_futures_internal_transfer_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountFuturesInternalTransferV1Params) -> Result<models::SubaccountCreateSubAccountFuturesInternalTransferV1Resp, Error<SubaccountCreateSubAccountFuturesInternalTransferV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/futures/internalTransfer", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &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 mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("amount", params.amount.to_string());
multipart_form_params.insert("asset", params.asset.to_string());
multipart_form_params.insert("fromEmail", params.from_email.to_string());
multipart_form_params.insert("futuresType", params.futures_type.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
multipart_form_params.insert("toEmail", params.to_email.to_string());
req_builder = req_builder.form(&multipart_form_params);
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::SubaccountCreateSubAccountFuturesInternalTransferV1Resp`"))),
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::SubaccountCreateSubAccountFuturesInternalTransferV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountCreateSubAccountFuturesInternalTransferV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_create_sub_account_futures_move_position_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountFuturesMovePositionV1Params) -> Result<models::SubaccountCreateSubAccountFuturesMovePositionV1Resp, Error<SubaccountCreateSubAccountFuturesMovePositionV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/futures/move-position", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &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 mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("fromUserEmail", params.from_user_email.to_string());
multipart_form_params.insert("orderArgs", params.order_args.into_iter().map(|p| serde_json::to_string(&p).unwrap_or_default()).collect::<Vec<String>>().join(",").to_string());
multipart_form_params.insert("productType", params.product_type.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
multipart_form_params.insert("toUserEmail", params.to_user_email.to_string());
req_builder = req_builder.form(&multipart_form_params);
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::SubaccountCreateSubAccountFuturesMovePositionV1Resp`"))),
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::SubaccountCreateSubAccountFuturesMovePositionV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountCreateSubAccountFuturesMovePositionV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_create_sub_account_futures_transfer_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountFuturesTransferV1Params) -> Result<models::SubaccountCreateSubAccountFuturesTransferV1Resp, Error<SubaccountCreateSubAccountFuturesTransferV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/futures/transfer", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &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 mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("amount", params.amount.to_string());
multipart_form_params.insert("asset", params.asset.to_string());
multipart_form_params.insert("email", params.email.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
multipart_form_params.insert("type", params.r#type.to_string());
req_builder = req_builder.form(&multipart_form_params);
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::SubaccountCreateSubAccountFuturesTransferV1Resp`"))),
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::SubaccountCreateSubAccountFuturesTransferV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountCreateSubAccountFuturesTransferV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_create_sub_account_margin_transfer_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountMarginTransferV1Params) -> Result<models::SubaccountCreateSubAccountMarginTransferV1Resp, Error<SubaccountCreateSubAccountMarginTransferV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/margin/transfer", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &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 mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("amount", params.amount.to_string());
multipart_form_params.insert("asset", params.asset.to_string());
multipart_form_params.insert("email", params.email.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
multipart_form_params.insert("type", params.r#type.to_string());
req_builder = req_builder.form(&multipart_form_params);
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::SubaccountCreateSubAccountMarginTransferV1Resp`"))),
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::SubaccountCreateSubAccountMarginTransferV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountCreateSubAccountMarginTransferV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_create_sub_account_transfer_sub_to_master_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountTransferSubToMasterV1Params) -> Result<models::SubaccountCreateSubAccountTransferSubToMasterV1Resp, Error<SubaccountCreateSubAccountTransferSubToMasterV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/transfer/subToMaster", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &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 mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("amount", params.amount.to_string());
multipart_form_params.insert("asset", params.asset.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
req_builder = req_builder.form(&multipart_form_params);
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::SubaccountCreateSubAccountTransferSubToMasterV1Resp`"))),
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::SubaccountCreateSubAccountTransferSubToMasterV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountCreateSubAccountTransferSubToMasterV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_create_sub_account_transfer_sub_to_sub_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountTransferSubToSubV1Params) -> Result<models::SubaccountCreateSubAccountTransferSubToSubV1Resp, Error<SubaccountCreateSubAccountTransferSubToSubV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/transfer/subToSub", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &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 mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("amount", params.amount.to_string());
multipart_form_params.insert("asset", params.asset.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
multipart_form_params.insert("toEmail", params.to_email.to_string());
req_builder = req_builder.form(&multipart_form_params);
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::SubaccountCreateSubAccountTransferSubToSubV1Resp`"))),
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::SubaccountCreateSubAccountTransferSubToSubV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountCreateSubAccountTransferSubToSubV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_create_sub_account_universal_transfer_v1(configuration: &configuration::Configuration, params: SubaccountCreateSubAccountUniversalTransferV1Params) -> Result<models::SubaccountCreateSubAccountUniversalTransferV1Resp, Error<SubaccountCreateSubAccountUniversalTransferV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/universalTransfer", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::POST, &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 mut multipart_form_params = std::collections::HashMap::new();
multipart_form_params.insert("amount", params.amount.to_string());
multipart_form_params.insert("asset", params.asset.to_string());
if let Some(param_value) = params.client_tran_id {
multipart_form_params.insert("clientTranId", param_value.to_string());
}
multipart_form_params.insert("fromAccountType", params.from_account_type.to_string());
if let Some(param_value) = params.from_email {
multipart_form_params.insert("fromEmail", param_value.to_string());
}
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
if let Some(param_value) = params.symbol {
multipart_form_params.insert("symbol", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
multipart_form_params.insert("toAccountType", params.to_account_type.to_string());
if let Some(param_value) = params.to_email {
multipart_form_params.insert("toEmail", param_value.to_string());
}
req_builder = req_builder.form(&multipart_form_params);
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::SubaccountCreateSubAccountUniversalTransferV1Resp`"))),
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::SubaccountCreateSubAccountUniversalTransferV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountCreateSubAccountUniversalTransferV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_capital_deposit_sub_address_v1(configuration: &configuration::Configuration, params: SubaccountGetCapitalDepositSubAddressV1Params) -> Result<models::SubaccountGetCapitalDepositSubAddressV1Resp, Error<SubaccountGetCapitalDepositSubAddressV1Error>> {
let uri_str = format!("{}/sapi/v1/capital/deposit/subAddress", 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(("email".to_string(), params.email.to_string()));
query_params.push(("coin".to_string(), params.coin.to_string()));
if let Some(ref param_value) = params.network {
query_params.push(("network".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.amount {
query_params.push(("amount".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetCapitalDepositSubAddressV1Resp`"))),
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::SubaccountGetCapitalDepositSubAddressV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetCapitalDepositSubAddressV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_capital_deposit_sub_hisrec_v1(configuration: &configuration::Configuration, params: SubaccountGetCapitalDepositSubHisrecV1Params) -> Result<Vec<models::SubaccountGetCapitalDepositSubHisrecV1RespItem>, Error<SubaccountGetCapitalDepositSubHisrecV1Error>> {
let uri_str = format!("{}/sapi/v1/capital/deposit/subHisrec", 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(("email".to_string(), params.email.to_string()));
if let Some(ref param_value) = params.coin {
query_params.push(("coin".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.status {
query_params.push(("status".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()));
}
if let Some(ref param_value) = params.offset {
query_params.push(("offset".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.to_string()));
if let Some(ref param_value) = params.tx_id {
query_params.push(("txId".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::SubaccountGetCapitalDepositSubHisrecV1RespItem>`"))),
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::SubaccountGetCapitalDepositSubHisrecV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetCapitalDepositSubHisrecV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_assets_v3(configuration: &configuration::Configuration, params: SubaccountGetSubAccountAssetsV3Params) -> Result<models::SubaccountGetSubAccountAssetsV3Resp, Error<SubaccountGetSubAccountAssetsV3Error>> {
let uri_str = format!("{}/sapi/v3/sub-account/assets", 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(("email".to_string(), params.email.to_string()));
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountAssetsV3Resp`"))),
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::SubaccountGetSubAccountAssetsV3Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountAssetsV3Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_assets_v4(configuration: &configuration::Configuration, params: SubaccountGetSubAccountAssetsV4Params) -> Result<models::SubaccountGetSubAccountAssetsV4Resp, Error<SubaccountGetSubAccountAssetsV4Error>> {
let uri_str = format!("{}/sapi/v4/sub-account/assets", 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(("email".to_string(), params.email.to_string()));
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountAssetsV4Resp`"))),
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::SubaccountGetSubAccountAssetsV4Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountAssetsV4Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_futures_account_summary_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesAccountSummaryV1Params) -> Result<models::SubaccountGetSubAccountFuturesAccountSummaryV1Resp, Error<SubaccountGetSubAccountFuturesAccountSummaryV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/futures/accountSummary", 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.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountFuturesAccountSummaryV1Resp`"))),
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::SubaccountGetSubAccountFuturesAccountSummaryV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountFuturesAccountSummaryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_futures_account_summary_v2(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesAccountSummaryV2Params) -> Result<models::SubaccountGetSubAccountFuturesAccountSummaryV2Resp, Error<SubaccountGetSubAccountFuturesAccountSummaryV2Error>> {
let uri_str = format!("{}/sapi/v2/sub-account/futures/accountSummary", 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(("futuresType".to_string(), params.futures_type.to_string()));
if let Some(ref param_value) = params.page {
query_params.push(("page".to_string(), param_value.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.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountFuturesAccountSummaryV2Resp`"))),
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::SubaccountGetSubAccountFuturesAccountSummaryV2Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountFuturesAccountSummaryV2Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_futures_account_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesAccountV1Params) -> Result<models::SubaccountGetSubAccountFuturesAccountV1Resp, Error<SubaccountGetSubAccountFuturesAccountV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/futures/account", 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(("email".to_string(), params.email.to_string()));
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountFuturesAccountV1Resp`"))),
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::SubaccountGetSubAccountFuturesAccountV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountFuturesAccountV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_futures_account_v2(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesAccountV2Params) -> Result<models::SubaccountGetSubAccountFuturesAccountV2Resp, Error<SubaccountGetSubAccountFuturesAccountV2Error>> {
let uri_str = format!("{}/sapi/v2/sub-account/futures/account", 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(("email".to_string(), params.email.to_string()));
query_params.push(("futuresType".to_string(), params.futures_type.to_string()));
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountFuturesAccountV2Resp`"))),
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::SubaccountGetSubAccountFuturesAccountV2Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountFuturesAccountV2Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_futures_internal_transfer_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesInternalTransferV1Params) -> Result<models::SubaccountGetSubAccountFuturesInternalTransferV1Resp, Error<SubaccountGetSubAccountFuturesInternalTransferV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/futures/internalTransfer", 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(("email".to_string(), params.email.to_string()));
query_params.push(("futuresType".to_string(), params.futures_type.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.page {
query_params.push(("page".to_string(), param_value.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.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountFuturesInternalTransferV1Resp`"))),
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::SubaccountGetSubAccountFuturesInternalTransferV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountFuturesInternalTransferV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_futures_move_position_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountFuturesMovePositionV1Params) -> Result<models::SubaccountGetSubAccountFuturesMovePositionV1Resp, Error<SubaccountGetSubAccountFuturesMovePositionV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/futures/move-position", 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()));
}
query_params.push(("page".to_string(), params.page.to_string()));
query_params.push(("row".to_string(), params.row.to_string()));
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountFuturesMovePositionV1Resp`"))),
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::SubaccountGetSubAccountFuturesMovePositionV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountFuturesMovePositionV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_margin_account_summary_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountMarginAccountSummaryV1Params) -> Result<models::SubaccountGetSubAccountMarginAccountSummaryV1Resp, Error<SubaccountGetSubAccountMarginAccountSummaryV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/margin/accountSummary", 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.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountMarginAccountSummaryV1Resp`"))),
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::SubaccountGetSubAccountMarginAccountSummaryV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountMarginAccountSummaryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_margin_account_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountMarginAccountV1Params) -> Result<models::SubaccountGetSubAccountMarginAccountV1Resp, Error<SubaccountGetSubAccountMarginAccountV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/margin/account", 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(("email".to_string(), params.email.to_string()));
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountMarginAccountV1Resp`"))),
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::SubaccountGetSubAccountMarginAccountV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountMarginAccountV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_spot_summary_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountSpotSummaryV1Params) -> Result<models::SubaccountGetSubAccountSpotSummaryV1Resp, Error<SubaccountGetSubAccountSpotSummaryV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/spotSummary", 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.email {
query_params.push(("email".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.page {
query_params.push(("page".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.size {
query_params.push(("size".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountSpotSummaryV1Resp`"))),
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::SubaccountGetSubAccountSpotSummaryV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountSpotSummaryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_sub_transfer_history_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountSubTransferHistoryV1Params) -> Result<Vec<models::SubaccountGetSubAccountSubTransferHistoryV1RespItem>, Error<SubaccountGetSubAccountSubTransferHistoryV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/sub/transfer/history", 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.from_email {
query_params.push(("fromEmail".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.to_email {
query_params.push(("toEmail".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.page {
query_params.push(("page".to_string(), param_value.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.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountSubTransferHistoryV1RespItem>`"))),
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::SubaccountGetSubAccountSubTransferHistoryV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountSubTransferHistoryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_transfer_sub_user_history_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountTransferSubUserHistoryV1Params) -> Result<Vec<models::SubaccountGetSubAccountTransferSubUserHistoryV1RespItem>, Error<SubaccountGetSubAccountTransferSubUserHistoryV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/transfer/subUserHistory", 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.asset {
query_params.push(("asset".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.r#type {
query_params.push(("type".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()));
}
if let Some(ref param_value) = params.return_fail_history {
query_params.push(("returnFailHistory".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountTransferSubUserHistoryV1RespItem>`"))),
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::SubaccountGetSubAccountTransferSubUserHistoryV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountTransferSubUserHistoryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn subaccount_get_sub_account_universal_transfer_v1(configuration: &configuration::Configuration, params: SubaccountGetSubAccountUniversalTransferV1Params) -> Result<models::SubaccountGetSubAccountUniversalTransferV1Resp, Error<SubaccountGetSubAccountUniversalTransferV1Error>> {
let uri_str = format!("{}/sapi/v1/sub-account/universalTransfer", 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.from_email {
query_params.push(("fromEmail".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.to_email {
query_params.push(("toEmail".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.client_tran_id {
query_params.push(("clientTranId".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.page {
query_params.push(("page".to_string(), param_value.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.recv_window {
query_params.push(("recvWindow".to_string(), param_value.to_string()));
}
query_params.push(("timestamp".to_string(), params.timestamp.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::SubaccountGetSubAccountUniversalTransferV1Resp`"))),
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::SubaccountGetSubAccountUniversalTransferV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<SubaccountGetSubAccountUniversalTransferV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}