use crate::model::User;
use crate::{WattpadClient, WattpadError};
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone)]
pub struct UserStub {
#[serde(rename = "name")]
pub username: Option<String>,
pub avatar: Option<String>,
pub fullname: Option<String>,
pub verified: Option<bool>,
}
impl UserStub {
pub async fn fetch_full_profile(&self, client: &WattpadClient) -> Result<User, WattpadError> {
if let Some(username) = &self.username {
client.user.get_user_info(username, None).await
} else {
Err(WattpadError::MissingRequiredField {
field: "username".to_string(),
context: "Cannot fetch full profile without a username.".to_string(),
})
}
}
}