hypixel 0.1.0

Rust wrapper for the Hypixel public API.
Documentation
//! Allows for easy access to Hypixel resource information.
//! 
//! Unlike other handlers these endpoints don't require an API key
//! and thus removes to need for a `Client` struct.
//! 
//! # Example
//! 
//! ```no_run
//! use hypixel::handler::resources;
//! 
//! // Simple right?
//! let challenges = resources::challenges().await?;
//! ```
use crate::api::http;
use crate::objects::{
    Games,
    GameInfoResponse,
    Challenges, 
    ChallengesResponse, 
    Quests, 
    QuestsResponse,
    GuildAchievements,
    GuildAchievementsResponse,
    VanityPet,
    VanityPetsResponse,
    Companion,
    CompanionsResponse
};
use crate::Error;

/// Returns all games and their associated data.
/// 
/// # Example
/// 
/// ```no_run
/// let games = resources::games().await?;
/// // Something...
/// ```
pub async fn games() -> Result<Games, Error>{
    let res = http::fetch::<GameInfoResponse>("resources/games").await?;

    Ok(res.games)
}

/// Returns all game modes and their list of challenges.
pub async fn challenges() -> Result<Challenges, Error> {
    let res = http::fetch::<ChallengesResponse>("resources/challenges").await?; 

    Ok(res.challenges)
}

/// Returns all game modes and their list of quests.
/// 
/// # Example
/// 
/// ```no_run
/// let quests = resources::quests().await?;
/// // Something...
/// ```
pub async fn quests() -> Result<Quests, Error> {
    let res = http::fetch::<QuestsResponse>("resources/quests").await?;

    Ok(res.quests)
}

/// Returns a list tiered guild achievements.
/// 
/// # Example
/// 
/// ```no_run
/// let achievements = resources::guild_achievements().await?;
/// // Something...
/// ```
pub async fn guild_achievements() -> Result<GuildAchievements, Error> {
    let res = http::fetch::<GuildAchievementsResponse>(
        "resources/guilds/achievements"
    ).await?;

    Ok(res.tiered)
}

/// Returns a list of vanity pet objects. 
/// 
/// # Example
/// 
/// ```no_run
/// let pets = resources::vanity_pets().await?;
/// // Something...
/// ```
pub async fn vanity_pets() -> Result<Vec<VanityPet>, Error> {
    let res = http::fetch::<VanityPetsResponse>(
        "resources/vanity/pets"
    ).await?;

    Ok(res.types)
}

/// Returns a list of all companions on Hypixel.
/// 
/// # Example
/// 
/// ```no_run
/// let companions = resources::companions().await?;
/// // Something...
/// ```
pub async fn companions() -> Result<Vec<Companion>, Error> {
    let res = http::fetch::<CompanionsResponse>(
        "resources/vanity/companions"
    ).await?;

    Ok(res.types)
}