use crate::client::endpoints::Endpoint;
use crate::client::BrawlClient;
use crate::errors::BrawlError;
use serde::Deserialize;
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Club {
pub tag: String,
pub name: String,
pub description: Option<String>,
#[serde(rename = "type")]
pub kind: String,
pub badge_id: u64,
pub required_trophies: u64,
pub trophies: u64,
pub members: Vec<ClubMember>,
#[serde(rename = "isFamilyFriendly")]
pub family_friendly: bool,
}
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ClubMember {
pub tag: String,
pub name: String,
pub name_color: String,
pub role: String,
pub trophies: u64,
}
impl Club {
pub async fn get(client: &BrawlClient, tag: &str) -> Result<Self, BrawlError> {
let endpoint = Endpoint::Club(tag.to_string());
client.fetch::<Self>(endpoint).await
}
}