/*
 * asklyphe-common nats/authservice/profile.rs
 * - nats structs for user profile queries
 *
 * Copyright (C) 2025 Real Microsoft, LLC
 *
 * This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

use serde::{Deserialize, Serialize};
use crate::nats::authservice::UserPrivateToken;

/// # UserInfoRequest
/// sent from frontend -> authsrvc to receive info for display on the frontend
/// expecting a AuthServiceResponse::UserInfoResponse back
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserInfoRequest {
    pub token: UserPrivateToken,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserInfo {
    pub username: String,
    pub email: String,
    pub new_email: Option<String>,
    pub theme: String,
    pub administrator: bool,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum UserInfoResponse {
    Success(UserInfo),
    InternalServerError(String),
    TokenExpired,
    TokenInvalid,
    AccountSuspended,
}

/// # ThemeChangeRequest
/// sent from frontend -> authsrvc to set the user's preferred theme
/// do note that the backend will not check if the theme is valid, this must be done on the frontend
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ThemeChangeRequest {
    pub token: UserPrivateToken,
    pub theme: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum ThemeChangeResponse {
    Success,
    /// sent if the token is invalid, and the account should be logged out
    Logout,
    InternalServerError,
}
