bpx_api_client/routes/
user.rs

1use bpx_api_types::user::{RequestTwoFactorPayload, RequestTwoFactorResponse};
2
3use crate::{error::Result, BpxClient};
4
5#[doc(hidden)]
6pub const API_USER_2FA: &str = "/wapi/v1/user/2fa";
7
8impl BpxClient {
9    /// Requests a two-factor authentication token.
10    ///
11    /// Sends a request to initiate the two-factor authentication process
12    /// with the provided payload and returns the response.
13    pub async fn request_two_factor(&self, payload: RequestTwoFactorPayload) -> Result<RequestTwoFactorResponse> {
14        let endpoint = format!("{}{}", self.base_url, API_USER_2FA);
15        let res = self.post(endpoint, payload).await?;
16
17        let data: RequestTwoFactorResponse = res.json().await?;
18        Ok(data)
19    }
20}