pub struct UserClient { /* private fields */ }Expand description
Provides access to user-related API endpoints.
This client allows you to fetch public information about Wattpad users.
Implementations§
Source§impl UserClient
impl UserClient
Sourcepub async fn get_user_info(
&self,
username: &str,
fields: Option<&[UserField]>,
) -> Result<UserResponse, WattpadError>
pub async fn get_user_info( &self, username: &str, fields: Option<&[UserField]>, ) -> Result<UserResponse, WattpadError>
Fetches detailed public information about a specific user.
This function retrieves a user’s profile data, such as their follower count, stories they’ve written, and more.
§Arguments
username- The username of the user to fetch.fields- An optional slice ofUserFieldspecifying which fields to retrieve. IfNone, a default set of fields will be requested.
§Returns
A Result containing a UserResponse struct with the user’s data on success.
§Errors
Returns a WattpadError if the network request fails, the API returns an error
(e.g., user not found), or a requested field requires authentication when the
client is unauthenticated.
§Examples
let client = WattpadClient::new();
let username = "test";
let fields = &[UserField::Username, UserField::FollowerCount];
let user_info = client.user.get_user_info(username, Some(fields)).await?;
println!("User: {}", user_info.username);
println!("Followers: {}", user_info.follower_count);Sourcepub fn get_user_stories<'a>(
&'a self,
username: &'a str,
fields: Option<&'a [StoryField]>,
) -> Result<Paginator<'a, StoryResponse, UserStoriesResponse>, WattpadError>
pub fn get_user_stories<'a>( &'a self, username: &'a str, fields: Option<&'a [StoryField]>, ) -> Result<Paginator<'a, StoryResponse, UserStoriesResponse>, WattpadError>
Creates a request builder to fetch user stories.
You can configure the limit/offset or call .execute_all().await
to get everything.
§Arguments
username- The username of the user to fetch.fields- An optional slice ofStoryFieldspecifying which fields to retrieve. IfNone, a default set of fields will be requested.
§Returns
A Result containing a UserStoriesResponse struct with the user’s data on success.
§Errors
Returns a WattpadError if the network request fails, the API returns an error
(e.g., user not found), or a requested field requires authentication when the
client is unauthenticated.
§Examples
let client = WattpadClient::new();
let username = "test";
let fields = &[StoryField::Id, StoryField::Title];
let result_of_all_stories = client.user.get_user_stories(username, Some(fields)).execute_all().await?;
// Use result_of_all_stories.