Skip to main content

mlbt_api/
standings.rs

1use crate::schedule::IdNameLink;
2use serde::{Deserialize, Serialize};
3
4#[derive(Default, Debug, Serialize, Deserialize)]
5pub struct StandingsResponse {
6    pub copyright: String,
7    pub records: Vec<Record>,
8}
9
10#[derive(Debug, Serialize, Deserialize)]
11#[serde(rename_all = "camelCase")]
12pub struct Record {
13    pub standings_type: String,
14    pub league: IdLink,
15    pub division: Option<IdLink>,
16    pub last_updated: String,
17    pub team_records: Vec<TeamRecord>,
18}
19
20#[derive(Debug, Serialize, Deserialize)]
21pub struct IdLink {
22    pub id: u8,
23    pub link: String,
24}
25
26#[derive(Debug, Serialize, Deserialize)]
27#[serde(rename_all = "camelCase")]
28pub struct TeamRecord {
29    pub team: IdNameLink,
30    pub season: String,
31    pub streak: Option<Streak>,
32    pub division_rank: Option<String>,
33    pub league_rank: String,
34    pub sport_rank: Option<String>,
35    pub games_played: u8,
36    pub games_back: String,
37    pub wild_card_games_back: String,
38    pub league_games_back: String,
39    pub sport_games_back: String,
40    pub division_games_back: String,
41    pub conference_games_back: String,
42    pub league_record: RecordElement,
43    pub last_updated: String,
44    pub records: Records,
45    pub runs_allowed: u16,
46    pub runs_scored: u16,
47    pub division_champ: Option<bool>,
48    pub division_leader: bool,
49    pub has_wildcard: Option<bool>,
50    pub clinched: Option<bool>,
51    pub elimination_number: Option<String>,
52    pub magic_number: Option<String>,
53    pub wins: u8,
54    pub losses: u8,
55    pub run_differential: i16,
56    pub winning_percentage: String,
57    pub wild_card_rank: Option<String>,
58    pub wild_card_leader: Option<bool>,
59    pub wild_card_elimination_number: Option<String>,
60}
61
62#[derive(Debug, Serialize, Deserialize)]
63pub struct RecordElement {
64    pub wins: u8,
65    pub losses: u8,
66    pub pct: String,
67    pub division: Option<IdNameLink>,
68    #[serde(rename = "type")]
69    pub record_type: Option<String>,
70    pub league: Option<IdNameLink>,
71}
72
73#[derive(Debug, Serialize, Deserialize)]
74#[serde(rename_all = "camelCase")]
75pub struct Records {
76    pub split_records: Vec<RecordElement>,
77    pub division_records: Option<Vec<RecordElement>>,
78    pub overall_records: Vec<RecordElement>,
79    pub league_records: Vec<RecordElement>,
80    pub expected_records: Option<Vec<RecordElement>>,
81}
82
83#[derive(Debug, Serialize, Deserialize)]
84#[serde(rename_all = "camelCase")]
85pub struct Streak {
86    pub streak_type: Option<String>,
87    pub streak_number: Option<u8>,
88    pub streak_code: String,
89}