Skip to content

Commit

Permalink
Added docs to verify_otp
Browse files Browse the repository at this point in the history
  • Loading branch information
Proziam committed Oct 21, 2024
1 parent c99d1df commit c791910
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,20 @@ impl AuthClient {
Ok(user)
}

// TODO: Add test
/// Verify the OTP sent to the user
/// # Example
/// ```
/// let params = VerifyEmailOtpParams {
/// token: "abc123",
/// otp_type: OtpType::EmailChange,
/// options: None,
/// };
///
/// let session = auth_client
/// .verify_otp(params)
/// .await
/// .unwrap();
///```
pub async fn verify_otp(&self, params: VerifyOtpParams) -> Result<Session, Error> {
let mut headers = HeaderMap::new();
headers.insert("apikey", HeaderValue::from_str(&self.api_key)?);
Expand Down
5 changes: 3 additions & 2 deletions src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,15 @@ pub struct OTPResponse {
pub message_id: Option<String>,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(untagged)]
pub enum VerifyOtpParams {
Mobile(VerifyMobileOtpParams),
Email(VerifyEmailOtpParams),
TokenHash(VerifyTokenHashParams),
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct VerifyMobileOtpParams {
/// The user's phone number.
pub phone: String,
Expand Down

0 comments on commit c791910

Please sign in to comment.