1use crate::schedule::IdNameLink;
2use serde::{Deserialize, Serialize};
3
4#[derive(Default, Debug, Serialize, Deserialize)]
5pub struct StatsResponse {
6 pub stats: Vec<Stat>,
7}
8
9#[derive(Debug, Serialize, Deserialize)]
10#[serde(rename_all = "camelCase")]
11pub struct Stat {
12 #[serde(rename = "type")]
13 pub stat_type: DisplayName,
14 pub group: DisplayName,
15 #[serde(default)]
16 pub total_splits: Option<u16>,
17 pub splits: Vec<Split>,
18}
19
20#[derive(Debug, Serialize, Deserialize)]
21#[serde(rename_all = "camelCase")]
22pub struct DisplayName {
23 pub display_name: String,
24}
25
26#[derive(Debug, Serialize, Deserialize)]
27#[serde(rename_all = "camelCase")]
28pub struct Split {
29 pub season: Option<String>,
30 pub stat: StatSplit,
31 pub team: Option<IdNameLink>,
32 pub player: Option<Player>,
33 pub date: Option<String>,
35 pub is_home: Option<bool>,
36 pub is_win: Option<bool>,
37 pub opponent: Option<IdNameLink>,
38 pub game: Option<GameRef>,
39}
40
41#[derive(Debug, Serialize, Deserialize)]
42#[serde(rename_all = "camelCase")]
43pub struct GameRef {
44 pub game_pk: u64,
45}
46
47#[derive(Debug, Serialize, Deserialize)]
48#[serde(rename_all = "camelCase")]
49pub struct Player {
50 pub id: u64,
51 pub full_name: String,
52 pub first_name: Option<String>,
53 pub last_name: Option<String>,
54}
55
56#[derive(Debug, Serialize, Deserialize)]
60#[serde(untagged)]
61pub enum StatSplit {
62 Pitching(Box<PitchingStat>),
63 Hitting(Box<HittingStat>),
64}
65
66#[derive(Debug, Serialize, Deserialize)]
67#[serde(rename_all = "camelCase")]
68pub struct PitchingStat {
69 pub wins: u16,
70 pub losses: u16,
71 pub era: String,
72 pub games_played: u16,
73 pub games_started: u16,
74 pub complete_games: u16,
75 pub shutouts: u16,
76 pub saves: u16,
77 pub save_opportunities: u16,
78 ground_outs: u16,
79 air_outs: u16,
80 pub innings_pitched: String,
81 pub hits: u16,
82 pub runs: u16,
83 pub earned_runs: u16,
84 doubles: i64,
85 triples: i64,
86 pub home_runs: u16,
87 pub hit_batsmen: u16,
88 pub base_on_balls: u16,
89 pub strike_outs: u16,
90 intentional_walks: u16,
91 hit_by_pitch: u16,
92 pub whip: String,
93 pub avg: String,
94 at_bats: u16,
95 obp: String,
96 slg: String,
97 ops: String,
98 caught_stealing: u16,
99 stolen_bases: u16,
100 stolen_base_percentage: String,
101 ground_into_double_play: u16,
102 number_of_pitches: u16,
103 holds: u16,
104 blown_saves: u16,
105 batters_faced: u16,
106 outs: u16,
107 games_pitched: u16,
108 strikes: u32,
109 strike_percentage: String,
110 balks: u16,
111 wild_pitches: u16,
112 pickoffs: Option<u16>,
113 total_bases: u16,
114 ground_outs_to_airouts: String,
115 win_percentage: String,
116 pitches_per_inning: String,
117 games_finished: u16,
118 strikeout_walk_ratio: String,
119 strikeouts_per9_inn: String,
120 walks_per9_inn: String,
121 hits_per9_inn: String,
122 runs_scored_per9: String,
123 home_runs_per9: String,
124 catchers_interference: Option<u16>,
125 sac_bunts: u16,
126 sac_flies: u16,
127}
128
129#[derive(Default, Debug, Serialize, Deserialize)]
130#[serde(rename_all = "camelCase")]
131pub struct HittingStat {
132 pub games_played: u16,
133 pub ground_outs: u16,
134 pub air_outs: u16,
135 pub runs: u16,
136 pub doubles: u16,
137 pub triples: u16,
138 pub home_runs: u16,
139 pub strike_outs: u16,
140 pub base_on_balls: u16,
141 pub intentional_walks: u16,
142 pub hits: u16,
143 pub hit_by_pitch: u16,
144 pub avg: String,
145 pub at_bats: u16,
146 pub obp: String,
147 pub slg: String,
148 pub ops: String,
149 pub caught_stealing: u16,
150 pub stolen_bases: u16,
151 pub stolen_base_percentage: String,
152 pub ground_into_double_play: u16,
153 pub number_of_pitches: u16,
154 pub plate_appearances: u16,
155 pub total_bases: u16,
156 pub rbi: u16,
157 pub left_on_base: u16,
158 pub sac_bunts: u16,
159 pub sac_flies: u16,
160 pub babip: String,
161 pub ground_outs_to_airouts: String,
162 pub catchers_interference: Option<u16>,
163 pub at_bats_per_home_run: String,
164}