gateio_rs/api/spot/
create_cross_liquidate_orders.rs1use crate::http::{Credentials, Method, request::Request};
2use serde::Serialize;
3
4#[derive(Debug, Clone, Serialize)]
10pub struct CrossLiquidateOrder {
11 pub currency_pair: String,
13 pub amount: String,
15 pub price: String,
17 #[serde(skip_serializing_if = "Option::is_none")]
19 pub text: Option<String>,
20 #[serde(skip_serializing_if = "Option::is_none")]
22 pub action_mode: Option<String>,
23}
24
25impl CrossLiquidateOrder {
26 pub fn new(currency_pair: &str, amount: &str, price: &str) -> Self {
28 Self {
29 currency_pair: currency_pair.to_owned(),
30 amount: amount.to_owned(),
31 price: price.to_owned(),
32 text: None,
33 action_mode: None,
34 }
35 }
36
37 pub fn text(mut self, text: &str) -> Self {
39 self.text = Some(text.to_owned());
40 self
41 }
42
43 pub fn action_mode(mut self, action_mode: &str) -> Self {
45 self.action_mode = Some(action_mode.to_owned());
46 self
47 }
48}
49
50pub struct CreateCrossLiquidateOrders {
63 pub orders: Vec<CrossLiquidateOrder>,
65 pub x_gate_exp_time: Option<u128>,
67 pub credentials: Option<Credentials>,
69}
70
71impl CreateCrossLiquidateOrders {
72 pub fn new(orders: Vec<CrossLiquidateOrder>) -> Self {
74 Self {
75 orders,
76 x_gate_exp_time: None,
77 credentials: None,
78 }
79 }
80
81 pub fn x_gate_exp_time(mut self, x_gate_exp_time: u128) -> Self {
83 self.x_gate_exp_time = Some(x_gate_exp_time);
84 self
85 }
86
87 pub fn credentials(mut self, creds: Credentials) -> Self {
89 self.credentials = Some(creds);
90 self
91 }
92}
93
94impl From<CreateCrossLiquidateOrders> for Request {
95 fn from(request: CreateCrossLiquidateOrders) -> Request {
96 let params = Vec::new();
97 let payload = serde_json::to_string(&request.orders).unwrap();
98
99 Request {
100 method: Method::Post,
101 path: "/api/v4/spot/cross_liquidate_orders".into(),
102 params,
103 payload,
104 x_gate_exp_time: request.x_gate_exp_time,
105 credentials: request.credentials,
106 sign: true,
107 }
108 }
109}