use wp::field::{PartField, PartReferenceField, PartStubField, StoryField, TextUrlField, UserStubField};
#[tokio::main]
async fn main() {
let client = wp::WattpadClient::new();
let story_id = 339586910;
let fields_to_fetch = &[
StoryField::Title, StoryField::FirstPartId,
StoryField::LastPublishedPart(vec![PartReferenceField::Id]),
StoryField::User(vec![
UserStubField::Username,
UserStubField::Avatar,
UserStubField::FullName, ]),
StoryField::Parts(vec![
PartStubField::Id,
PartStubField::TextUrl(vec![TextUrlField::Text])
])
];
match client
.story
.get_story_info(story_id, Some(fields_to_fetch))
.await
{
Ok(story) => {
println!(
"Successfully fetched story: {}",
story.title.unwrap_or_default()
);
if let Some(author) = story.user {
println!("Parts: {:#?}", story.parts);
match author.fetch_full_profile(&client).await {
Ok(full_profile) => {
println!("Successfully fetched the full profile!");
}
Err(e) => {
eprintln!("Error fetching the full profile: {}", e);
}
}
}
}
Err(e) => {
eprintln!("{:#?}", e);
}
}
}