Skip to main content

dhan_rs/api/
super_order.rs

1//! Super Order endpoints.
2
3use crate::client::DhanClient;
4use crate::error::Result;
5use crate::types::orders::OrderResponse;
6use crate::types::super_order::*;
7
8impl DhanClient {
9    /// Place a new super order.
10    ///
11    /// **Endpoint:** `POST /v2/super/orders`
12    pub async fn place_super_order(&self, req: &PlaceSuperOrderRequest) -> Result<OrderResponse> {
13        self.post("/v2/super/orders", req).await
14    }
15
16    /// Modify a pending super order.
17    ///
18    /// **Endpoint:** `PUT /v2/super/orders/{order-id}`
19    pub async fn modify_super_order(
20        &self,
21        order_id: &str,
22        req: &ModifySuperOrderRequest,
23    ) -> Result<OrderResponse> {
24        self.put(&format!("/v2/super/orders/{order_id}"), req).await
25    }
26
27    /// Cancel a super order leg.
28    ///
29    /// Cancelling the `ENTRY_LEG` cancels all legs.
30    ///
31    /// **Endpoint:** `DELETE /v2/super/orders/{order-id}/{order-leg}`
32    pub async fn cancel_super_order(&self, order_id: &str, leg: &str) -> Result<OrderResponse> {
33        self.delete(&format!("/v2/super/orders/{order_id}/{leg}"))
34            .await
35    }
36
37    /// Retrieve all super orders for the day.
38    ///
39    /// **Endpoint:** `GET /v2/super/orders`
40    pub async fn get_super_orders(&self) -> Result<Vec<SuperOrderDetail>> {
41        self.get("/v2/super/orders").await
42    }
43}