use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::spot::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Clone, Debug, Default)]
pub struct CreateMiningHashTransferConfigCancelV1Params {
pub config_id: i32,
pub timestamp: i64,
pub user_name: String,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateMiningHashTransferConfigV1Params {
pub algo: String,
pub end_date: i64,
pub hash_rate: i64,
pub start_date: i64,
pub timestamp: i64,
pub to_pool_user: String,
pub user_name: String,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMiningHashTransferConfigDetailsListV1Params {
pub timestamp: i64,
pub page_index: Option<i32>,
pub page_size: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMiningHashTransferProfitDetailsV1Params {
pub config_id: i32,
pub user_name: String,
pub timestamp: i64,
pub page_index: Option<i32>,
pub page_size: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMiningPaymentListV1Params {
pub algo: String,
pub user_name: String,
pub timestamp: i64,
pub coin: Option<String>,
pub start_date: Option<i64>,
pub end_date: Option<i64>,
pub page_index: Option<i32>,
pub page_size: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMiningPaymentOtherV1Params {
pub algo: String,
pub user_name: String,
pub timestamp: i64,
pub coin: Option<String>,
pub start_date: Option<i64>,
pub end_date: Option<i64>,
pub page_index: Option<i32>,
pub page_size: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMiningPaymentUidV1Params {
pub algo: String,
pub timestamp: i64,
pub start_date: Option<i64>,
pub end_date: Option<i64>,
pub page_index: Option<i32>,
pub page_size: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMiningStatisticsUserListV1Params {
pub algo: String,
pub user_name: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMiningStatisticsUserStatusV1Params {
pub algo: String,
pub user_name: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMiningWorkerDetailV1Params {
pub algo: String,
pub user_name: String,
pub worker_name: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMiningWorkerListV1Params {
pub algo: String,
pub user_name: String,
pub timestamp: i64,
pub page_index: Option<i32>,
pub sort: Option<i32>,
pub sort_column: Option<i32>,
pub worker_status: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateMiningHashTransferConfigCancelV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateMiningHashTransferConfigV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningHashTransferConfigDetailsListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningHashTransferProfitDetailsV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningPaymentListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningPaymentOtherV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningPaymentUidV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningPubAlgoListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningPubCoinListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningStatisticsUserListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningStatisticsUserStatusV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningWorkerDetailV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMiningWorkerListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
pub async fn create_mining_hash_transfer_config_cancel_v1(configuration: &configuration::Configuration, params: CreateMiningHashTransferConfigCancelV1Params) -> Result<models::CreateMiningHashTransferConfigCancelV1Resp, Error<CreateMiningHashTransferConfigCancelV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/hash-transfer/config/cancel", 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("configId", params.config_id.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("userName", params.user_name.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::CreateMiningHashTransferConfigCancelV1Resp`"))),
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::CreateMiningHashTransferConfigCancelV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateMiningHashTransferConfigCancelV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_mining_hash_transfer_config_v1(configuration: &configuration::Configuration, params: CreateMiningHashTransferConfigV1Params) -> Result<models::CreateMiningHashTransferConfigV1Resp, Error<CreateMiningHashTransferConfigV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/hash-transfer/config", 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("algo", params.algo.to_string());
multipart_form_params.insert("endDate", params.end_date.to_string());
multipart_form_params.insert("hashRate", params.hash_rate.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("startDate", params.start_date.to_string());
multipart_form_params.insert("timestamp", params.timestamp.to_string());
multipart_form_params.insert("toPoolUser", params.to_pool_user.to_string());
multipart_form_params.insert("userName", params.user_name.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::CreateMiningHashTransferConfigV1Resp`"))),
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::CreateMiningHashTransferConfigV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateMiningHashTransferConfigV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_hash_transfer_config_details_list_v1(configuration: &configuration::Configuration, params: GetMiningHashTransferConfigDetailsListV1Params) -> Result<models::GetMiningHashTransferConfigDetailsListV1Resp, Error<GetMiningHashTransferConfigDetailsListV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/hash-transfer/config/details/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();
if let Some(ref param_value) = params.page_index {
query_params.push(("pageIndex".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.page_size {
query_params.push(("pageSize".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::GetMiningHashTransferConfigDetailsListV1Resp`"))),
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::GetMiningHashTransferConfigDetailsListV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningHashTransferConfigDetailsListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_hash_transfer_profit_details_v1(configuration: &configuration::Configuration, params: GetMiningHashTransferProfitDetailsV1Params) -> Result<models::GetMiningHashTransferProfitDetailsV1Resp, Error<GetMiningHashTransferProfitDetailsV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/hash-transfer/profit/details", 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(("configId".to_string(), params.config_id.to_string()));
query_params.push(("userName".to_string(), params.user_name.to_string()));
if let Some(ref param_value) = params.page_index {
query_params.push(("pageIndex".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.page_size {
query_params.push(("pageSize".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::GetMiningHashTransferProfitDetailsV1Resp`"))),
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::GetMiningHashTransferProfitDetailsV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningHashTransferProfitDetailsV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_payment_list_v1(configuration: &configuration::Configuration, params: GetMiningPaymentListV1Params) -> Result<models::GetMiningPaymentListV1Resp, Error<GetMiningPaymentListV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/payment/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(("algo".to_string(), params.algo.to_string()));
query_params.push(("userName".to_string(), params.user_name.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.start_date {
query_params.push(("startDate".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_date {
query_params.push(("endDate".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.page_index {
query_params.push(("pageIndex".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.page_size {
query_params.push(("pageSize".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::GetMiningPaymentListV1Resp`"))),
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::GetMiningPaymentListV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningPaymentListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_payment_other_v1(configuration: &configuration::Configuration, params: GetMiningPaymentOtherV1Params) -> Result<models::GetMiningPaymentOtherV1Resp, Error<GetMiningPaymentOtherV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/payment/other", 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(("algo".to_string(), params.algo.to_string()));
query_params.push(("userName".to_string(), params.user_name.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.start_date {
query_params.push(("startDate".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_date {
query_params.push(("endDate".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.page_index {
query_params.push(("pageIndex".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.page_size {
query_params.push(("pageSize".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::GetMiningPaymentOtherV1Resp`"))),
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::GetMiningPaymentOtherV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningPaymentOtherV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_payment_uid_v1(configuration: &configuration::Configuration, params: GetMiningPaymentUidV1Params) -> Result<models::GetMiningPaymentUidV1Resp, Error<GetMiningPaymentUidV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/payment/uid", 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(("algo".to_string(), params.algo.to_string()));
if let Some(ref param_value) = params.start_date {
query_params.push(("startDate".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_date {
query_params.push(("endDate".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.page_index {
query_params.push(("pageIndex".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.page_size {
query_params.push(("pageSize".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::GetMiningPaymentUidV1Resp`"))),
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::GetMiningPaymentUidV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningPaymentUidV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_pub_algo_list_v1(configuration: &configuration::Configuration) -> Result<models::GetMiningPubAlgoListV1Resp, Error<GetMiningPubAlgoListV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/pub/algoList", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMiningPubAlgoListV1Resp`"))),
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::GetMiningPubAlgoListV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningPubAlgoListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_pub_coin_list_v1(configuration: &configuration::Configuration) -> Result<models::GetMiningPubCoinListV1Resp, Error<GetMiningPubCoinListV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/pub/coinList", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::GetMiningPubCoinListV1Resp`"))),
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::GetMiningPubCoinListV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningPubCoinListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_statistics_user_list_v1(configuration: &configuration::Configuration, params: GetMiningStatisticsUserListV1Params) -> Result<models::GetMiningStatisticsUserListV1Resp, Error<GetMiningStatisticsUserListV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/statistics/user/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(("algo".to_string(), params.algo.to_string()));
query_params.push(("userName".to_string(), params.user_name.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::GetMiningStatisticsUserListV1Resp`"))),
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::GetMiningStatisticsUserListV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningStatisticsUserListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_statistics_user_status_v1(configuration: &configuration::Configuration, params: GetMiningStatisticsUserStatusV1Params) -> Result<models::GetMiningStatisticsUserStatusV1Resp, Error<GetMiningStatisticsUserStatusV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/statistics/user/status", 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(("algo".to_string(), params.algo.to_string()));
query_params.push(("userName".to_string(), params.user_name.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::GetMiningStatisticsUserStatusV1Resp`"))),
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::GetMiningStatisticsUserStatusV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningStatisticsUserStatusV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_worker_detail_v1(configuration: &configuration::Configuration, params: GetMiningWorkerDetailV1Params) -> Result<models::GetMiningWorkerDetailV1Resp, Error<GetMiningWorkerDetailV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/worker/detail", 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(("algo".to_string(), params.algo.to_string()));
query_params.push(("userName".to_string(), params.user_name.to_string()));
query_params.push(("workerName".to_string(), params.worker_name.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::GetMiningWorkerDetailV1Resp`"))),
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::GetMiningWorkerDetailV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningWorkerDetailV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_mining_worker_list_v1(configuration: &configuration::Configuration, params: GetMiningWorkerListV1Params) -> Result<models::GetMiningWorkerListV1Resp, Error<GetMiningWorkerListV1Error>> {
let uri_str = format!("{}/sapi/v1/mining/worker/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(("algo".to_string(), params.algo.to_string()));
query_params.push(("userName".to_string(), params.user_name.to_string()));
if let Some(ref param_value) = params.page_index {
query_params.push(("pageIndex".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.sort {
query_params.push(("sort".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.sort_column {
query_params.push(("sortColumn".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.worker_status {
query_params.push(("workerStatus".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::GetMiningWorkerListV1Resp`"))),
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::GetMiningWorkerListV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMiningWorkerListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}