swgoh-gg 1.0.0

API Bindings for swgoh.gg
Documentation
//! Types related to Units (Characters & Ships)

use serde::{Deserialize, Serialize};

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Units {
    pub data: Vec<Unit>,

    // TODO just a guess on this type
    pub message: Option<String>,

    // TODO just a guess on this type
    pub total_count: Option<i64>,

    // TODO just a guess on this type
    pub error_key: Option<String>,
}

// TODO create more useful copies of these type in the top level crate, including the TODOs below
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Unit {
    pub name: String,
    pub base_id: String,
    pub url: String,
    pub image: String,
    pub power: u64,
    pub description: String,
    pub combat_type: u64, // TODO enum Character = 1, Ships = 2s
    pub gear_levels: Vec<GearLevel>,
    pub alignment: u64, // TODO enum // FIXME for /units this is a number and for /characters and /ships this is a string
    pub categories: Vec<String>, // TODO enum? xtask to scrape it
    pub ability_classes: Vec<String>, // TODO enum? xtask
    pub role: String,   // TODO enum?
    pub ship_base_id: Option<String>,
    pub ship_slot: Option<u64>, // TODO enum? none, 0, 1, 2
    pub activate_shard_count: u64,
    pub is_capital_ship: bool,
    pub is_galactic_legend: bool,
    pub made_available_on: String, // TODO date
    pub crew_base_ids: Vec<String>,
    pub omicron_ability_ids: Vec<String>,
    pub zeta_ability_ids: Vec<String>,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct GearLevel {
    pub tier: u64,
    pub gear: Vec<String>,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Character {
    pub name: String,
    pub base_id: String,
    pub url: String,
    pub image: String,
    pub power: u64,
    pub description: String,
    pub combat_type: u64,
    pub gear_levels: Vec<GearLevel>,
    pub alignment: String,
    pub categories: Vec<String>,
    pub ability_classes: Vec<String>,
    pub role: String,
    pub ship: String,
    pub ship_slot: Option<u64>,
    pub activate_shard_count: u64,
}

#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Ship {
    pub name: String,
    pub base_id: String,
    pub url: String,
    pub image: String,
    pub power: u64,
    pub description: String,
    pub combat_type: u64,
    pub alignment: String,
    pub categories: Vec<String>,
    pub ability_classes: Vec<String>,
    pub role: String,
    pub capital_ship: bool,
    pub activate_shard_count: u64,
}