#![allow(non_snake_case)]
use serde_json::value::Map;
use serde_json::Value;
#[derive(Serialize, Deserialize, Debug)]
pub struct BStart {
pub secret: String,
pub http: Map<String, Value>,
pub https: Map<String, Value>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Game {
pub id: i32,
pub url: String,
pub title: String,
pub short_text: String,
pub cover_url: String,
#[serde(default)]
pub still_cover_url: String,
#[serde(flatten)]
pub dates: Dates,
#[serde(default)]
pub min_price: i32,
pub can_be_bought: bool,
#[serde(default)]
pub has_demo: bool,
#[serde(default)]
pub in_press_system: bool,
pub user: Option<User>,
pub sale: Option<Sale>,
pub user_id: Option<i32>,
pub views_count: Option<i32>,
pub downloads_count: Option<i32>,
pub purchases_count: Option<i32>,
pub published: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct ProfileGame {
pub game: Game,
pub views_count: i32,
pub downloads_count: i32,
pub purchases_count: i32,
pub published: bool,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Profile {
pub id: i32,
pub last_connected: String,
pub user: User,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Upload {
pub id: i32,
pub storage: String,
#[serde(default)]
pub host: String,
pub filename: String,
pub display_name: String,
pub size: i32,
#[serde(default)]
pub channel_name: String,
#[serde(default)]
pub build_id: i32,
pub preorder: bool,
pub demo: bool,
#[serde(flatten)]
pub dates: Dates,
pub platforms: Platforms,
}
impl Upload {
pub fn supports(&self, os: &str) -> bool {
match os {
"windows" => self.platforms.windows.is_some(),
"osx" => self.platforms.osx.is_some(),
"linux" => self.platforms.linux.is_some(),
_ => false,
}
}
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub enum Archs {
All,
#[serde(rename = "386")]
i386,
Amd64,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Platforms {
windows: Option<Archs>,
osx: Option<Archs>,
linux: Option<Archs>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct User {
pub id: i32,
pub username: String,
pub display_name: String,
pub developer: bool,
pub press_user: bool,
pub url: String,
pub cover_url: String,
#[serde(default)]
pub still_cover_url: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Build {
pub id: i32,
pub parent_build_id: i32,
pub state: String,
pub version: i32,
#[serde(default)]
pub user_version: String,
pub user: Option<User>,
#[serde(flatten)]
pub dates: Dates,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Cave {
pub id: String,
pub game: Game,
pub upload: Upload,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Response {
pub id: i32,
pub jsonrpc: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Dates {
#[serde(default)]
pub created_at: String,
#[serde(default)]
pub updated_at: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ResponseErr {
#[serde(flatten)]
pub response: Response,
pub error: BError,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct ResponseRes {
#[serde(flatten)]
pub response: Response,
pub result: Map<String, Value>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Sale {
pub id: i32,
pub game_id: i32,
pub rate: i32,
pub start_date: String,
pub end_date: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct InstallLocationSummary {
pub id: String,
pub path: String,
pub size_info: InstallLocationSizeInfo,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct InstallLocationSizeInfo {
pub installed_size: i64,
pub free_size: i64,
pub total_size: i64,
}
#[derive(Serialize, Deserialize, Debug)]
pub enum DownloadReason {
#[serde(rename = "install")]
Install,
#[serde(rename = "reinstall")]
Reinstall,
#[serde(rename = "update")]
Update,
#[serde(rename = "version-switch")]
VersionSwitch,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct QueueResponse {
pub id: String,
pub reason: DownloadReason,
pub cave_id: String,
pub game: Game,
pub upload: Upload,
pub build: Build,
pub install_folder: String,
pub staging_folder: String,
pub install_location_id: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct InstallQueueReq {
pub install_location_id: String,
pub reason: String,
pub game: Game,
pub upload: Upload,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Download {
pub id: String,
pub error: Option<String>,
pub error_message: Option<String>,
pub error_code: Option<String>,
pub reason: DownloadReason,
pub position: i32,
pub cave_id: String,
pub game: Game,
pub upload: Upload,
pub build: Option<Build>,
pub started_at: String,
pub finished_at: Option<String>,
pub staging_folder: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct VersionInfo {
pub version: String,
pub version_string: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct CheckUpdate {
pub updates: Option<Vec<GameUpdate>>,
pub warnings: Option<Vec<String>>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct GameUpdate {
pub cave_id: String,
pub game: Game,
pub direct: bool,
pub choices: Option<Vec<GameUpdateChoice>>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct GameUpdateChoice {
pub upload: Upload,
pub build: Option<Build>,
pub confidence: f64,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct PassLogRes {
pub profile: Profile,
pub cookie: Map<String, Value>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct DownloadKey {
pub id: i64,
pub game_id: i32,
pub game: Game,
pub owner_id: i64,
#[serde(flatten)]
pub dates: Dates,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Commons {
pub download_keys: Vec<DownloadKeySummary>,
pub caves: Vec<CaveSummary>,
pub install_locations: Vec<InstallLocationSummary>,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct DownloadKeySummary {
pub id: i64,
pub game_id: i32,
pub created_at: String,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CaveSummary {
pub id: String,
pub game_id: i32,
pub last_touched_at: Option<String>,
pub seconds_run: i32,
pub installed_size: i64,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct Collection {
pub id: i32,
pub title: String,
#[serde(flatten)]
pub dates: Dates,
pub games_count: i32,
pub collection_games: Option<Vec<CollectionGame>>,
pub user_id: i32,
pub user: User,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct CollectionGame {
pub collection_id: i32,
pub collection: Collection,
pub game_id: i32,
pub game: Game,
pub position: i32,
pub blurb: String,
pub user_id: i32,
#[serde(flatten)]
pub dates: Dates,
}
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
pub struct FsInfo {
pub free_size: i64,
pub total_size: i64,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct CleanDownloadsEntry {
pub path: String,
pub size: i64,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct BError {
pub code: i64,
pub message: String,
}