gateio_rs/api/spot/
order.rs1use serde::Serialize;
2
3#[derive(Debug, Clone, Serialize)]
5pub struct Order {
6 #[serde(skip_serializing_if = "Option::is_none")]
8 pub text: Option<String>,
9 pub currency_pair: String,
11 #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
13 pub order_type: Option<String>,
14 #[serde(skip_serializing_if = "Option::is_none")]
16 pub account: Option<String>,
17 pub side: String,
19 pub amount: String,
21 #[serde(skip_serializing_if = "Option::is_none")]
23 pub price: Option<String>,
24 #[serde(skip_serializing_if = "Option::is_none")]
26 pub time_in_force: Option<String>,
27 #[serde(skip_serializing_if = "Option::is_none")]
29 pub iceberg: Option<String>,
30 #[serde(skip_serializing_if = "Option::is_none")]
32 pub auto_borrow: Option<bool>,
33 #[serde(skip_serializing_if = "Option::is_none")]
35 pub auto_repay: Option<bool>,
36 #[serde(skip_serializing_if = "Option::is_none")]
38 pub stp_act: Option<String>,
39 #[serde(skip_serializing_if = "Option::is_none")]
41 pub action_mode: Option<String>,
42}
43
44impl Order {
45 pub fn new(currency_pair: &str, side: &str, amount: &str) -> Self {
47 Self {
48 text: None,
49 currency_pair: currency_pair.to_owned(),
50 order_type: None,
51 account: None,
52 side: side.to_owned(),
53 amount: amount.to_owned(),
54 price: None,
55 time_in_force: None,
56 iceberg: None,
57 auto_borrow: None,
58 auto_repay: None,
59 stp_act: None,
60 action_mode: None,
61 }
62 }
63
64 pub fn text(mut self, text: &str) -> Self {
66 self.text = Some(text.into());
67 self
68 }
69
70 pub fn order_type(mut self, order_type: &str) -> Self {
72 self.order_type = Some(order_type.into());
73 self
74 }
75
76 pub fn account(mut self, account: &str) -> Self {
78 self.account = Some(account.into());
79 self
80 }
81
82 pub fn price(mut self, price: &str) -> Self {
84 self.price = Some(price.into());
85 self
86 }
87
88 pub fn time_in_force(mut self, time_in_force: &str) -> Self {
90 self.time_in_force = Some(time_in_force.into());
91 self
92 }
93
94 pub fn iceberg(mut self, iceberg: &str) -> Self {
96 self.iceberg = Some(iceberg.into());
97 self
98 }
99
100 pub fn auto_borrow(mut self, auto_borrow: bool) -> Self {
102 self.auto_borrow = Some(auto_borrow);
103 self
104 }
105
106 pub fn auto_repay(mut self, auto_repay: bool) -> Self {
108 self.auto_repay = Some(auto_repay);
109 self
110 }
111
112 pub fn stp_act(mut self, stp_act: &str) -> Self {
114 self.stp_act = Some(stp_act.into());
115 self
116 }
117
118 pub fn action_mode(mut self, action_mode: &str) -> Self {
120 self.action_mode = Some(action_mode.into());
121 self
122 }
123}