dhan_rs/api/profile.rs
1//! User profile endpoint.
2
3use crate::client::DhanClient;
4use crate::error::Result;
5use crate::types::profile::UserProfile;
6
7impl DhanClient {
8 /// Retrieve the user profile.
9 ///
10 /// Can also be used to validate that an access token is still active.
11 ///
12 /// **Endpoint:** `GET /v2/profile`
13 ///
14 /// # Example
15 ///
16 /// ```no_run
17 /// # use dhan_rs::client::DhanClient;
18 /// # #[tokio::main]
19 /// # async fn main() -> dhan_rs::error::Result<()> {
20 /// let client = DhanClient::new("1000000001", "your-access-token");
21 /// let profile = client.get_profile().await?;
22 /// println!("Token valid until: {}", profile.token_validity);
23 /// # Ok(())
24 /// # }
25 /// ```
26 pub async fn get_profile(&self) -> Result<UserProfile> {
27 self.get("/v2/profile").await
28 }
29}