// Get user information by id or username
use osynic_osuapi::error::Result;
use osynic_osuapi::v2::client::request::client::OsynicOsuApiV2Client;
use osynic_osuapi::v2::interface::users::IUsers;
use osynic_osuapi::v2::model::oauth::structs::o_token::OToken;

#[tokio::main]
async fn main() -> Result<()> {
    dotenvy::dotenv().ok();
    let access_token = std::env::var("ACCESS_TOKEN").expect(
        "Please set the ACCESS_TOKEN environment variable to a valid osu! API v2 access token",
    );
    let client = OsynicOsuApiV2Client::new(OToken {
        access_token,
        refresh_token: None,
        expires_in: 86400,
        token_type: "Bearer".to_string(),
    });

    let favourites = client
        .users
        .get_user_beatmaps(31175842, "favourite".to_string(), None, None)
        .await?;
    println!("{:?}", favourites);

    let most_playeds = client
        .users
        .get_user_beatmaps_most_played(31175842, None, None)
        .await?;

    println!("{:?}", most_playeds);

    Ok(())
}

/*
ReqwestUsers get_user_beatmaps
    []
ReqwestUsers get_user_beatmaps_most_played
    [BeatmapPlaycount {
        beatmap_id: 351188,
        count: 105,
        beatmap: Beatmap {
            beatmapset_id: 140662,
            difficulty_rating: 3.06,
            id: 351188,
            mode: "osu",
            status: "ranked",
            total_length: 240,
            user_id: 270377,
            version: "Hard"
        },
        beatmapset: Beatmapset {
            artist: "cYsmix feat. Emmy",
            artist_unicode: "cYsmix feat. えみぃ",
            covers: Covers {
                cover: "https://assets.ppy.sh/beatmaps/140662/covers/cover.jpg?1622070421",
                cover_2x: "https://assets.ppy.sh/beatmaps/140662/covers/cover@2x.jpg?1622070421",
                card: "https://assets.ppy.sh/beatmaps/140662/covers/card.jpg?1622070421",
                card_2x: "https://assets.ppy.sh/beatmaps/140662/covers/card@2x.jpg?1622070421",
                list: "https://assets.ppy.sh/beatmaps/140662/covers/list.jpg?1622070421",
                list_2x: "https://assets.ppy.sh/beatmaps/140662/covers/list@2x.jpg?1622070421",
                slimcover: "https://assets.ppy.sh/beatmaps/140662/covers/slimcover.jpg?1622070421",
                slimcover_2x: "https://assets.ppy.sh/beatmaps/140662/covers/slimcover@2x.jpg?1622070421"
            },
            creator: "jonathanlfj",
            favourite_count: 20647,
            hype: None,
            id: 140662,
            nsfw: false,
            offset: 0,
            play_count: 56451776,
            preview_url: "//b.ppy.sh/preview/140662.mp3",
            source: "Touhou",
            spotlight: false,
            status: Ranked,
            title: "Tear Rain",
            title_unicode: "Tear Rain",
            track_id: None,
            user_id: 270377,
            video: false,
            bpm: None,
            can_be_hyped: None,
            deleted_at: None,
            discussion_enabled: None,
            discussion_locked: None,
            is_scoreable: None,
            last_updated: None,
            legacy_thread_url: None,
            nominations_summary: None,
            ranked: None,
            ranked_date: None,
            storyboard: None,
            submitted_date: None,
            tags: None,
            availability: None,
            beatmaps: None,
            pack_tags: None,
            converts: None,
            current_nominations: None,
            description: None,
            genre: None,
            language: None,
            ratings: None,
            recent_favourites: None,
            related_users: None,
            related_tags: None,
            user: None
        }
    }, BeatmapPlaycount {
        beatmap_id: 3853596,
        count: 102,
        beatmap: Beatmap {
            beatmapset_id: 1872783,
            difficulty_rating: 4.76,
            id: 3853596,
            mode: "osu",
            status: "ranked",
            total_length: 230,
            user_id: 22686604,
            version: "Insane"
        },
        beatmapset: Beatmapset {
            artist: "Hana",
            artist_unicode: "はな",
            covers: Covers {
                cover: "https://assets.ppy.sh/beatmaps/1872783/covers/cover.jpg?1672205774",
                cover_2x: "https://assets.ppy.sh/beatmaps/1872783/covers/cover@2x.jpg?1672205774",
                card: "https://assets.ppy.sh/beatmaps/1872783/covers/card.jpg?1672205774",
                card_2x: "https://assets.ppy.sh/beatmaps/1872783/covers/card@2x.jpg?1672205774",
                list: "https://assets.ppy.sh/beatmaps/1872783/covers/list.jpg?1672205774",
                list_2x: "https://assets.ppy.sh/beatmaps/1872783/covers/list@2x.jpg?1672205774",
                slimcover: "https://assets.ppy.sh/beatmaps/1872783/covers/slimcover.jpg?1672205774",
                slimcover_2x: "https://assets.ppy.sh/beatmaps/1872783/covers/slimcover@2x.jpg?1672205774"
            },
            creator: "InsertUsernamev",
            favourite_count: 67,
            hype: None,
            id: 1872783,
            nsfw: false,
            offset: 0,
            play_count: 75018,
            preview_url: "//b.ppy.sh/preview/1872783.mp3",
            source: "サクラノ詩 －櫻の森の上を舞う－",
            spotlight: false,
            status: Ranked,
            title: "Sakura no Uta",
            title_unicode: "櫻ノ詩",
            track_id: None,
            user_id: 22686604,
            video: false,
            bpm: None,
            can_be_hyped: None,
            deleted_at: None,
            discussion_enabled: None,
            discussion_locked: None,
            is_scoreable: None,
            last_updated: None,
            legacy_thread_url: None,
            nominations_summary: None,
            ranked: None,
            ranked_date: None,
            storyboard: None,
            submitted_date: None,
            tags: None,
            availability: None,
            beatmaps: None,
            pack_tags: None,
            converts: None,
            current_nominations: None,
            description: None,
            genre: None,
            language: None,
            ratings: None,
            recent_favourites: None,
            related_users: None,
            related_tags: None,
            user: None
        }
    }, BeatmapPlaycount {
        beatmap_id: 693621,
        count: 87,
        beatmap: Beatmap {
            beatmapset_id: 310371,
            difficulty_rating: 4.09,
            id: 693621,
            mode: "osu",
            status: "ranked",
            total_length: 105,
            user_id: 3143784,
            version: "Insane"
        },
        beatmapset: Beatmapset {
            artist: "Sharlo",
            artist_unicode: "Sharlo",
            covers: Covers {
                cover: "https://assets.ppy.sh/beatmaps/310371/covers/cover.jpg?1650630726",
                cover_2x: "https://assets.ppy.sh/beatmaps/310371/covers/cover@2x.jpg?1650630726",
                card: "https://assets.ppy.sh/beatmaps/310371/covers/card.jpg?1650630726",
                card_2x: "https://assets.ppy.sh/beatmaps/310371/covers/card@2x.jpg?1650630726",
                list: "https://assets.ppy.sh/beatmaps/310371/covers/list.jpg?1650630726",
                list_2x: "https://assets.ppy.sh/beatmaps/310371/covers/list@2x.jpg?1650630726",
                slimcover: "https://assets.ppy.sh/beatmaps/310371/covers/slimcover.jpg?1650630726",
                slimcover_2x: "https://assets.ppy.sh/beatmaps/310371/covers/slimcover@2x.jpg?1650630726"
            },
            creator: "Karen",
            favourite_count: 363,
            hype: None,
            id: 310371,
            nsfw: false,
            offset: 0,
            play_count: 595411,
            preview_url: "//b.ppy.sh/preview/310371.mp3",
            source: "Love Live! School idol project",
            spotlight: false,
            status: Ranked,
            title: "START:DASH!!",
            title_unicode: "START:DASH!!",
            track_id: None,
            user_id: 3143784,
            video: false,
            bpm: None,
            can_be_hyped: None,
            deleted_at: None,
            discussion_enabled: None,
            discussion_locked: None,
            is_scoreable: None,
            last_updated: None,
            legacy_thread_url: None,
            nominations_summary: None,
            ranked: None,
            ranked_date: None,
            storyboard: None,
            submitted_date: None,
            tags: None,
            availability: None,
            beatmaps: None,
            pack_tags: None,
            converts: None,
            current_nominations: None,
            description: None,
            genre: None,
            language: None,
            ratings: None,
            recent_favourites: None,
            related_users: None,
            related_tags: None,
            user: None
        }
    }, BeatmapPlaycount {
        beatmap_id: 1988750,
        count: 75,
        beatmap: Beatmap {
            beatmapset_id: 952409,
            difficulty_rating: 4.61,
            id: 1988750,
            mode: "osu",
            status: "ranked",
            total_length: 67,
            user_id: 4378277,
            version: "Insane"
        },
        beatmapset: Beatmapset {
            artist: "MIMI feat. Hatsune Miku",
            artist_unicode: "MIMI feat. 初音ミク",
            covers: Covers {
                cover: "https://assets.ppy.sh/beatmaps/952409/covers/cover.jpg?1645787548",
                cover_2x: "https://assets.ppy.sh/beatmaps/952409/covers/cover@2x.jpg?1645787548",
                card: "https://assets.ppy.sh/beatmaps/952409/covers/card.jpg?1645787548",
                card_2x: "https://assets.ppy.sh/beatmaps/952409/covers/card@2x.jpg?1645787548",
                list: "https://assets.ppy.sh/beatmaps/952409/covers/list.jpg?1645787548",
                list_2x: "https://assets.ppy.sh/beatmaps/952409/covers/list@2x.jpg?1645787548",
                slimcover: "https://assets.ppy.sh/beatmaps/952409/covers/slimcover.jpg?1645787548",
                slimcover_2x: "https://assets.ppy.sh/beatmaps/952409/covers/slimcover@2x.jpg?1645787548"
            },
            creator: "Log Off Now",
            favourite_count: 16793,
            hype: None,
            id: 952409,
            nsfw: false,
            offset: 0,
            play_count: 59121414,
            preview_url: "//b.ppy.sh/preview/952409.mp3",
            source: "",
            spotlight: false,
            status: Ranked,
            title: "Ai no Sukima",
            title_unicode: "哀の隙間",
            track_id: Some(2076),
            user_id: 4378277,
            video: false,
            bpm: None,
            can_be_hyped: None,
            deleted_at: None,
            discussion_enabled: None,
            discussion_locked: None,
            is_scoreable: None,
            last_updated: None,
            legacy_thread_url: None,
            nominations_summary: None,
            ranked: None,
            ranked_date: None,
            storyboard: None,
            submitted_date: None,
            tags: None,
            availability: None,
            beatmaps: None,
            pack_tags: None,
            converts: None,
            current_nominations: None,
            description: None,
            genre: None,
            language: None,
            ratings: None,
            recent_favourites: None,
            related_users: None,
            related_tags: None,
            user: None
        }
    }, BeatmapPlaycount {
        beatmap_id: 3939073,
        count: 65,
        beatmap: Beatmap {
            beatmapset_id: 1909798,
            difficulty_rating: 4.61,
            id: 3939073,
            mode: "osu",
            status: "ranked",
            total_length: 259,
            user_id: 8939857,
            version: "Insane"
        },
        beatmapset: Beatmapset {
            artist: "kessoku band",
            artist_unicode: "結束バンド",
            covers: Covers {
                cover: "https://assets.ppy.sh/beatmaps/1909798/covers/cover.jpg?1672293224",
                cover_2x: "https://assets.ppy.sh/beatmaps/1909798/covers/cover@2x.jpg?1672293224",
                card: "https://assets.ppy.sh/beatmaps/1909798/covers/card.jpg?1672293224",
                card_2x: "https://assets.ppy.sh/beatmaps/1909798/covers/card@2x.jpg?1672293224",
                list: "https://assets.ppy.sh/beatmaps/1909798/covers/list.jpg?1672293224",
                list_2x: "https://assets.ppy.sh/beatmaps/1909798/covers/list@2x.jpg?1672293224",
                slimcover: "https://assets.ppy.sh/beatmaps/1909798/covers/slimcover.jpg?1672293224",
                slimcover_2x: "https://assets.ppy.sh/beatmaps/1909798/covers/slimcover@2x.jpg?1672293224"
            },
            creator: "ponbot",
            favourite_count: 898,
            hype: None,
            id: 1909798,
            nsfw: false,
            offset: 0,
            play_count: 302077,
            preview_url: "//b.ppy.sh/preview/1909798.mp3",
            source: "ぼっち・ざ・ろっく！",
            spotlight: false,
            status: Ranked,
            title: "Korogaru Iwa, Kimi ni Asa ga Furu",
            title_unicode: "転がる岩、君に朝が降る",
            track_id: None,
            user_id: 8939857,
            video: false,
            bpm: None,
            can_be_hyped: None,
            deleted_at: None,
            discussion_enabled: None,
            discussion_locked: None,
            is_scoreable: None,
            last_updated: None,
            legacy_thread_url: None,
            nominations_summary: None,
            ranked: None,
            ranked_date: None,
            storyboard: None,
            submitted_date: None,
            tags: None,
            availability: None,
            beatmaps: None,
            pack_tags: None,
            converts: None,
            current_nominations: None,
            description: None,
            genre: None,
            language: None,
            ratings: None,
            recent_favourites: None,
            related_users: None,
            related_tags: None,
            user: None
        }
    }]
*/
