binance_client/http_api_v3/data/open_orders/delete/
request.rs

1//!
2//! The open orders DELETE request.
3//!
4
5use chrono::prelude::*;
6
7///
8/// The `https://www.binance.com/api/v3/openOrders` GET request query.
9///
10pub struct Query {
11    /// The symbol name.
12    pub symbol: String,
13    /// The allowed time window between the request and response in milliseconds.
14    pub recv_window: Option<i64>,
15    /// The request time in milliseconds.
16    pub timestamp: i64,
17}
18
19impl Query {
20    /// The query params default capacity.
21    const QUERY_INITIAL_CAPACITY: usize = 256;
22
23    ///
24    /// A shortcut constructor.
25    ///
26    pub fn new(symbol: String) -> Self {
27        Self {
28            symbol,
29            recv_window: None,
30            timestamp: Utc::now().timestamp_millis(),
31        }
32    }
33}
34
35impl ToString for Query {
36    fn to_string(&self) -> String {
37        let mut params = String::with_capacity(Self::QUERY_INITIAL_CAPACITY);
38        params += &format!("symbol={}", self.symbol);
39        if let Some(recv_window) = self.recv_window {
40            params += &format!("&recvWindow={}", recv_window);
41        }
42        params += &format!("&timestamp={}", self.timestamp);
43        params
44    }
45}