steam-user 0.1.0

Steam User web client for Rust - HTTP-based Steam Community interactions
Documentation
//! Email management types.

use serde::{Deserialize, Serialize};

/// Parsed wizard page parameters from Steam Help pages.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct WizardPageParams {
    /// Session ID for the wizard flow.
    pub session_id: String,
    /// Issue-specific parameters.
    pub issue: WizardIssue,
    /// Default wizard page parameters extracted from JavaScript.
    pub default_params: WizardDefaultParams,
}

/// Issue-specific form fields for the wizard.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct WizardIssue {
    /// The 's' parameter (session identifier).
    pub s: String,
    /// Reset parameter.
    pub reset: String,
    /// Lost parameter.
    pub lost: String,
    /// Method parameter (e.g., "8" for mobile confirmation).
    pub method: String,
    /// Issue ID.
    pub issueid: String,
}

/// Default wizard parameters extracted from JavaScript.
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct WizardDefaultParams {
    /// Account ID (miniprofile).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub account: Option<u32>,
    /// Wizard session token.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub wizard: Option<String>,
    /// Other parameters that may vary.
    #[serde(flatten)]
    pub extra: std::collections::HashMap<String, String>,
}

/// Result of an email change operation.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "status", content = "message")]
pub enum ChangeEmailResult {
    /// Email change was successful.
    Success,
    /// Email change failed with an error message.
    Error(String),
}

impl ChangeEmailResult {
    /// Returns true if the email change was successful.
    pub fn is_success(&self) -> bool {
        matches!(self, ChangeEmailResult::Success)
    }

    /// Returns the error message if the operation failed.
    pub fn error_message(&self) -> Option<&str> {
        match self {
            ChangeEmailResult::Error(msg) => Some(msg),
            _ => None,
        }
    }
}

/// Status from polling account recovery confirmation.
#[derive(Debug, Clone, Deserialize)]
pub struct AccountRecoveryStatus {
    /// Whether to continue polling.
    #[serde(default)]
    pub r#continue: bool,
    /// Whether the confirmation was successful.
    #[serde(default)]
    pub success: bool,
    /// Error message if any.
    #[serde(default)]
    pub error: Option<String>,
}

/// Response from submitting a new email.
#[derive(Debug, Clone, Deserialize)]
pub struct SubmitEmailResponse {
    /// Hash/URL for next step if successful.
    #[serde(default)]
    pub hash: String,
    /// Error message if failed.
    #[serde(rename = "errorMsg", default)]
    pub error_msg: String,
    /// Whether to show confirmation dialog.
    #[serde(default)]
    pub show_confirmation: bool,
}

/// Response from confirming new email with OTP.
#[derive(Debug, Clone, Deserialize)]
pub struct ConfirmEmailResponse {
    /// Hash/URL containing result - success if contains
    /// "HelpWithLoginInfoComplete".
    #[serde(default)]
    pub hash: String,
    /// Error message if failed.
    #[serde(rename = "errorMsg", default)]
    pub error_msg: String,
    /// Whether to show confirmation dialog.
    #[serde(default)]
    pub show_confirmation: bool,
}

/// Response from sending account recovery code.
#[derive(Debug, Clone, Deserialize)]
pub struct SendRecoveryCodeResponse {
    /// Whether the operation was successful.
    #[serde(default)]
    pub success: bool,
}