Skip to main content

gateio_rs/api/spot/
get_price_order.rs

1use crate::http::{Credentials, Method, request::Request};
2
3/// # Get a price-triggered order
4///
5/// Retrieve details of a specific price-triggered order (auto order/conditional order) by order ID.
6///
7/// ## Order Status Values:
8/// - "open": Waiting to trigger
9/// - "cancelled": Manually cancelled  
10/// - "finish": Successfully executed
11/// - "failed": Failed to execute
12/// - "expired": Expired
13///
14/// ## Response includes:
15/// - Order ID and creation time
16/// - Trigger condition (price and rule)
17/// - Order details (currency pair, side, amount, price)
18/// - Current status and execution details
19/// - Account information
20///
21/// [Gate API Documentation](https://www.gate.com/docs/developers/apiv4/#get-a-price-triggered-order)
22pub struct GetPriceOrder {
23    /// Order ID of the price-triggered order to retrieve
24    pub order_id: String,
25    /// API credentials for authentication
26    pub credentials: Option<Credentials>,
27}
28
29impl GetPriceOrder {
30    /// Creates a new GetPriceOrder request with the specified order ID
31    pub fn new(order_id: &str) -> Self {
32        Self {
33            order_id: order_id.to_owned(),
34            credentials: None,
35        }
36    }
37
38    /// Sets the API credentials for authentication
39    pub fn credentials(mut self, creds: Credentials) -> Self {
40        self.credentials = Some(creds);
41        self
42    }
43}
44
45impl From<GetPriceOrder> for Request {
46    fn from(request: GetPriceOrder) -> Request {
47        let params = Vec::new();
48
49        Request {
50            method: Method::Get,
51            path: format!("/api/v4/spot/price_orders/{}", request.order_id).into(),
52            params,
53            payload: "".to_string(),
54            x_gate_exp_time: None,
55            credentials: request.credentials,
56            sign: true,
57        }
58    }
59}