mcapi 0.2.0

Unified async Rust client for the Minecraft ecosystem (Mojang, Modrinth, CurseForge, Yggdrasil, Blessing Skin, Loaders, Java Runtimes, and SLP)
Documentation
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use url::Url;

/// Role of a Modrinth user.
#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum UserRole {
    Admin,
    Moderator,
    Pyro,
    Developer,
    #[serde(other)]
    Unknown,
}

/// Payout summary attached to an authenticated [`User`].
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PayoutData {
    #[serde(default)]
    pub balance: Option<f64>,
    #[serde(default)]
    pub payout_wallet: Option<String>,
    #[serde(default)]
    pub payout_wallet_type: Option<String>,
    #[serde(default)]
    pub payout_address: Option<String>,
}

/// Modrinth user account returned by `/v2/user` and `/v2/user/{id|username}`.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct User {
    pub id: String,
    pub username: String,
    #[serde(default)]
    pub name: Option<String>,
    #[serde(default)]
    pub email: Option<String>,
    #[serde(default)]
    pub bio: Option<String>,
    #[serde(default)]
    pub payout_data: Option<PayoutData>,
    #[serde(default)]
    pub avatar_url: Option<Url>,
    pub created: DateTime<Utc>,
    pub role: UserRole,
    #[serde(default)]
    pub badges: u32,
    #[serde(default)]
    pub auth_providers: Option<Vec<String>>,
    #[serde(default)]
    pub email_verified: Option<bool>,
    #[serde(default)]
    pub has_password: Option<bool>,
    #[serde(default)]
    pub has_totp: Option<bool>,
}

/// Patch payload for `PATCH /v2/user/{id|username}`.
#[derive(Clone, Debug, Default, Serialize)]
pub struct ModifyUserRequest {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub username: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub email: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bio: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub payout_data: Option<serde_json::Value>,
}

/// Payout history returned by `GET /v2/user/{id|username}/payouts`.
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct PayoutHistory {
    pub all_time: String,
    pub last_month: String,
    #[serde(default)]
    pub payouts: Vec<serde_json::Value>,
}