Skip to main content

dhan_rs/api/
edis.rs

1//! EDIS endpoints — T-PIN, Form, Inquiry.
2
3use crate::client::{DhanClient, required_path_segment};
4use crate::error::{DhanError, Result};
5use crate::types::edis::*;
6
7impl DhanClient {
8    /// Generate a T-PIN on the user's registered mobile number.
9    ///
10    /// Returns `202 Accepted` on success.
11    ///
12    /// **Endpoint:** `GET /v2/edis/tpin`
13    pub async fn generate_tpin(&self) -> Result<()> {
14        self.get_no_content("/v2/edis/tpin").await
15    }
16
17    /// Generate an eDIS form for CDSL T-PIN entry.
18    ///
19    /// **Endpoint:** `POST /v2/edis/form`
20    pub async fn generate_edis_form(&self, req: &EdisFormRequest) -> Result<EdisFormResponse> {
21        self.post("/v2/edis/form", req).await
22    }
23
24    /// Generate one eDIS form for multiple ISINs.
25    ///
26    /// **Endpoint:** `POST /v2/edis/bulkform`
27    pub async fn generate_bulk_edis_form(
28        &self,
29        req: &EdisBulkFormRequest,
30    ) -> Result<EdisFormResponse> {
31        req.validate()
32            .map_err(|message| DhanError::InvalidArgument(message.into()))?;
33        self.post("/v2/edis/bulkform", req).await
34    }
35
36    /// Inquire the eDIS status for a stock by ISIN.
37    ///
38    /// Pass `"ALL"` as the ISIN to get status of all holdings.
39    ///
40    /// **Endpoint:** `GET /v2/edis/inquire/{isin}`
41    pub async fn inquire_edis(&self, isin: &str) -> Result<EdisInquiry> {
42        let isin = required_path_segment("isin", isin)?;
43        self.get(&format!("/v2/edis/inquire/{isin}")).await
44    }
45}