wp 0.1.0-alpha.3

Complete async API Wrapper for WP
Documentation
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, // You can request other fields at the same time
        StoryField::FirstPartId,
        StoryField::LastPublishedPart(vec![PartReferenceField::Id]),
        StoryField::User(vec![
            UserStubField::Username,
            UserStubField::Avatar,
            UserStubField::FullName, // Corresponds to `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 {
                // --- DO ALL YOUR PRINTING FIRST ---
                println!("Parts: {:#?}", story.parts);

                // --- THEN, CALL THE CONSUMING METHOD LAST ---
                match author.fetch_full_profile(&client).await {
                    // 'author' is moved here and gone
                    Ok(full_profile) => {
                        println!("Successfully fetched the full profile!");
                        // println!("Avatar: {:?}", full_profile);
                    }
                    Err(e) => {
                        eprintln!("Error fetching the full profile: {}", e);
                    }
                }
                // You cannot use `author` here anymore.
            }
        }
        Err(e) => {
            eprintln!("{:#?}", e);
        }
    }
}