use reqwest;
use serde::{Deserialize, Serialize, de::Error as _};
use crate::pmargin::{apis::ResponseContent, models};
use super::{Error, configuration, ContentType};
#[derive(Clone, Debug, Default)]
pub struct CreateAssetCollectionV1Params {
pub asset: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateAutoCollectionV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateBnbTransferV1Params {
pub amount: String,
pub timestamp: i64,
pub transfer_side: String,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateCmConditionalOrderV1Params {
pub side: String,
pub strategy_type: String,
pub symbol: String,
pub timestamp: i64,
pub activation_price: Option<String>,
pub callback_rate: Option<String>,
pub new_client_strategy_id: Option<String>,
pub position_side: Option<String>,
pub price: Option<String>,
pub price_protect: Option<String>,
pub quantity: Option<String>,
pub recv_window: Option<i64>,
pub reduce_only: Option<String>,
pub stop_price: Option<String>,
pub time_in_force: Option<String>,
pub working_type: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CreateCmLeverageV1Params {
pub leverage: i32,
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateCmOrderV1Params {
pub side: String,
pub symbol: String,
pub timestamp: i64,
pub r#type: String,
pub new_client_order_id: Option<String>,
pub new_order_resp_type: Option<String>,
pub position_side: Option<String>,
pub price: Option<String>,
pub price_match: Option<String>,
pub quantity: Option<String>,
pub recv_window: Option<i64>,
pub reduce_only: Option<String>,
pub time_in_force: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CreateCmPositionSideDualV1Params {
pub dual_side_position: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateMarginLoanV1Params {
pub amount: String,
pub asset: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateMarginOrderOcoV1Params {
pub price: String,
pub quantity: String,
pub side: String,
pub stop_price: String,
pub symbol: String,
pub timestamp: i64,
pub limit_client_order_id: Option<String>,
pub limit_iceberg_qty: Option<String>,
pub list_client_order_id: Option<String>,
pub new_order_resp_type: Option<String>,
pub recv_window: Option<i64>,
pub side_effect_type: Option<String>,
pub stop_client_order_id: Option<String>,
pub stop_iceberg_qty: Option<String>,
pub stop_limit_price: Option<String>,
pub stop_limit_time_in_force: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CreateMarginOrderV1Params {
pub side: String,
pub symbol: String,
pub timestamp: i64,
pub r#type: String,
pub auto_repay_at_cancel: Option<bool>,
pub iceberg_qty: Option<String>,
pub new_client_order_id: Option<String>,
pub new_order_resp_type: Option<String>,
pub price: Option<String>,
pub quantity: Option<String>,
pub quote_order_qty: Option<String>,
pub recv_window: Option<i64>,
pub self_trade_prevention_mode: Option<String>,
pub side_effect_type: Option<String>,
pub stop_price: Option<String>,
pub time_in_force: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CreateMarginRepayDebtV1Params {
pub asset: String,
pub timestamp: i64,
pub amount: Option<String>,
pub recv_window: Option<i64>,
pub specify_repay_assets: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CreateRepayFuturesNegativeBalanceV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateRepayFuturesSwitchV1Params {
pub auto_repay: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateRepayLoanV1Params {
pub amount: String,
pub asset: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateUmConditionalOrderV1Params {
pub side: String,
pub strategy_type: String,
pub symbol: String,
pub timestamp: i64,
pub activation_price: Option<String>,
pub callback_rate: Option<String>,
pub good_till_date: Option<i64>,
pub new_client_strategy_id: Option<String>,
pub position_side: Option<String>,
pub price: Option<String>,
pub price_match: Option<String>,
pub price_protect: Option<String>,
pub quantity: Option<String>,
pub recv_window: Option<i64>,
pub reduce_only: Option<String>,
pub self_trade_prevention_mode: Option<String>,
pub stop_price: Option<String>,
pub time_in_force: Option<String>,
pub working_type: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CreateUmFeeBurnV1Params {
pub fee_burn: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateUmLeverageV1Params {
pub leverage: i32,
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct CreateUmOrderV1Params {
pub side: String,
pub symbol: String,
pub timestamp: i64,
pub r#type: String,
pub good_till_date: Option<i64>,
pub new_client_order_id: Option<String>,
pub new_order_resp_type: Option<String>,
pub position_side: Option<String>,
pub price: Option<String>,
pub price_match: Option<String>,
pub quantity: Option<String>,
pub recv_window: Option<i64>,
pub reduce_only: Option<String>,
pub self_trade_prevention_mode: Option<String>,
pub time_in_force: Option<String>
}
#[derive(Clone, Debug, Default)]
pub struct CreateUmPositionSideDualV1Params {
pub dual_side_position: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteCmAllOpenOrdersV1Params {
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteCmConditionalAllOpenOrdersV1Params {
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteCmConditionalOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub strategy_id: Option<i64>,
pub new_client_strategy_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteCmOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteMarginAllOpenOrdersV1Params {
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteMarginOrderListV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_list_id: Option<i64>,
pub list_client_order_id: Option<String>,
pub new_client_order_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteMarginOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub new_client_order_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteUmAllOpenOrdersV1Params {
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteUmConditionalAllOpenOrdersV1Params {
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteUmConditionalOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub strategy_id: Option<i64>,
pub new_client_strategy_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct DeleteUmOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetAccountV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetBalanceV1Params {
pub timestamp: i64,
pub asset: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmAccountV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmAllOrdersV1Params {
pub symbol: String,
pub timestamp: i64,
pub pair: Option<String>,
pub order_id: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmCommissionRateV1Params {
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmConditionalAllOrdersV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub strategy_id: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmConditionalOpenOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub strategy_id: Option<i64>,
pub new_client_strategy_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmConditionalOpenOrdersV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmConditionalOrderHistoryV1Params {
pub symbol: String,
pub timestamp: i64,
pub strategy_id: Option<i64>,
pub new_client_strategy_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmForceOrdersV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub auto_close_type: Option<String>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmIncomeV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub income_type: 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 GetCmLeverageBracketV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmOpenOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmOpenOrdersV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub pair: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmOrderAmendmentV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmPositionRiskV1Params {
pub timestamp: i64,
pub margin_asset: Option<String>,
pub pair: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmPositionSideDualV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetCmUserTradesV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub pair: Option<String>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub from_id: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginAllOrderListV1Params {
pub timestamp: i64,
pub from_id: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginAllOrdersV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginForceOrdersV1Params {
pub timestamp: i64,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub current: Option<i64>,
pub size: Option<i64>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginMarginInterestHistoryV1Params {
pub timestamp: i64,
pub asset: Option<String>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub current: Option<i64>,
pub size: Option<i64>,
pub archived: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginMarginLoanV1Params {
pub asset: String,
pub timestamp: i64,
pub tx_id: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub current: Option<i64>,
pub size: Option<i64>,
pub archived: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginMaxBorrowableV1Params {
pub asset: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginMaxWithdrawV1Params {
pub asset: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginMyTradesV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub from_id: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginOpenOrderListV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginOpenOrdersV1Params {
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginOrderListV1Params {
pub timestamp: i64,
pub order_list_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetMarginRepayLoanV1Params {
pub asset: String,
pub timestamp: i64,
pub tx_id: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub current: Option<i64>,
pub size: Option<i64>,
pub archived: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetPortfolioInterestHistoryV1Params {
pub timestamp: i64,
pub asset: Option<String>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub size: Option<i64>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetPortfolioNegativeBalanceExchangeRecordV1Params {
pub start_time: i64,
pub end_time: i64,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetRateLimitOrderV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetRepayFuturesSwitchV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmAccountConfigV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmAccountV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmAccountV2Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmAdlQuantileV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmAllOrdersV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmApiTradingStatusV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmCommissionRateV1Params {
pub symbol: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmConditionalAllOrdersV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub strategy_id: Option<i64>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmConditionalOpenOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub strategy_id: Option<i64>,
pub new_client_strategy_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmConditionalOrderHistoryV1Params {
pub symbol: String,
pub timestamp: i64,
pub strategy_id: Option<i64>,
pub new_client_strategy_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmFeeBurnV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmForceOrdersV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub auto_close_type: Option<String>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmIncomeAsynIdV1Params {
pub download_id: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmIncomeAsynV1Params {
pub start_time: i64,
pub end_time: i64,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmIncomeV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub income_type: 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 GetUmLeverageBracketV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmOpenOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmOpenOrdersV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmOrderAmendmentV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmOrderAsynIdV1Params {
pub download_id: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmOrderAsynV1Params {
pub start_time: i64,
pub end_time: i64,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmOrderV1Params {
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmPositionSideDualV1Params {
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmSymbolConfigV1Params {
pub timestamp: i64,
pub symbol: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmTradeAsynIdV1Params {
pub download_id: String,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmTradeAsynV1Params {
pub start_time: i64,
pub end_time: i64,
pub timestamp: i64,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct GetUmUserTradesV1Params {
pub symbol: String,
pub timestamp: i64,
pub start_time: Option<i64>,
pub end_time: Option<i64>,
pub from_id: Option<i64>,
pub limit: Option<i32>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct UpdateCmOrderV1Params {
pub price: String,
pub quantity: String,
pub side: String,
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub price_match: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Clone, Debug, Default)]
pub struct UpdateUmOrderV1Params {
pub price: String,
pub quantity: String,
pub side: String,
pub symbol: String,
pub timestamp: i64,
pub order_id: Option<i64>,
pub orig_client_order_id: Option<String>,
pub price_match: Option<String>,
pub recv_window: Option<i64>
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAssetCollectionV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateAutoCollectionV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateBnbTransferV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCmConditionalOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCmLeverageV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCmOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateCmPositionSideDualV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateListenKeyV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateMarginLoanV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateMarginOrderOcoV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateMarginOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateMarginRepayDebtV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateRepayFuturesNegativeBalanceV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateRepayFuturesSwitchV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateRepayLoanV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateUmConditionalOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateUmFeeBurnV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateUmLeverageV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateUmOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum CreateUmPositionSideDualV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCmAllOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCmConditionalAllOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCmConditionalOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteCmOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteListenKeyV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteMarginAllOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteMarginOrderListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteMarginOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteUmAllOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteUmConditionalAllOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteUmConditionalOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum DeleteUmOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetAccountV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetBalanceV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmAccountV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmAdlQuantileV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmAllOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmCommissionRateV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmConditionalAllOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmConditionalOpenOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmConditionalOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmConditionalOrderHistoryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmForceOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmIncomeV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmLeverageBracketV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmOpenOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmOrderAmendmentV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmPositionRiskV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmPositionSideDualV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetCmUserTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginAllOrderListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginAllOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginForceOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginMarginInterestHistoryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginMarginLoanV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginMaxBorrowableV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginMaxWithdrawV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginMyTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginOpenOrderListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginOrderListV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetMarginRepayLoanV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPingV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPortfolioInterestHistoryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetPortfolioNegativeBalanceExchangeRecordV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetRateLimitOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetRepayFuturesSwitchV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmAccountConfigV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmAccountV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmAccountV2Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmAdlQuantileV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmAllOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmApiTradingStatusV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmCommissionRateV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmConditionalAllOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmConditionalOpenOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmConditionalOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmConditionalOrderHistoryV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmFeeBurnV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmForceOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmIncomeAsynIdV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmIncomeAsynV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmIncomeV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmLeverageBracketV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmOpenOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmOpenOrdersV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmOrderAmendmentV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmOrderAsynIdV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmOrderAsynV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmPositionRiskV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmPositionSideDualV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmSymbolConfigV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmTradeAsynIdV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmTradeAsynV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum GetUmUserTradesV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateCmOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateListenKeyV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(untagged)]
pub enum UpdateUmOrderV1Error {
Status4XX(models::ApiError),
Status5XX(models::ApiError),
UnknownValue(serde_json::Value),
}
pub async fn create_asset_collection_v1(configuration: &configuration::Configuration, params: CreateAssetCollectionV1Params) -> Result<models::CreateAssetCollectionV1Resp, Error<CreateAssetCollectionV1Error>> {
let uri_str = format!("{}/papi/v1/asset-collection", 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("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::CreateAssetCollectionV1Resp`"))),
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::CreateAssetCollectionV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAssetCollectionV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_auto_collection_v1(configuration: &configuration::Configuration, params: CreateAutoCollectionV1Params) -> Result<models::CreateAutoCollectionV1Resp, Error<CreateAutoCollectionV1Error>> {
let uri_str = format!("{}/papi/v1/auto-collection", 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.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::CreateAutoCollectionV1Resp`"))),
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::CreateAutoCollectionV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateAutoCollectionV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_bnb_transfer_v1(configuration: &configuration::Configuration, params: CreateBnbTransferV1Params) -> Result<models::CreateBnbTransferV1Resp, Error<CreateBnbTransferV1Error>> {
let uri_str = format!("{}/papi/v1/bnb-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());
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("transferSide", params.transfer_side.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::CreateBnbTransferV1Resp`"))),
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::CreateBnbTransferV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateBnbTransferV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_cm_conditional_order_v1(configuration: &configuration::Configuration, params: CreateCmConditionalOrderV1Params) -> Result<models::CreateCmConditionalOrderV1Resp, Error<CreateCmConditionalOrderV1Error>> {
let uri_str = format!("{}/papi/v1/cm/conditional/order", 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.activation_price {
multipart_form_params.insert("activationPrice", param_value.to_string());
}
if let Some(param_value) = params.callback_rate {
multipart_form_params.insert("callbackRate", param_value.to_string());
}
if let Some(param_value) = params.new_client_strategy_id {
multipart_form_params.insert("newClientStrategyId", param_value.to_string());
}
if let Some(param_value) = params.position_side {
multipart_form_params.insert("positionSide", param_value.to_string());
}
if let Some(param_value) = params.price {
multipart_form_params.insert("price", param_value.to_string());
}
if let Some(param_value) = params.price_protect {
multipart_form_params.insert("priceProtect", param_value.to_string());
}
if let Some(param_value) = params.quantity {
multipart_form_params.insert("quantity", 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.reduce_only {
multipart_form_params.insert("reduceOnly", param_value.to_string());
}
multipart_form_params.insert("side", params.side.to_string());
if let Some(param_value) = params.stop_price {
multipart_form_params.insert("stopPrice", param_value.to_string());
}
multipart_form_params.insert("strategyType", params.strategy_type.to_string());
multipart_form_params.insert("symbol", params.symbol.to_string());
if let Some(param_value) = params.time_in_force {
multipart_form_params.insert("timeInForce", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
if let Some(param_value) = params.working_type {
multipart_form_params.insert("workingType", 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::CreateCmConditionalOrderV1Resp`"))),
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::CreateCmConditionalOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_cm_leverage_v1(configuration: &configuration::Configuration, params: CreateCmLeverageV1Params) -> Result<models::CreateCmLeverageV1Resp, Error<CreateCmLeverageV1Error>> {
let uri_str = format!("{}/papi/v1/cm/leverage", 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("leverage", params.leverage.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("symbol", params.symbol.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::CreateCmLeverageV1Resp`"))),
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::CreateCmLeverageV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCmLeverageV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_cm_order_v1(configuration: &configuration::Configuration, params: CreateCmOrderV1Params) -> Result<models::CreateCmOrderV1Resp, Error<CreateCmOrderV1Error>> {
let uri_str = format!("{}/papi/v1/cm/order", 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.new_client_order_id {
multipart_form_params.insert("newClientOrderId", param_value.to_string());
}
if let Some(param_value) = params.new_order_resp_type {
multipart_form_params.insert("newOrderRespType", param_value.to_string());
}
if let Some(param_value) = params.position_side {
multipart_form_params.insert("positionSide", param_value.to_string());
}
if let Some(param_value) = params.price {
multipart_form_params.insert("price", param_value.to_string());
}
if let Some(param_value) = params.price_match {
multipart_form_params.insert("priceMatch", param_value.to_string());
}
if let Some(param_value) = params.quantity {
multipart_form_params.insert("quantity", 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.reduce_only {
multipart_form_params.insert("reduceOnly", param_value.to_string());
}
multipart_form_params.insert("side", params.side.to_string());
multipart_form_params.insert("symbol", params.symbol.to_string());
if let Some(param_value) = params.time_in_force {
multipart_form_params.insert("timeInForce", 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::CreateCmOrderV1Resp`"))),
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::CreateCmOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCmOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_cm_position_side_dual_v1(configuration: &configuration::Configuration, params: CreateCmPositionSideDualV1Params) -> Result<models::CreateCmPositionSideDualV1Resp, Error<CreateCmPositionSideDualV1Error>> {
let uri_str = format!("{}/papi/v1/cm/positionSide/dual", 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("dualSidePosition", params.dual_side_position.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::CreateCmPositionSideDualV1Resp`"))),
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::CreateCmPositionSideDualV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateCmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_listen_key_v1(configuration: &configuration::Configuration) -> Result<models::CreateListenKeyV1Resp, Error<CreateListenKeyV1Error>> {
let uri_str = format!("{}/papi/v1/listenKey", 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 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::CreateListenKeyV1Resp`"))),
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::CreateListenKeyV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateListenKeyV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_margin_loan_v1(configuration: &configuration::Configuration, params: CreateMarginLoanV1Params) -> Result<models::CreateMarginLoanV1Resp, Error<CreateMarginLoanV1Error>> {
let uri_str = format!("{}/papi/v1/marginLoan", 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::CreateMarginLoanV1Resp`"))),
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::CreateMarginLoanV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateMarginLoanV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_margin_order_oco_v1(configuration: &configuration::Configuration, params: CreateMarginOrderOcoV1Params) -> Result<models::CreateMarginOrderOcoV1Resp, Error<CreateMarginOrderOcoV1Error>> {
let uri_str = format!("{}/papi/v1/margin/order/oco", 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.limit_client_order_id {
multipart_form_params.insert("limitClientOrderId", param_value.to_string());
}
if let Some(param_value) = params.limit_iceberg_qty {
multipart_form_params.insert("limitIcebergQty", param_value.to_string());
}
if let Some(param_value) = params.list_client_order_id {
multipart_form_params.insert("listClientOrderId", param_value.to_string());
}
if let Some(param_value) = params.new_order_resp_type {
multipart_form_params.insert("newOrderRespType", param_value.to_string());
}
multipart_form_params.insert("price", params.price.to_string());
multipart_form_params.insert("quantity", params.quantity.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("side", params.side.to_string());
if let Some(param_value) = params.side_effect_type {
multipart_form_params.insert("sideEffectType", param_value.to_string());
}
if let Some(param_value) = params.stop_client_order_id {
multipart_form_params.insert("stopClientOrderId", param_value.to_string());
}
if let Some(param_value) = params.stop_iceberg_qty {
multipart_form_params.insert("stopIcebergQty", param_value.to_string());
}
if let Some(param_value) = params.stop_limit_price {
multipart_form_params.insert("stopLimitPrice", param_value.to_string());
}
if let Some(param_value) = params.stop_limit_time_in_force {
multipart_form_params.insert("stopLimitTimeInForce", param_value.to_string());
}
multipart_form_params.insert("stopPrice", params.stop_price.to_string());
multipart_form_params.insert("symbol", params.symbol.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::CreateMarginOrderOcoV1Resp`"))),
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::CreateMarginOrderOcoV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateMarginOrderOcoV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_margin_order_v1(configuration: &configuration::Configuration, params: CreateMarginOrderV1Params) -> Result<models::CreateMarginOrderV1Resp, Error<CreateMarginOrderV1Error>> {
let uri_str = format!("{}/papi/v1/margin/order", 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.auto_repay_at_cancel {
multipart_form_params.insert("autoRepayAtCancel", param_value.to_string());
}
if let Some(param_value) = params.iceberg_qty {
multipart_form_params.insert("icebergQty", param_value.to_string());
}
if let Some(param_value) = params.new_client_order_id {
multipart_form_params.insert("newClientOrderId", param_value.to_string());
}
if let Some(param_value) = params.new_order_resp_type {
multipart_form_params.insert("newOrderRespType", param_value.to_string());
}
if let Some(param_value) = params.price {
multipart_form_params.insert("price", param_value.to_string());
}
if let Some(param_value) = params.quantity {
multipart_form_params.insert("quantity", param_value.to_string());
}
if let Some(param_value) = params.quote_order_qty {
multipart_form_params.insert("quoteOrderQty", 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.self_trade_prevention_mode {
multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
}
multipart_form_params.insert("side", params.side.to_string());
if let Some(param_value) = params.side_effect_type {
multipart_form_params.insert("sideEffectType", param_value.to_string());
}
if let Some(param_value) = params.stop_price {
multipart_form_params.insert("stopPrice", param_value.to_string());
}
multipart_form_params.insert("symbol", params.symbol.to_string());
if let Some(param_value) = params.time_in_force {
multipart_form_params.insert("timeInForce", 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::CreateMarginOrderV1Resp`"))),
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::CreateMarginOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateMarginOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_margin_repay_debt_v1(configuration: &configuration::Configuration, params: CreateMarginRepayDebtV1Params) -> Result<models::CreateMarginRepayDebtV1Resp, Error<CreateMarginRepayDebtV1Error>> {
let uri_str = format!("{}/papi/v1/margin/repay-debt", 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.amount {
multipart_form_params.insert("amount", param_value.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());
}
if let Some(param_value) = params.specify_repay_assets {
multipart_form_params.insert("specifyRepayAssets", 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::CreateMarginRepayDebtV1Resp`"))),
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::CreateMarginRepayDebtV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateMarginRepayDebtV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_repay_futures_negative_balance_v1(configuration: &configuration::Configuration, params: CreateRepayFuturesNegativeBalanceV1Params) -> Result<models::CreateRepayFuturesNegativeBalanceV1Resp, Error<CreateRepayFuturesNegativeBalanceV1Error>> {
let uri_str = format!("{}/papi/v1/repay-futures-negative-balance", 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.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::CreateRepayFuturesNegativeBalanceV1Resp`"))),
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::CreateRepayFuturesNegativeBalanceV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateRepayFuturesNegativeBalanceV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_repay_futures_switch_v1(configuration: &configuration::Configuration, params: CreateRepayFuturesSwitchV1Params) -> Result<models::CreateRepayFuturesSwitchV1Resp, Error<CreateRepayFuturesSwitchV1Error>> {
let uri_str = format!("{}/papi/v1/repay-futures-switch", 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("autoRepay", params.auto_repay.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::CreateRepayFuturesSwitchV1Resp`"))),
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::CreateRepayFuturesSwitchV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateRepayFuturesSwitchV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_repay_loan_v1(configuration: &configuration::Configuration, params: CreateRepayLoanV1Params) -> Result<models::CreateRepayLoanV1Resp, Error<CreateRepayLoanV1Error>> {
let uri_str = format!("{}/papi/v1/repayLoan", 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::CreateRepayLoanV1Resp`"))),
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::CreateRepayLoanV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateRepayLoanV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_um_conditional_order_v1(configuration: &configuration::Configuration, params: CreateUmConditionalOrderV1Params) -> Result<models::CreateUmConditionalOrderV1Resp, Error<CreateUmConditionalOrderV1Error>> {
let uri_str = format!("{}/papi/v1/um/conditional/order", 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.activation_price {
multipart_form_params.insert("activationPrice", param_value.to_string());
}
if let Some(param_value) = params.callback_rate {
multipart_form_params.insert("callbackRate", param_value.to_string());
}
if let Some(param_value) = params.good_till_date {
multipart_form_params.insert("goodTillDate", param_value.to_string());
}
if let Some(param_value) = params.new_client_strategy_id {
multipart_form_params.insert("newClientStrategyId", param_value.to_string());
}
if let Some(param_value) = params.position_side {
multipart_form_params.insert("positionSide", param_value.to_string());
}
if let Some(param_value) = params.price {
multipart_form_params.insert("price", param_value.to_string());
}
if let Some(param_value) = params.price_match {
multipart_form_params.insert("priceMatch", param_value.to_string());
}
if let Some(param_value) = params.price_protect {
multipart_form_params.insert("priceProtect", param_value.to_string());
}
if let Some(param_value) = params.quantity {
multipart_form_params.insert("quantity", 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.reduce_only {
multipart_form_params.insert("reduceOnly", param_value.to_string());
}
if let Some(param_value) = params.self_trade_prevention_mode {
multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
}
multipart_form_params.insert("side", params.side.to_string());
if let Some(param_value) = params.stop_price {
multipart_form_params.insert("stopPrice", param_value.to_string());
}
multipart_form_params.insert("strategyType", params.strategy_type.to_string());
multipart_form_params.insert("symbol", params.symbol.to_string());
if let Some(param_value) = params.time_in_force {
multipart_form_params.insert("timeInForce", param_value.to_string());
}
multipart_form_params.insert("timestamp", params.timestamp.to_string());
if let Some(param_value) = params.working_type {
multipart_form_params.insert("workingType", 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::CreateUmConditionalOrderV1Resp`"))),
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::CreateUmConditionalOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateUmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_um_fee_burn_v1(configuration: &configuration::Configuration, params: CreateUmFeeBurnV1Params) -> Result<models::CreateUmFeeBurnV1Resp, Error<CreateUmFeeBurnV1Error>> {
let uri_str = format!("{}/papi/v1/um/feeBurn", 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("feeBurn", params.fee_burn.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::CreateUmFeeBurnV1Resp`"))),
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::CreateUmFeeBurnV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateUmFeeBurnV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_um_leverage_v1(configuration: &configuration::Configuration, params: CreateUmLeverageV1Params) -> Result<models::CreateUmLeverageV1Resp, Error<CreateUmLeverageV1Error>> {
let uri_str = format!("{}/papi/v1/um/leverage", 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("leverage", params.leverage.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("symbol", params.symbol.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::CreateUmLeverageV1Resp`"))),
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::CreateUmLeverageV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateUmLeverageV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_um_order_v1(configuration: &configuration::Configuration, params: CreateUmOrderV1Params) -> Result<models::CreateUmOrderV1Resp, Error<CreateUmOrderV1Error>> {
let uri_str = format!("{}/papi/v1/um/order", 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.good_till_date {
multipart_form_params.insert("goodTillDate", param_value.to_string());
}
if let Some(param_value) = params.new_client_order_id {
multipart_form_params.insert("newClientOrderId", param_value.to_string());
}
if let Some(param_value) = params.new_order_resp_type {
multipart_form_params.insert("newOrderRespType", param_value.to_string());
}
if let Some(param_value) = params.position_side {
multipart_form_params.insert("positionSide", param_value.to_string());
}
if let Some(param_value) = params.price {
multipart_form_params.insert("price", param_value.to_string());
}
if let Some(param_value) = params.price_match {
multipart_form_params.insert("priceMatch", param_value.to_string());
}
if let Some(param_value) = params.quantity {
multipart_form_params.insert("quantity", 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.reduce_only {
multipart_form_params.insert("reduceOnly", param_value.to_string());
}
if let Some(param_value) = params.self_trade_prevention_mode {
multipart_form_params.insert("selfTradePreventionMode", param_value.to_string());
}
multipart_form_params.insert("side", params.side.to_string());
multipart_form_params.insert("symbol", params.symbol.to_string());
if let Some(param_value) = params.time_in_force {
multipart_form_params.insert("timeInForce", 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::CreateUmOrderV1Resp`"))),
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::CreateUmOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateUmOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn create_um_position_side_dual_v1(configuration: &configuration::Configuration, params: CreateUmPositionSideDualV1Params) -> Result<models::CreateUmPositionSideDualV1Resp, Error<CreateUmPositionSideDualV1Error>> {
let uri_str = format!("{}/papi/v1/um/positionSide/dual", 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("dualSidePosition", params.dual_side_position.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::CreateUmPositionSideDualV1Resp`"))),
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::CreateUmPositionSideDualV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<CreateUmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_cm_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteCmAllOpenOrdersV1Params) -> Result<models::DeleteCmAllOpenOrdersV1Resp, Error<DeleteCmAllOpenOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/cm/allOpenOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.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::DeleteCmAllOpenOrdersV1Resp`"))),
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::DeleteCmAllOpenOrdersV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCmAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_cm_conditional_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteCmConditionalAllOpenOrdersV1Params) -> Result<models::DeleteCmConditionalAllOpenOrdersV1Resp, Error<DeleteCmConditionalAllOpenOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/cm/conditional/allOpenOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.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::DeleteCmConditionalAllOpenOrdersV1Resp`"))),
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::DeleteCmConditionalAllOpenOrdersV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCmConditionalAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_cm_conditional_order_v1(configuration: &configuration::Configuration, params: DeleteCmConditionalOrderV1Params) -> Result<models::DeleteCmConditionalOrderV1Resp, Error<DeleteCmConditionalOrderV1Error>> {
let uri_str = format!("{}/papi/v1/cm/conditional/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.strategy_id {
query_params.push(("strategyId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.new_client_strategy_id {
query_params.push(("newClientStrategyId".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::DeleteCmConditionalOrderV1Resp`"))),
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::DeleteCmConditionalOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_cm_order_v1(configuration: &configuration::Configuration, params: DeleteCmOrderV1Params) -> Result<models::DeleteCmOrderV1Resp, Error<DeleteCmOrderV1Error>> {
let uri_str = format!("{}/papi/v1/cm/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".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::DeleteCmOrderV1Resp`"))),
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::DeleteCmOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteCmOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<DeleteListenKeyV1Error>> {
let uri_str = format!("{}/papi/v1/listenKey", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteListenKeyV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_margin_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteMarginAllOpenOrdersV1Params) -> Result<Vec<models::PmarginDeleteMarginAllOpenOrdersV1RespInner>, Error<DeleteMarginAllOpenOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/margin/allOpenOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.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::PmarginDeleteMarginAllOpenOrdersV1RespInner>`"))),
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::PmarginDeleteMarginAllOpenOrdersV1RespInner>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteMarginAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_margin_order_list_v1(configuration: &configuration::Configuration, params: DeleteMarginOrderListV1Params) -> Result<models::DeleteMarginOrderListV1Resp, Error<DeleteMarginOrderListV1Error>> {
let uri_str = format!("{}/papi/v1/margin/orderList", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.order_list_id {
query_params.push(("orderListId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.list_client_order_id {
query_params.push(("listClientOrderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.new_client_order_id {
query_params.push(("newClientOrderId".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::DeleteMarginOrderListV1Resp`"))),
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::DeleteMarginOrderListV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteMarginOrderListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_margin_order_v1(configuration: &configuration::Configuration, params: DeleteMarginOrderV1Params) -> Result<models::DeleteMarginOrderV1Resp, Error<DeleteMarginOrderV1Error>> {
let uri_str = format!("{}/papi/v1/margin/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.new_client_order_id {
query_params.push(("newClientOrderId".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::DeleteMarginOrderV1Resp`"))),
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::DeleteMarginOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteMarginOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_um_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteUmAllOpenOrdersV1Params) -> Result<models::DeleteUmAllOpenOrdersV1Resp, Error<DeleteUmAllOpenOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/um/allOpenOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.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::DeleteUmAllOpenOrdersV1Resp`"))),
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::DeleteUmAllOpenOrdersV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteUmAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_um_conditional_all_open_orders_v1(configuration: &configuration::Configuration, params: DeleteUmConditionalAllOpenOrdersV1Params) -> Result<models::DeleteUmConditionalAllOpenOrdersV1Resp, Error<DeleteUmConditionalAllOpenOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/um/conditional/allOpenOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.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::DeleteUmConditionalAllOpenOrdersV1Resp`"))),
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::DeleteUmConditionalAllOpenOrdersV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteUmConditionalAllOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_um_conditional_order_v1(configuration: &configuration::Configuration, params: DeleteUmConditionalOrderV1Params) -> Result<models::DeleteUmConditionalOrderV1Resp, Error<DeleteUmConditionalOrderV1Error>> {
let uri_str = format!("{}/papi/v1/um/conditional/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.strategy_id {
query_params.push(("strategyId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.new_client_strategy_id {
query_params.push(("newClientStrategyId".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::DeleteUmConditionalOrderV1Resp`"))),
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::DeleteUmConditionalOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteUmConditionalOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn delete_um_order_v1(configuration: &configuration::Configuration, params: DeleteUmOrderV1Params) -> Result<models::DeleteUmOrderV1Resp, Error<DeleteUmOrderV1Error>> {
let uri_str = format!("{}/papi/v1/um/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &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.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".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::DeleteUmOrderV1Resp`"))),
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::DeleteUmOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<DeleteUmOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_account_v1(configuration: &configuration::Configuration, params: GetAccountV1Params) -> Result<models::GetAccountV1Resp, Error<GetAccountV1Error>> {
let uri_str = format!("{}/papi/v1/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();
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::GetAccountV1Resp`"))),
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::GetAccountV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetAccountV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_balance_v1(configuration: &configuration::Configuration, params: GetBalanceV1Params) -> Result<models::PmarginGetBalanceV1Resp, Error<GetBalanceV1Error>> {
let uri_str = format!("{}/papi/v1/balance", 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.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::PmarginGetBalanceV1Resp`"))),
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::PmarginGetBalanceV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetBalanceV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_account_v1(configuration: &configuration::Configuration, params: GetCmAccountV1Params) -> Result<models::GetCmAccountV1Resp, Error<GetCmAccountV1Error>> {
let uri_str = format!("{}/papi/v1/cm/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();
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::GetCmAccountV1Resp`"))),
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::GetCmAccountV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmAccountV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_adl_quantile_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetCmAdlQuantileV1RespItem>, Error<GetCmAdlQuantileV1Error>> {
let uri_str = format!("{}/papi/v1/cm/adlQuantile", 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::GetCmAdlQuantileV1RespItem>`"))),
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::GetCmAdlQuantileV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmAdlQuantileV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_all_orders_v1(configuration: &configuration::Configuration, params: GetCmAllOrdersV1Params) -> Result<Vec<models::GetCmAllOrdersV1RespItem>, Error<GetCmAllOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/cm/allOrders", 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.pair {
query_params.push(("pair".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.order_id {
query_params.push(("orderId".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.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::GetCmAllOrdersV1RespItem>`"))),
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::GetCmAllOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmAllOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_commission_rate_v1(configuration: &configuration::Configuration, params: GetCmCommissionRateV1Params) -> Result<models::GetCmCommissionRateV1Resp, Error<GetCmCommissionRateV1Error>> {
let uri_str = format!("{}/papi/v1/cm/commissionRate", 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.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::GetCmCommissionRateV1Resp`"))),
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::GetCmCommissionRateV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmCommissionRateV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_conditional_all_orders_v1(configuration: &configuration::Configuration, params: GetCmConditionalAllOrdersV1Params) -> Result<Vec<models::GetCmConditionalAllOrdersV1RespItem>, Error<GetCmConditionalAllOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/cm/conditional/allOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.strategy_id {
query_params.push(("strategyId".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.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::GetCmConditionalAllOrdersV1RespItem>`"))),
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::GetCmConditionalAllOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmConditionalAllOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_conditional_open_order_v1(configuration: &configuration::Configuration, params: GetCmConditionalOpenOrderV1Params) -> Result<models::GetCmConditionalOpenOrderV1Resp, Error<GetCmConditionalOpenOrderV1Error>> {
let uri_str = format!("{}/papi/v1/cm/conditional/openOrder", 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.strategy_id {
query_params.push(("strategyId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.new_client_strategy_id {
query_params.push(("newClientStrategyId".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::GetCmConditionalOpenOrderV1Resp`"))),
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::GetCmConditionalOpenOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmConditionalOpenOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_conditional_open_orders_v1(configuration: &configuration::Configuration, params: GetCmConditionalOpenOrdersV1Params) -> Result<Vec<models::GetCmConditionalOpenOrdersV1RespItem>, Error<GetCmConditionalOpenOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/cm/conditional/openOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.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::GetCmConditionalOpenOrdersV1RespItem>`"))),
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::GetCmConditionalOpenOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmConditionalOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_conditional_order_history_v1(configuration: &configuration::Configuration, params: GetCmConditionalOrderHistoryV1Params) -> Result<models::GetCmConditionalOrderHistoryV1Resp, Error<GetCmConditionalOrderHistoryV1Error>> {
let uri_str = format!("{}/papi/v1/cm/conditional/orderHistory", 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.strategy_id {
query_params.push(("strategyId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.new_client_strategy_id {
query_params.push(("newClientStrategyId".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::GetCmConditionalOrderHistoryV1Resp`"))),
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::GetCmConditionalOrderHistoryV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmConditionalOrderHistoryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_force_orders_v1(configuration: &configuration::Configuration, params: GetCmForceOrdersV1Params) -> Result<Vec<models::GetCmForceOrdersV1RespItem>, Error<GetCmForceOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/cm/forceOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.auto_close_type {
query_params.push(("autoCloseType".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.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::GetCmForceOrdersV1RespItem>`"))),
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::GetCmForceOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmForceOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_income_v1(configuration: &configuration::Configuration, params: GetCmIncomeV1Params) -> Result<Vec<models::GetCmIncomeV1RespItem>, Error<GetCmIncomeV1Error>> {
let uri_str = format!("{}/papi/v1/cm/income", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.income_type {
query_params.push(("incomeType".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::GetCmIncomeV1RespItem>`"))),
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::GetCmIncomeV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmIncomeV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_leverage_bracket_v1(configuration: &configuration::Configuration, params: GetCmLeverageBracketV1Params) -> Result<Vec<models::GetCmLeverageBracketV1RespItem>, Error<GetCmLeverageBracketV1Error>> {
let uri_str = format!("{}/papi/v1/cm/leverageBracket", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.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::GetCmLeverageBracketV1RespItem>`"))),
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::GetCmLeverageBracketV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmLeverageBracketV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_open_order_v1(configuration: &configuration::Configuration, params: GetCmOpenOrderV1Params) -> Result<models::GetCmOpenOrderV1Resp, Error<GetCmOpenOrderV1Error>> {
let uri_str = format!("{}/papi/v1/cm/openOrder", 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.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".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::GetCmOpenOrderV1Resp`"))),
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::GetCmOpenOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmOpenOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_open_orders_v1(configuration: &configuration::Configuration, params: GetCmOpenOrdersV1Params) -> Result<Vec<models::GetCmOpenOrdersV1RespItem>, Error<GetCmOpenOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/cm/openOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.pair {
query_params.push(("pair".to_string(), param_value.to_string()));
}
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::GetCmOpenOrdersV1RespItem>`"))),
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::GetCmOpenOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_order_amendment_v1(configuration: &configuration::Configuration, params: GetCmOrderAmendmentV1Params) -> Result<Vec<models::GetCmOrderAmendmentV1RespItem>, Error<GetCmOrderAmendmentV1Error>> {
let uri_str = format!("{}/papi/v1/cm/orderAmendment", 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.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".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.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::GetCmOrderAmendmentV1RespItem>`"))),
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::GetCmOrderAmendmentV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmOrderAmendmentV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_order_v1(configuration: &configuration::Configuration, params: GetCmOrderV1Params) -> Result<models::GetCmOrderV1Resp, Error<GetCmOrderV1Error>> {
let uri_str = format!("{}/papi/v1/cm/order", 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.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".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::GetCmOrderV1Resp`"))),
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::GetCmOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_position_risk_v1(configuration: &configuration::Configuration, params: GetCmPositionRiskV1Params) -> Result<Vec<models::GetCmPositionRiskV1RespItem>, Error<GetCmPositionRiskV1Error>> {
let uri_str = format!("{}/papi/v1/cm/positionRisk", 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.margin_asset {
query_params.push(("marginAsset".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.pair {
query_params.push(("pair".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::GetCmPositionRiskV1RespItem>`"))),
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::GetCmPositionRiskV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmPositionRiskV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_position_side_dual_v1(configuration: &configuration::Configuration, params: GetCmPositionSideDualV1Params) -> Result<models::GetCmPositionSideDualV1Resp, Error<GetCmPositionSideDualV1Error>> {
let uri_str = format!("{}/papi/v1/cm/positionSide/dual", 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::GetCmPositionSideDualV1Resp`"))),
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::GetCmPositionSideDualV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_cm_user_trades_v1(configuration: &configuration::Configuration, params: GetCmUserTradesV1Params) -> Result<Vec<models::GetCmUserTradesV1RespItem>, Error<GetCmUserTradesV1Error>> {
let uri_str = format!("{}/papi/v1/cm/userTrades", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.pair {
query_params.push(("pair".to_string(), param_value.to_string()));
}
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.from_id {
query_params.push(("fromId".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::GetCmUserTradesV1RespItem>`"))),
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::GetCmUserTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetCmUserTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_all_order_list_v1(configuration: &configuration::Configuration, params: GetMarginAllOrderListV1Params) -> Result<Vec<models::GetMarginAllOrderListV1RespItem>, Error<GetMarginAllOrderListV1Error>> {
let uri_str = format!("{}/papi/v1/margin/allOrderList", 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_id {
query_params.push(("fromId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.limit {
query_params.push(("limit".to_string(), param_value.to_string()));
}
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::GetMarginAllOrderListV1RespItem>`"))),
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::GetMarginAllOrderListV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginAllOrderListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_all_orders_v1(configuration: &configuration::Configuration, params: GetMarginAllOrdersV1Params) -> Result<Vec<models::GetMarginAllOrdersV1RespItem>, Error<GetMarginAllOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/margin/allOrders", 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.order_id {
query_params.push(("orderId".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.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::GetMarginAllOrdersV1RespItem>`"))),
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::GetMarginAllOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginAllOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_force_orders_v1(configuration: &configuration::Configuration, params: GetMarginForceOrdersV1Params) -> Result<models::GetMarginForceOrdersV1Resp, Error<GetMarginForceOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/margin/forceOrders", 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.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.current {
query_params.push(("current".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::GetMarginForceOrdersV1Resp`"))),
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::GetMarginForceOrdersV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginForceOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_margin_interest_history_v1(configuration: &configuration::Configuration, params: GetMarginMarginInterestHistoryV1Params) -> Result<models::GetMarginMarginInterestHistoryV1Resp, Error<GetMarginMarginInterestHistoryV1Error>> {
let uri_str = format!("{}/papi/v1/margin/marginInterestHistory", 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.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.current {
query_params.push(("current".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.archived {
query_params.push(("archived".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::GetMarginMarginInterestHistoryV1Resp`"))),
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::GetMarginMarginInterestHistoryV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginMarginInterestHistoryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_margin_loan_v1(configuration: &configuration::Configuration, params: GetMarginMarginLoanV1Params) -> Result<models::GetMarginMarginLoanV1Resp, Error<GetMarginMarginLoanV1Error>> {
let uri_str = format!("{}/papi/v1/margin/marginLoan", 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(("asset".to_string(), params.asset.to_string()));
if let Some(ref param_value) = params.tx_id {
query_params.push(("txId".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.current {
query_params.push(("current".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.archived {
query_params.push(("archived".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::GetMarginMarginLoanV1Resp`"))),
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::GetMarginMarginLoanV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginMarginLoanV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_max_borrowable_v1(configuration: &configuration::Configuration, params: GetMarginMaxBorrowableV1Params) -> Result<models::GetMarginMaxBorrowableV1Resp, Error<GetMarginMaxBorrowableV1Error>> {
let uri_str = format!("{}/papi/v1/margin/maxBorrowable", 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(("asset".to_string(), params.asset.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::GetMarginMaxBorrowableV1Resp`"))),
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::GetMarginMaxBorrowableV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginMaxBorrowableV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_max_withdraw_v1(configuration: &configuration::Configuration, params: GetMarginMaxWithdrawV1Params) -> Result<models::GetMarginMaxWithdrawV1Resp, Error<GetMarginMaxWithdrawV1Error>> {
let uri_str = format!("{}/papi/v1/margin/maxWithdraw", 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(("asset".to_string(), params.asset.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::GetMarginMaxWithdrawV1Resp`"))),
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::GetMarginMaxWithdrawV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginMaxWithdrawV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_my_trades_v1(configuration: &configuration::Configuration, params: GetMarginMyTradesV1Params) -> Result<Vec<models::GetMarginMyTradesV1RespItem>, Error<GetMarginMyTradesV1Error>> {
let uri_str = format!("{}/papi/v1/margin/myTrades", 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.order_id {
query_params.push(("orderId".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.from_id {
query_params.push(("fromId".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::GetMarginMyTradesV1RespItem>`"))),
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::GetMarginMyTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginMyTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_open_order_list_v1(configuration: &configuration::Configuration, params: GetMarginOpenOrderListV1Params) -> Result<Vec<models::GetMarginOpenOrderListV1RespItem>, Error<GetMarginOpenOrderListV1Error>> {
let uri_str = format!("{}/papi/v1/margin/openOrderList", 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::GetMarginOpenOrderListV1RespItem>`"))),
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::GetMarginOpenOrderListV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginOpenOrderListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_open_orders_v1(configuration: &configuration::Configuration, params: GetMarginOpenOrdersV1Params) -> Result<Vec<models::GetMarginOpenOrdersV1RespItem>, Error<GetMarginOpenOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/margin/openOrders", 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.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::GetMarginOpenOrdersV1RespItem>`"))),
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::GetMarginOpenOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_order_list_v1(configuration: &configuration::Configuration, params: GetMarginOrderListV1Params) -> Result<models::GetMarginOrderListV1Resp, Error<GetMarginOrderListV1Error>> {
let uri_str = format!("{}/papi/v1/margin/orderList", 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.order_list_id {
query_params.push(("orderListId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".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::GetMarginOrderListV1Resp`"))),
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::GetMarginOrderListV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginOrderListV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_order_v1(configuration: &configuration::Configuration, params: GetMarginOrderV1Params) -> Result<models::GetMarginOrderV1Resp, Error<GetMarginOrderV1Error>> {
let uri_str = format!("{}/papi/v1/margin/order", 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.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".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::GetMarginOrderV1Resp`"))),
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::GetMarginOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_margin_repay_loan_v1(configuration: &configuration::Configuration, params: GetMarginRepayLoanV1Params) -> Result<models::GetMarginRepayLoanV1Resp, Error<GetMarginRepayLoanV1Error>> {
let uri_str = format!("{}/papi/v1/margin/repayLoan", 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(("asset".to_string(), params.asset.to_string()));
if let Some(ref param_value) = params.tx_id {
query_params.push(("txId".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.current {
query_params.push(("current".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.archived {
query_params.push(("archived".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::GetMarginRepayLoanV1Resp`"))),
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::GetMarginRepayLoanV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetMarginRepayLoanV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_ping_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<GetPingV1Error>> {
let uri_str = format!("{}/papi/v1/ping", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPingV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_portfolio_interest_history_v1(configuration: &configuration::Configuration, params: GetPortfolioInterestHistoryV1Params) -> Result<Vec<models::GetPortfolioInterestHistoryV1RespItem>, Error<GetPortfolioInterestHistoryV1Error>> {
let uri_str = format!("{}/papi/v1/portfolio/interest-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.asset {
query_params.push(("asset".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.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 `Vec<models::GetPortfolioInterestHistoryV1RespItem>`"))),
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::GetPortfolioInterestHistoryV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPortfolioInterestHistoryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_portfolio_negative_balance_exchange_record_v1(configuration: &configuration::Configuration, params: GetPortfolioNegativeBalanceExchangeRecordV1Params) -> Result<models::GetPortfolioNegativeBalanceExchangeRecordV1Resp, Error<GetPortfolioNegativeBalanceExchangeRecordV1Error>> {
let uri_str = format!("{}/papi/v1/portfolio/negative-balance-exchange-record", 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(("startTime".to_string(), params.start_time.to_string()));
query_params.push(("endTime".to_string(), params.end_time.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::GetPortfolioNegativeBalanceExchangeRecordV1Resp`"))),
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::GetPortfolioNegativeBalanceExchangeRecordV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetPortfolioNegativeBalanceExchangeRecordV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_rate_limit_order_v1(configuration: &configuration::Configuration, params: GetRateLimitOrderV1Params) -> Result<Vec<models::GetRateLimitOrderV1RespItem>, Error<GetRateLimitOrderV1Error>> {
let uri_str = format!("{}/papi/v1/rateLimit/order", 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::GetRateLimitOrderV1RespItem>`"))),
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::GetRateLimitOrderV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetRateLimitOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_repay_futures_switch_v1(configuration: &configuration::Configuration, params: GetRepayFuturesSwitchV1Params) -> Result<models::GetRepayFuturesSwitchV1Resp, Error<GetRepayFuturesSwitchV1Error>> {
let uri_str = format!("{}/papi/v1/repay-futures-switch", 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::GetRepayFuturesSwitchV1Resp`"))),
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::GetRepayFuturesSwitchV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetRepayFuturesSwitchV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_account_config_v1(configuration: &configuration::Configuration, params: GetUmAccountConfigV1Params) -> Result<models::GetUmAccountConfigV1Resp, Error<GetUmAccountConfigV1Error>> {
let uri_str = format!("{}/papi/v1/um/accountConfig", 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::GetUmAccountConfigV1Resp`"))),
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::GetUmAccountConfigV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmAccountConfigV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_account_v1(configuration: &configuration::Configuration, params: GetUmAccountV1Params) -> Result<models::GetUmAccountV1Resp, Error<GetUmAccountV1Error>> {
let uri_str = format!("{}/papi/v1/um/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();
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::GetUmAccountV1Resp`"))),
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::GetUmAccountV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmAccountV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_account_v2(configuration: &configuration::Configuration, params: GetUmAccountV2Params) -> Result<models::GetUmAccountV2Resp, Error<GetUmAccountV2Error>> {
let uri_str = format!("{}/papi/v2/um/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();
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::GetUmAccountV2Resp`"))),
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::GetUmAccountV2Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmAccountV2Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_adl_quantile_v1(configuration: &configuration::Configuration, params: GetUmAdlQuantileV1Params) -> Result<Vec<models::GetUmAdlQuantileV1RespItem>, Error<GetUmAdlQuantileV1Error>> {
let uri_str = format!("{}/papi/v1/um/adlQuantile", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.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::GetUmAdlQuantileV1RespItem>`"))),
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::GetUmAdlQuantileV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmAdlQuantileV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_all_orders_v1(configuration: &configuration::Configuration, params: GetUmAllOrdersV1Params) -> Result<Vec<models::GetUmAllOrdersV1RespItem>, Error<GetUmAllOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/um/allOrders", 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.order_id {
query_params.push(("orderId".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.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::GetUmAllOrdersV1RespItem>`"))),
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::GetUmAllOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmAllOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_api_trading_status_v1(configuration: &configuration::Configuration, params: GetUmApiTradingStatusV1Params) -> Result<models::GetUmApiTradingStatusV1Resp, Error<GetUmApiTradingStatusV1Error>> {
let uri_str = format!("{}/papi/v1/um/apiTradingStatus", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.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::GetUmApiTradingStatusV1Resp`"))),
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::GetUmApiTradingStatusV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmApiTradingStatusV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_commission_rate_v1(configuration: &configuration::Configuration, params: GetUmCommissionRateV1Params) -> Result<models::GetUmCommissionRateV1Resp, Error<GetUmCommissionRateV1Error>> {
let uri_str = format!("{}/papi/v1/um/commissionRate", 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.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::GetUmCommissionRateV1Resp`"))),
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::GetUmCommissionRateV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmCommissionRateV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_conditional_all_orders_v1(configuration: &configuration::Configuration, params: GetUmConditionalAllOrdersV1Params) -> Result<Vec<models::GetUmConditionalAllOrdersV1RespItem>, Error<GetUmConditionalAllOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/um/conditional/allOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.strategy_id {
query_params.push(("strategyId".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.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::GetUmConditionalAllOrdersV1RespItem>`"))),
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::GetUmConditionalAllOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmConditionalAllOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_conditional_open_order_v1(configuration: &configuration::Configuration, params: GetUmConditionalOpenOrderV1Params) -> Result<models::GetUmConditionalOpenOrderV1Resp, Error<GetUmConditionalOpenOrderV1Error>> {
let uri_str = format!("{}/papi/v1/um/conditional/openOrder", 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.strategy_id {
query_params.push(("strategyId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.new_client_strategy_id {
query_params.push(("newClientStrategyId".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::GetUmConditionalOpenOrderV1Resp`"))),
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::GetUmConditionalOpenOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmConditionalOpenOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_conditional_open_orders_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetUmConditionalOpenOrdersV1RespItem>, Error<GetUmConditionalOpenOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/um/conditional/openOrders", 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::GetUmConditionalOpenOrdersV1RespItem>`"))),
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::GetUmConditionalOpenOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmConditionalOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_conditional_order_history_v1(configuration: &configuration::Configuration, params: GetUmConditionalOrderHistoryV1Params) -> Result<models::GetUmConditionalOrderHistoryV1Resp, Error<GetUmConditionalOrderHistoryV1Error>> {
let uri_str = format!("{}/papi/v1/um/conditional/orderHistory", 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.strategy_id {
query_params.push(("strategyId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.new_client_strategy_id {
query_params.push(("newClientStrategyId".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::GetUmConditionalOrderHistoryV1Resp`"))),
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::GetUmConditionalOrderHistoryV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmConditionalOrderHistoryV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_fee_burn_v1(configuration: &configuration::Configuration, params: GetUmFeeBurnV1Params) -> Result<models::GetUmFeeBurnV1Resp, Error<GetUmFeeBurnV1Error>> {
let uri_str = format!("{}/papi/v1/um/feeBurn", 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::GetUmFeeBurnV1Resp`"))),
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::GetUmFeeBurnV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmFeeBurnV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_force_orders_v1(configuration: &configuration::Configuration, params: GetUmForceOrdersV1Params) -> Result<Vec<models::GetUmForceOrdersV1RespItem>, Error<GetUmForceOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/um/forceOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.auto_close_type {
query_params.push(("autoCloseType".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.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::GetUmForceOrdersV1RespItem>`"))),
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::GetUmForceOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmForceOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_income_asyn_id_v1(configuration: &configuration::Configuration, params: GetUmIncomeAsynIdV1Params) -> Result<models::GetUmIncomeAsynIdV1Resp, Error<GetUmIncomeAsynIdV1Error>> {
let uri_str = format!("{}/papi/v1/um/income/asyn/id", 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(("downloadId".to_string(), params.download_id.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::GetUmIncomeAsynIdV1Resp`"))),
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::GetUmIncomeAsynIdV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmIncomeAsynIdV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_income_asyn_v1(configuration: &configuration::Configuration, params: GetUmIncomeAsynV1Params) -> Result<models::GetUmIncomeAsynV1Resp, Error<GetUmIncomeAsynV1Error>> {
let uri_str = format!("{}/papi/v1/um/income/asyn", 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(("startTime".to_string(), params.start_time.to_string()));
query_params.push(("endTime".to_string(), params.end_time.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::GetUmIncomeAsynV1Resp`"))),
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::GetUmIncomeAsynV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmIncomeAsynV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_income_v1(configuration: &configuration::Configuration, params: GetUmIncomeV1Params) -> Result<Vec<models::GetUmIncomeV1RespItem>, Error<GetUmIncomeV1Error>> {
let uri_str = format!("{}/papi/v1/um/income", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.income_type {
query_params.push(("incomeType".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::GetUmIncomeV1RespItem>`"))),
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::GetUmIncomeV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmIncomeV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_leverage_bracket_v1(configuration: &configuration::Configuration, params: GetUmLeverageBracketV1Params) -> Result<Vec<models::GetUmLeverageBracketV1RespItem>, Error<GetUmLeverageBracketV1Error>> {
let uri_str = format!("{}/papi/v1/um/leverageBracket", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.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::GetUmLeverageBracketV1RespItem>`"))),
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::GetUmLeverageBracketV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmLeverageBracketV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_open_order_v1(configuration: &configuration::Configuration, params: GetUmOpenOrderV1Params) -> Result<models::GetUmOpenOrderV1Resp, Error<GetUmOpenOrderV1Error>> {
let uri_str = format!("{}/papi/v1/um/openOrder", 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.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".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::GetUmOpenOrderV1Resp`"))),
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::GetUmOpenOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmOpenOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_open_orders_v1(configuration: &configuration::Configuration, params: GetUmOpenOrdersV1Params) -> Result<Vec<models::GetUmOpenOrdersV1RespItem>, Error<GetUmOpenOrdersV1Error>> {
let uri_str = format!("{}/papi/v1/um/openOrders", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.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::GetUmOpenOrdersV1RespItem>`"))),
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::GetUmOpenOrdersV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmOpenOrdersV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_order_amendment_v1(configuration: &configuration::Configuration, params: GetUmOrderAmendmentV1Params) -> Result<Vec<models::GetUmOrderAmendmentV1RespItem>, Error<GetUmOrderAmendmentV1Error>> {
let uri_str = format!("{}/papi/v1/um/orderAmendment", 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.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".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.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::GetUmOrderAmendmentV1RespItem>`"))),
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::GetUmOrderAmendmentV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmOrderAmendmentV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_order_asyn_id_v1(configuration: &configuration::Configuration, params: GetUmOrderAsynIdV1Params) -> Result<models::GetUmOrderAsynIdV1Resp, Error<GetUmOrderAsynIdV1Error>> {
let uri_str = format!("{}/papi/v1/um/order/asyn/id", 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(("downloadId".to_string(), params.download_id.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::GetUmOrderAsynIdV1Resp`"))),
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::GetUmOrderAsynIdV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmOrderAsynIdV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_order_asyn_v1(configuration: &configuration::Configuration, params: GetUmOrderAsynV1Params) -> Result<models::GetUmOrderAsynV1Resp, Error<GetUmOrderAsynV1Error>> {
let uri_str = format!("{}/papi/v1/um/order/asyn", 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(("startTime".to_string(), params.start_time.to_string()));
query_params.push(("endTime".to_string(), params.end_time.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::GetUmOrderAsynV1Resp`"))),
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::GetUmOrderAsynV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmOrderAsynV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_order_v1(configuration: &configuration::Configuration, params: GetUmOrderV1Params) -> Result<models::GetUmOrderV1Resp, Error<GetUmOrderV1Error>> {
let uri_str = format!("{}/papi/v1/um/order", 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.order_id {
query_params.push(("orderId".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.orig_client_order_id {
query_params.push(("origClientOrderId".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::GetUmOrderV1Resp`"))),
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::GetUmOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_position_risk_v1(configuration: &configuration::Configuration) -> Result<Vec<models::GetUmPositionRiskV1RespItem>, Error<GetUmPositionRiskV1Error>> {
let uri_str = format!("{}/papi/v1/um/positionRisk", 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::GetUmPositionRiskV1RespItem>`"))),
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::GetUmPositionRiskV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmPositionRiskV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_position_side_dual_v1(configuration: &configuration::Configuration, params: GetUmPositionSideDualV1Params) -> Result<models::GetUmPositionSideDualV1Resp, Error<GetUmPositionSideDualV1Error>> {
let uri_str = format!("{}/papi/v1/um/positionSide/dual", 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::GetUmPositionSideDualV1Resp`"))),
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::GetUmPositionSideDualV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmPositionSideDualV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_symbol_config_v1(configuration: &configuration::Configuration, params: GetUmSymbolConfigV1Params) -> Result<Vec<models::GetUmSymbolConfigV1RespItem>, Error<GetUmSymbolConfigV1Error>> {
let uri_str = format!("{}/papi/v1/um/symbolConfig", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
if let Some(ref param_value) = params.symbol {
query_params.push(("symbol".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.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::GetUmSymbolConfigV1RespItem>`"))),
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::GetUmSymbolConfigV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmSymbolConfigV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_trade_asyn_id_v1(configuration: &configuration::Configuration, params: GetUmTradeAsynIdV1Params) -> Result<models::GetUmTradeAsynIdV1Resp, Error<GetUmTradeAsynIdV1Error>> {
let uri_str = format!("{}/papi/v1/um/trade/asyn/id", 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(("downloadId".to_string(), params.download_id.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::GetUmTradeAsynIdV1Resp`"))),
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::GetUmTradeAsynIdV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmTradeAsynIdV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_trade_asyn_v1(configuration: &configuration::Configuration, params: GetUmTradeAsynV1Params) -> Result<models::GetUmTradeAsynV1Resp, Error<GetUmTradeAsynV1Error>> {
let uri_str = format!("{}/papi/v1/um/trade/asyn", 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(("startTime".to_string(), params.start_time.to_string()));
query_params.push(("endTime".to_string(), params.end_time.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::GetUmTradeAsynV1Resp`"))),
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::GetUmTradeAsynV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmTradeAsynV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn get_um_user_trades_v1(configuration: &configuration::Configuration, params: GetUmUserTradesV1Params) -> Result<Vec<models::GetUmUserTradesV1RespItem>, Error<GetUmUserTradesV1Error>> {
let uri_str = format!("{}/papi/v1/um/userTrades", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
query_params.push(("symbol".to_string(), params.symbol.to_string()));
if let Some(ref param_value) = params.start_time {
query_params.push(("startTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.end_time {
query_params.push(("endTime".to_string(), param_value.to_string()));
}
if let Some(ref param_value) = params.from_id {
query_params.push(("fromId".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::GetUmUserTradesV1RespItem>`"))),
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::GetUmUserTradesV1RespItem>`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<GetUmUserTradesV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn update_cm_order_v1(configuration: &configuration::Configuration, params: UpdateCmOrderV1Params) -> Result<models::UpdateCmOrderV1Resp, Error<UpdateCmOrderV1Error>> {
let uri_str = format!("{}/papi/v1/cm/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &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.order_id {
multipart_form_params.insert("orderId", param_value.to_string());
}
if let Some(param_value) = params.orig_client_order_id {
multipart_form_params.insert("origClientOrderId", param_value.to_string());
}
multipart_form_params.insert("price", params.price.to_string());
if let Some(param_value) = params.price_match {
multipart_form_params.insert("priceMatch", param_value.to_string());
}
multipart_form_params.insert("quantity", params.quantity.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("side", params.side.to_string());
multipart_form_params.insert("symbol", params.symbol.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::UpdateCmOrderV1Resp`"))),
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::UpdateCmOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateCmOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn update_listen_key_v1(configuration: &configuration::Configuration) -> Result<serde_json::Value, Error<UpdateListenKeyV1Error>> {
let uri_str = format!("{}/papi/v1/listenKey", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &uri_str);
let mut query_params: Vec<(String, String)> = Vec::new();
let mut header_params = std::collections::HashMap::new();
if let Some(ref binance_auth) = configuration.binance_auth {
header_params.insert("X-MBX-APIKEY".to_string(), binance_auth.api_key().to_string());
let body_string: Option<Vec<u8>> = None;
let signature = match binance_auth.sign(Some(&query_params), body_string.as_deref()) {
Ok(sig) => sig,
Err(e) => return Err(Error::Generic(format!("Failed to sign request: {}", e))),
};
query_params.push(("signature".to_string(), signature));
}
if !query_params.is_empty() {
req_builder = req_builder.query(&query_params);
}
if let Some(ref user_agent) = configuration.user_agent {
req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
}
for (header_name, header_value) in header_params {
req_builder = req_builder.header(&header_name, &header_value);
}
let req = req_builder.build()?;
let resp = configuration.client.execute(req).await?;
let status = resp.status();
let content_type = resp
.headers()
.get("content-type")
.and_then(|v| v.to_str().ok())
.unwrap_or("application/octet-stream");
let content_type = super::ContentType::from(content_type);
if !status.is_client_error() && !status.is_server_error() {
let content = resp.text().await?;
match content_type {
ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `serde_json::Value`"))),
ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `serde_json::Value`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateListenKeyV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}
pub async fn update_um_order_v1(configuration: &configuration::Configuration, params: UpdateUmOrderV1Params) -> Result<models::UpdateUmOrderV1Resp, Error<UpdateUmOrderV1Error>> {
let uri_str = format!("{}/papi/v1/um/order", configuration.base_path);
let mut req_builder = configuration.client.request(reqwest::Method::PUT, &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.order_id {
multipart_form_params.insert("orderId", param_value.to_string());
}
if let Some(param_value) = params.orig_client_order_id {
multipart_form_params.insert("origClientOrderId", param_value.to_string());
}
multipart_form_params.insert("price", params.price.to_string());
if let Some(param_value) = params.price_match {
multipart_form_params.insert("priceMatch", param_value.to_string());
}
multipart_form_params.insert("quantity", params.quantity.to_string());
if let Some(param_value) = params.recv_window {
multipart_form_params.insert("recvWindow", param_value.to_string());
}
multipart_form_params.insert("side", params.side.to_string());
multipart_form_params.insert("symbol", params.symbol.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::UpdateUmOrderV1Resp`"))),
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::UpdateUmOrderV1Resp`")))),
}
} else {
let content = resp.text().await?;
let entity: Option<UpdateUmOrderV1Error> = serde_json::from_str(&content).ok();
Err(Error::ResponseError(ResponseContent { status, content, entity }))
}
}