/*
* Stadar Esports Data API
*
* Read-only esports data across all major competitive titles. Flat-tier pricing (no per-game gates), monthly subscriptions, sandbox keys for evaluation. See https://stadar.net for tier pricing. All endpoints under `/v1/...`. The version in `info.version` matches the URL prefix; non-breaking field additions ship in `/v1`, breaking changes get a `/v2`. We commit to 24 months of `/v1` support after `/v2` ships. Times are UTC end-to-end (RFC 3339). Localization is the client's problem. Cursors are opaque base64 strings; treat them as such.
*
* The version of the OpenAPI document: v1
* Contact: api@stadar.net
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct Match {
#[serde(rename = "id", skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "game", skip_serializing_if = "Option::is_none")]
pub game: Option<String>,
#[serde(rename = "league", skip_serializing_if = "Option::is_none")]
pub league: Option<Box<models::LeagueSummary>>,
#[serde(rename = "series", skip_serializing_if = "Option::is_none")]
pub series: Option<Box<models::SeriesSummary>>,
#[serde(rename = "tournament", skip_serializing_if = "Option::is_none")]
pub tournament: Option<Box<models::TournamentSummary>>,
#[serde(rename = "status", skip_serializing_if = "Option::is_none")]
pub status: Option<Status>,
#[serde(rename = "format", skip_serializing_if = "Option::is_none")]
pub format: Option<String>,
#[serde(rename = "scheduled_at", skip_serializing_if = "Option::is_none")]
pub scheduled_at: Option<chrono::DateTime<chrono::FixedOffset>>,
#[serde(rename = "original_scheduled_at", skip_serializing_if = "Option::is_none")]
pub original_scheduled_at: Option<chrono::DateTime<chrono::FixedOffset>>,
#[serde(rename = "rescheduled", skip_serializing_if = "Option::is_none")]
pub rescheduled: Option<bool>,
#[serde(rename = "started_at", skip_serializing_if = "Option::is_none")]
pub started_at: Option<chrono::DateTime<chrono::FixedOffset>>,
#[serde(rename = "completed_at", skip_serializing_if = "Option::is_none")]
pub completed_at: Option<chrono::DateTime<chrono::FixedOffset>>,
#[serde(rename = "patch_version", skip_serializing_if = "Option::is_none")]
pub patch_version: Option<String>,
#[serde(rename = "has_detailed_stats", skip_serializing_if = "Option::is_none")]
pub has_detailed_stats: Option<bool>,
#[serde(rename = "forfeit", skip_serializing_if = "Option::is_none")]
pub forfeit: Option<bool>,
#[serde(rename = "participants", skip_serializing_if = "Option::is_none")]
pub participants: Option<Vec<models::MatchParticipant>>,
/// Per-game / per-map telemetry. Empty/absent for matches without an upstream live counterpart; populated for matches linked to a per-game telemetry feed. For CS2 each entry is one map (inferno, mirage, …); for Dota 2 / LoL each is one match inside a Bo3/Bo5.
#[serde(rename = "games", skip_serializing_if = "Option::is_none")]
pub games: Option<Vec<models::MatchGame>>,
#[serde(rename = "streams", skip_serializing_if = "Option::is_none")]
pub streams: Option<Vec<models::Stream>>,
/// Source-specific JSON snapshot of the most recent mid-game state. Refreshed up to once per 60 seconds for matches whose game backs the `live_tick` capability flag (advertised in `/v1/games/<slug>.features`). Absent / null when no live snapshot has been recorded yet, or when the match has completed / cancelled. The top-level `source` field discriminates the inner schema: - `\"source\": \"grid\"` carries a `series_state` object with `started` / `finished` / `teams[].score` / `teams[].kills` / per-game `map` + `sequence`. - `\"source\": \"stratz\"` carries a `match_state` object with `didRadiantWin` / `durationSeconds` / `endDateTime` / `radiantScore` / `direScore` / `gameMode` / `lobbyType` / `gameVersionId`. The snapshot is passed through verbatim from the upstream — no v1 normalization. Code defensively against new fields appearing and existing fields shifting inside the per-source nested object.
#[serde(rename = "live_state", skip_serializing_if = "Option::is_none")]
pub live_state: Option<std::collections::HashMap<String, serde_json::Value>>,
/// UTC timestamp of the last successful live snapshot apply for this match. Compare against the current wall clock to detect stale snapshots without parsing the `live_state` JSON. Absent / null when `live_state` is absent / null.
#[serde(rename = "live_state_updated_at", skip_serializing_if = "Option::is_none")]
pub live_state_updated_at: Option<chrono::DateTime<chrono::FixedOffset>>,
/// STRATZ-sourced Dota 2 match depth: the draft (pick/ban), per-lane outcomes, and per-player role + IMP. Embedded inline (not a sub-resource) to keep one round-trip. Present only for a Dota 2 match that has STRATZ depth — either the requested match is the STRATZ row, or its Liquipedia counterpart is linked to one. Absent (omitted, not null) for CS2 / Liquipedia-only / non-Dota matches; no 404 for missing depth, same contract as `live_state` and `games`. Gated behind the `match_stats` capability (Hobbyist+): Free tier never receives the block, and a STRATZ credit appears in `meta.sources` only when the block is present.
#[serde(rename = "dota2", skip_serializing_if = "Option::is_none")]
pub dota2: Option<Box<models::Dota2Block>>,
}
impl Match {
pub fn new() -> Match {
Match {
id: None,
game: None,
league: None,
series: None,
tournament: None,
status: None,
format: None,
scheduled_at: None,
original_scheduled_at: None,
rescheduled: None,
started_at: None,
completed_at: None,
patch_version: None,
has_detailed_stats: None,
forfeit: None,
participants: None,
games: None,
streams: None,
live_state: None,
live_state_updated_at: None,
dota2: None,
}
}
}
///
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
#[serde(rename = "scheduled")]
Scheduled,
#[serde(rename = "live")]
Live,
#[serde(rename = "completed")]
Completed,
#[serde(rename = "cancelled")]
Cancelled,
#[serde(rename = "postponed")]
Postponed,
}
impl Default for Status {
fn default() -> Status {
Self::Scheduled
}
}