gateio_rs/api/spot/
amend_batch_orders.rs1use crate::http::{Credentials, Method, request::Request};
2use serde::Serialize;
3
4#[derive(Debug, Clone, Serialize)]
6pub struct OrderAmendment {
7 pub order_id: String,
9 pub currency_pair: String,
11 #[serde(skip_serializing_if = "Option::is_none")]
13 pub account: Option<String>,
14 #[serde(skip_serializing_if = "Option::is_none")]
16 pub amount: Option<String>,
17 #[serde(skip_serializing_if = "Option::is_none")]
19 pub price: Option<String>,
20 #[serde(skip_serializing_if = "Option::is_none")]
22 pub amend_text: Option<String>,
23}
24
25impl OrderAmendment {
26 pub fn new(order_id: &str, currency_pair: &str) -> Self {
28 Self {
29 order_id: order_id.to_owned(),
30 currency_pair: currency_pair.to_owned(),
31 account: None,
32 amount: None,
33 price: None,
34 amend_text: None,
35 }
36 }
37
38 pub fn account(mut self, account: &str) -> Self {
40 self.account = Some(account.to_owned());
41 self
42 }
43
44 pub fn amount(mut self, amount: &str) -> Self {
46 self.amount = Some(amount.to_owned());
47 self
48 }
49
50 pub fn price(mut self, price: &str) -> Self {
52 self.price = Some(price.to_owned());
53 self
54 }
55
56 pub fn amend_text(mut self, amend_text: &str) -> Self {
58 self.amend_text = Some(amend_text.to_owned());
59 self
60 }
61}
62
63pub struct AmendBatchOrders {
65 pub orders: Vec<OrderAmendment>,
67 pub x_gate_exp_time: Option<u128>,
69 pub credentials: Option<Credentials>,
71}
72
73impl AmendBatchOrders {
74 pub fn new(orders: Vec<OrderAmendment>) -> Self {
76 Self {
77 orders,
78 x_gate_exp_time: None,
79 credentials: None,
80 }
81 }
82
83 pub fn x_gate_exp_time(mut self, x_gate_exp_time: u128) -> Self {
85 self.x_gate_exp_time = Some(x_gate_exp_time);
86 self
87 }
88
89 pub fn credentials(mut self, creds: Credentials) -> Self {
91 self.credentials = Some(creds);
92 self
93 }
94}
95
96impl From<AmendBatchOrders> for Request {
97 fn from(request: AmendBatchOrders) -> Request {
98 let params = Vec::new();
99 let payload = serde_json::to_string(&request.orders).unwrap();
100
101 Request {
102 method: Method::Post,
103 path: "/api/v4/spot/amend_batch_orders".into(),
104 params,
105 payload,
106 x_gate_exp_time: request.x_gate_exp_time,
107 credentials: request.credentials,
108 sign: true,
109 }
110 }
111}