use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::wallet::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Clone, Debug, Default)]
pub struct WalletCreateCapitalDepositCreditApplyV1Params {
pub deposit_id: Option<i64>,
pub sub_account_id: Option<i64>,
pub sub_user_id: Option<i64>,
pub tx_id: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct WalletCreateCapitalWithdrawApplyV1Params {
pub address: String,
pub amount: String,
pub coin: String,
pub timestamp: i64,
pub address_tag: Option<String>,
pub name: Option<String>,
pub network: Option<String>,
pub recv_window: Option<i64>,
pub transaction_fee_flag: Option<bool>,
pub wallet_type: Option<i32>,
pub withdraw_order_id: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct WalletGetCapitalConfigGetallV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct WalletGetCapitalDepositAddressListV1Params {
pub coin: String,
pub timestamp: i64,
pub network: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct WalletGetCapitalDepositAddressV1Params {
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 WalletGetCapitalDepositHisrecV1Params {
pub timestamp: i64,
pub include_source: Option<bool>,
pub coin: Option<String>,
pub status: Option<i32>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub offset: Option<i32>,
pub limit: Option<i32>,
pub recv_window: Option<i64>,
pub tx_id: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct WalletGetCapitalWithdrawHistoryV1Params {
pub timestamp: i64,
pub coin: Option<String>,
pub withdraw_order_id: Option<String>,
pub status: Option<i32>,
pub offset: Option<i32>,
pub limit: Option<i32>,
pub id_list: Option<String>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub recv_window: Option<i64>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WalletCreateCapitalDepositCreditApplyV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WalletCreateCapitalWithdrawApplyV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WalletGetCapitalConfigGetallV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WalletGetCapitalDepositAddressListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WalletGetCapitalDepositAddressV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WalletGetCapitalDepositHisrecV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WalletGetCapitalWithdrawAddressListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum WalletGetCapitalWithdrawHistoryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
pub async fn wallet_create_capital_deposit_credit_apply_v1(configuration: &configuration::Configuration, params: WalletCreateCapitalDepositCreditApplyV1Params) -> Result<models::WalletCreateCapitalDepositCreditApplyV1Resp, Error<WalletCreateCapitalDepositCreditApplyV1Error>> {
let uri_str = format!("{}/sapi/v1/capital/deposit/credit-apply", 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();
if let Some(param_value) = params.deposit_id {
multipart_form_params.insert("depositId", param_value.to_string());
}
if let Some(param_value) = params.sub_account_id {
multipart_form_params.insert("subAccountId", param_value.to_string());
}
if let Some(param_value) = params.sub_user_id {
multipart_form_params.insert("subUserId", param_value.to_string());
}
if let Some(param_value) = params.tx_id {
multipart_form_params.insert("txId", 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::WalletCreateCapitalDepositCreditApplyV1Resp`"))),
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::WalletCreateCapitalDepositCreditApplyV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WalletCreateCapitalDepositCreditApplyV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn wallet_create_capital_withdraw_apply_v1(configuration: &configuration::Configuration, params: WalletCreateCapitalWithdrawApplyV1Params) -> Result<models::WalletCreateCapitalWithdrawApplyV1Resp, Error<WalletCreateCapitalWithdrawApplyV1Error>> {
let uri_str = format!("{}/sapi/v1/capital/withdraw/apply", 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("address", params.address.to_string());
if let Some(param_value) = params.address_tag {
multipart_form_params.insert("addressTag", param_value.to_string());
}
multipart_form_params.insert("amount", params.amount.to_string());
multipart_form_params.insert("coin", params.coin.to_string());
if let Some(param_value) = params.name {
multipart_form_params.insert("name", param_value.to_string());
}
if let Some(param_value) = params.network {
multipart_form_params.insert("network", param_value.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());
if let Some(param_value) = params.transaction_fee_flag {
multipart_form_params.insert("transactionFeeFlag", param_value.to_string());
}
if let Some(param_value) = params.wallet_type {
multipart_form_params.insert("walletType", param_value.to_string());
}
if let Some(param_value) = params.withdraw_order_id {
multipart_form_params.insert("withdrawOrderId", 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::WalletCreateCapitalWithdrawApplyV1Resp`"))),
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::WalletCreateCapitalWithdrawApplyV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WalletCreateCapitalWithdrawApplyV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn wallet_get_capital_config_getall_v1(configuration: &configuration::Configuration, params: WalletGetCapitalConfigGetallV1Params) -> Result<Vec<models::WalletGetCapitalConfigGetallV1RespItem>, Error<WalletGetCapitalConfigGetallV1Error>> {
let uri_str = format!("{}/sapi/v1/capital/config/getall", 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 `Vec<models::WalletGetCapitalConfigGetallV1RespItem>`"))),
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::WalletGetCapitalConfigGetallV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WalletGetCapitalConfigGetallV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn wallet_get_capital_deposit_address_list_v1(configuration: &configuration::Configuration, params: WalletGetCapitalDepositAddressListV1Params) -> Result<Vec<models::WalletGetCapitalDepositAddressListV1RespItem>, Error<WalletGetCapitalDepositAddressListV1Error>> {
let uri_str = format!("{}/sapi/v1/capital/deposit/address/list", 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(("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()));
}
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::WalletGetCapitalDepositAddressListV1RespItem>`"))),
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::WalletGetCapitalDepositAddressListV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WalletGetCapitalDepositAddressListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn wallet_get_capital_deposit_address_v1(configuration: &configuration::Configuration, params: WalletGetCapitalDepositAddressV1Params) -> Result<models::WalletGetCapitalDepositAddressV1Resp, Error<WalletGetCapitalDepositAddressV1Error>> {
let uri_str = format!("{}/sapi/v1/capital/deposit/address", 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(("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::WalletGetCapitalDepositAddressV1Resp`"))),
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::WalletGetCapitalDepositAddressV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WalletGetCapitalDepositAddressV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn wallet_get_capital_deposit_hisrec_v1(configuration: &configuration::Configuration, params: WalletGetCapitalDepositHisrecV1Params) -> Result<Vec<models::WalletGetCapitalDepositHisrecV1RespItem>, Error<WalletGetCapitalDepositHisrecV1Error>> {
let uri_str = format!("{}/sapi/v1/capital/deposit/hisrec", 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.include_source {
query_params.push(("includeSource".to_string(), param_value.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.offset {
query_params.push(("offset".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()));
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::WalletGetCapitalDepositHisrecV1RespItem>`"))),
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::WalletGetCapitalDepositHisrecV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WalletGetCapitalDepositHisrecV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn wallet_get_capital_withdraw_address_list_v1(configuration: &configuration::Configuration) -> Result<Vec<models::WalletGetCapitalWithdrawAddressListV1RespItem>, Error<WalletGetCapitalWithdrawAddressListV1Error>> {
let uri_str = format!("{}/sapi/v1/capital/withdraw/address/list", 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::WalletGetCapitalWithdrawAddressListV1RespItem>`"))),
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::WalletGetCapitalWithdrawAddressListV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WalletGetCapitalWithdrawAddressListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn wallet_get_capital_withdraw_history_v1(configuration: &configuration::Configuration, params: WalletGetCapitalWithdrawHistoryV1Params) -> Result<Vec<models::WalletGetCapitalWithdrawHistoryV1RespItem>, Error<WalletGetCapitalWithdrawHistoryV1Error>> {
let uri_str = format!("{}/sapi/v1/capital/withdraw/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.coin {
query_params.push(("coin".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.withdraw_order_id {
query_params.push(("withdrawOrderId".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.offset {
query_params.push(("offset".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.id_list {
query_params.push(("idList".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.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::WalletGetCapitalWithdrawHistoryV1RespItem>`"))),
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::WalletGetCapitalWithdrawHistoryV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<WalletGetCapitalWithdrawHistoryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}