mcapi 0.3.1

Unified async Rust client for the Minecraft ecosystem (Mojang, Modrinth, CurseForge, Yggdrasil, Blessing Skin, Loaders, BMCLAPI, and Java Runtimes)
Documentation
use serde::Serialize;

use super::Authed;
use super::models::{SignInResult, User};
use crate::error::Result;

#[derive(Serialize)]
struct EmptyBody {}

impl<'a> Authed<'a> {
    /// Logs out and revokes the active token via `POST /api/auth/logout`.
    pub async fn logout(&self) -> Result<()> {
        self.post_unit("/auth/logout", &EmptyBody {}).await
    }

    /// Fetches the authenticated user's profile via `GET /api/user`.
    pub async fn current_user(&self) -> Result<User> {
        self.get_envelope("/user").await
    }

    /// Performs the daily check-in reward via `POST /api/user/sign`.
    pub async fn daily_sign_in(&self) -> Result<SignInResult> {
        self.post_envelope("/user/sign", &EmptyBody {}).await
    }
}