stadar 0.1.27

Rust SDK for the stadar.net esports data API.
/*
 * 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 OddsMarket {
    #[serde(rename = "market")]
    pub market: Market,
    /// Market-dependent. moneyline: home|away. handicap: plus|minus (relative to `line`, for the team in `side`). total_maps: over|under. total_maps_parity: even|odd. correct_score: \"<a>_<b>\" from the perspective of the team in `side`. team_map_win: yes|no. 
    #[serde(rename = "selection")]
    pub selection: String,
    /// Home/away relative to THIS match's participant ordering. Null when the market has no side (totals, parity) or the orientation could not be established — in the latter case do not infer a side from position. 
    #[serde(rename = "side", skip_serializing_if = "Option::is_none")]
    pub side: Option<Side>,
    /// Handicap or total line as a decimal string; null for line-less markets.
    #[serde(rename = "line", skip_serializing_if = "Option::is_none")]
    pub line: Option<String>,
    /// Decimal odds. A string, not a number, to avoid float round-tripping a DECIMAL.
    #[serde(rename = "price")]
    pub price: String,
    /// The bookmaker's own peak-since-open figure. Undocumented upstream; surfaced as-is.
    #[serde(rename = "max_price", skip_serializing_if = "Option::is_none")]
    pub max_price: Option<String>,
    /// First price observed for this selection, frozen at insert.
    #[serde(rename = "opening_price", skip_serializing_if = "Option::is_none")]
    pub opening_price: Option<String>,
    /// False when the bookmaker has suspended the selection.
    #[serde(rename = "active")]
    pub active: bool,
    #[serde(rename = "observed_at")]
    pub observed_at: chrono::DateTime<chrono::FixedOffset>,
}

impl OddsMarket {
    pub fn new(market: Market, selection: String, price: String, active: bool, observed_at: chrono::DateTime<chrono::FixedOffset>) -> OddsMarket {
        OddsMarket {
            market,
            selection,
            side: None,
            line: None,
            price,
            max_price: None,
            opening_price: None,
            active,
            observed_at,
        }
    }
}
/// 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Market {
    #[serde(rename = "moneyline")]
    Moneyline,
    #[serde(rename = "handicap")]
    Handicap,
    #[serde(rename = "total_maps")]
    TotalMaps,
    #[serde(rename = "total_maps_parity")]
    TotalMapsParity,
    #[serde(rename = "correct_score")]
    CorrectScore,
    #[serde(rename = "team_map_win")]
    TeamMapWin,
    #[serde(rename = "unknown")]
    Unknown,
}

impl Default for Market {
    fn default() -> Market {
        Self::Moneyline
    }
}
/// Home/away relative to THIS match's participant ordering. Null when the market has no side (totals, parity) or the orientation could not be established — in the latter case do not infer a side from position. 
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Side {
    #[serde(rename = "home")]
    Home,
    #[serde(rename = "away")]
    Away,
}

impl Default for Side {
    fn default() -> Side {
        Self::Home
    }
}