use crate::client::BybitClient;
use crate::error::Result;
use crate::models::fiat::*;
use crate::models::AccountType;
impl BybitClient {
pub async fn apply_quote(&self, params: ApplyQuoteParams) -> Result<ApplyQuoteResponse> {
self.post("/v5/fiat/quote-apply", ¶ms).await
}
pub async fn confirm_quote(&self, params: ConfirmQuoteParams) -> Result<ConfirmQuoteResponse> {
self.post("/v5/fiat/trade-execute", ¶ms).await
}
pub async fn get_p2p_personal_info(&self) -> Result<serde_json::Value> {
self.post("/v5/p2p/user/personal/info", &serde_json::json!({}))
.await
}
pub async fn get_ads(&self, params: GetAdsParams) -> Result<GetAdsResponse> {
self.post("/v5/p2p/item/online", ¶ms).await
}
pub async fn get_all_orders(&self, params: serde_json::Value) -> Result<serde_json::Value> {
self.post("/v5/p2p/order/simplifyList", ¶ms).await
}
pub async fn get_chat_messages(
&self,
params: GetChatMessagesParams,
) -> Result<GetChatMessagesResponse> {
self.post("/v5/p2p/order/message/listpage", ¶ms).await
}
pub async fn get_coin_balance(
&self,
account_type: AccountType,
member_id: Option<&str>,
coin: Option<&str>,
with_bonus: Option<i64>,
) -> Result<GetCoinBalanceResponse> {
let account_type_str = account_type.to_string();
let with_bonus_str = with_bonus.map(|v| v.to_string());
let mut params = vec![("accountType", account_type_str.as_str())];
if let Some(m) = member_id {
params.push(("memberId", m));
}
if let Some(c) = coin {
params.push(("coin", c));
}
if let Some(ref wb) = with_bonus_str {
params.push(("withBonus", wb.as_str()));
}
self.get("/v5/asset/transfer/query-account-coins-balance", ¶ms)
.await
}
pub async fn get_counterparty_user_info(
&self,
params: GetCounterpartyUserInfoParams,
) -> Result<GetCounterpartyUserInfoResponse> {
self.post("/v5/p2p/user/order/personal/info", ¶ms).await
}
pub async fn get_my_ad_details(
&self,
params: GetMyAdDetailsParams,
) -> Result<GetMyAdDetailsResponse> {
self.post("/v5/p2p/item/info", ¶ms).await
}
pub async fn get_my_ads(&self, params: GetMyAdsParams) -> Result<GetMyAdsResponse> {
self.post("/v5/p2p/item/personal/list", ¶ms).await
}
pub async fn get_order_detail(
&self,
params: GetOrderDetailParams,
) -> Result<GetOrderDetailResponse> {
self.post("/v5/p2p/order/info", ¶ms).await
}
pub async fn get_pending_orders(
&self,
params: GetPendingOrdersParams,
) -> Result<GetPendingOrdersResponse> {
self.post("/v5/p2p/order/pending/simplifyList", ¶ms)
.await
}
pub async fn get_reference_price(
&self,
symbol: &str,
payment_method: Option<&str>,
) -> Result<GetReferencePriceResponse> {
let mut params = vec![("symbol", symbol)];
if let Some(pm) = payment_method {
params.push(("paymentMethod", pm));
}
self.get("/v5/fiat/reference-price", ¶ms).await
}
pub async fn get_user_payment(&self) -> Result<GetUserPaymentResponse> {
self.post("/v5/p2p/user/payment/list", &serde_json::json!({}))
.await
}
pub async fn mark_order_as_paid(
&self,
params: MarkOrderAsPaidParams,
) -> Result<MarkOrderAsPaidResponse> {
self.post("/v5/p2p/order/pay", ¶ms).await
}
pub async fn post_ad(&self, params: PostAdParams) -> Result<PostAdResponse> {
self.post("/v5/p2p/item/create", ¶ms).await
}
pub async fn query_balance(
&self,
account_category: Option<&str>,
currency: Option<&str>,
) -> Result<QueryBalanceResponse> {
let mut params = vec![];
if let Some(ac) = account_category {
params.push(("accountCategory", ac));
}
if let Some(c) = currency {
params.push(("currency", c));
}
self.get("/v5/fiat/balance-query", ¶ms).await
}
pub async fn query_coin_list(&self, side: Option<i64>) -> Result<QueryCoinListResponse> {
let side_str = side.map(|v| v.to_string());
let mut params = vec![];
if let Some(ref s) = side_str {
params.push(("side", s.as_str()));
}
self.get("/v5/fiat/query-coin-list", ¶ms).await
}
pub async fn query_funding_detail_api(
&self,
create_time_from: Option<&str>,
create_time_to: Option<&str>,
limit: Option<&str>,
cursor: Option<&str>,
) -> Result<QueryFundingDetailApiResponse> {
let mut params = vec![];
if let Some(v) = create_time_from {
params.push(("createTimeFrom", v));
}
if let Some(v) = create_time_to {
params.push(("createTimeTo", v));
}
if let Some(v) = limit {
params.push(("limit", v));
}
if let Some(v) = cursor {
params.push(("cursor", v));
}
self.get("/v5/asset/fundinghistory", ¶ms).await
}
pub async fn query_trade(
&self,
trade_no: Option<&str>,
merchant_request_id: Option<&str>,
) -> Result<QueryTradeResponse> {
let mut params = vec![];
if let Some(v) = trade_no {
params.push(("tradeNo", v));
}
if let Some(v) = merchant_request_id {
params.push(("merchantRequestId", v));
}
self.get("/v5/fiat/trade-query", ¶ms).await
}
pub async fn query_trade_history(
&self,
index: Option<i64>,
limit: Option<i64>,
start_time: Option<&str>,
end_time: Option<&str>,
) -> Result<QueryTradeHistoryResponse> {
let index_str = index.map(|v| v.to_string());
let limit_str = limit.map(|v| v.to_string());
let mut params = vec![];
if let Some(ref v) = index_str {
params.push(("index", v.as_str()));
}
if let Some(ref v) = limit_str {
params.push(("limit", v.as_str()));
}
if let Some(v) = start_time {
params.push(("startTime", v));
}
if let Some(v) = end_time {
params.push(("endTime", v));
}
self.get("/v5/fiat/query-trade-history", ¶ms).await
}
pub async fn release_assets(&self, params: ReleaseAssetsParams) -> Result<serde_json::Value> {
self.post("/v5/p2p/order/finish", ¶ms).await
}
pub async fn remove_ad(&self, params: RemoveAdParams) -> Result<serde_json::Value> {
self.post("/v5/p2p/item/cancel", ¶ms).await
}
pub async fn send_chat_message(
&self,
params: SendChatMessageParams,
) -> Result<serde_json::Value> {
self.post("/v5/p2p/order/message/send", ¶ms).await
}
pub async fn update_ad(&self, params: UpdateAdParams) -> Result<UpdateAdResponse> {
self.post("/v5/p2p/item/update", ¶ms).await
}
pub async fn upload_chat_file(
&self,
params: UploadChatFileParams,
) -> Result<UploadChatFileResponse> {
self.post("/v5/p2p/oss/upload_file", ¶ms).await
}
}