bpx_api_client/routes/
user.rs

1use bpx_api_types::user::{RequestTwoFactorPayload, RequestTwoFactorResponse};
2
3use crate::{BpxClient, error::Result};
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(
14        &self,
15        payload: RequestTwoFactorPayload,
16    ) -> Result<RequestTwoFactorResponse> {
17        let endpoint = self.base_url.join(API_USER_2FA)?;
18        let res = self.post(endpoint, payload).await?;
19
20        let data: RequestTwoFactorResponse = res.json().await?;
21        Ok(data)
22    }
23}