1use crate::boxscore::Boxscore;
2use crate::plays::Plays;
3use crate::schedule::Status;
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7#[derive(Default, Debug, Serialize, Deserialize)]
8#[serde(rename_all = "camelCase")]
9pub struct LiveResponse {
10 pub game_pk: u64,
11 pub link: String,
12 pub meta_data: MetaData,
13 pub game_data: GameData,
14 pub live_data: LiveData,
15}
16
17#[derive(Default, Debug, Serialize, Deserialize)]
18#[serde(rename_all = "camelCase")]
19pub struct MetaData {
20 pub wait: i64,
21 pub time_stamp: String,
22 pub game_events: Vec<String>,
23 pub logical_events: Vec<String>,
24}
25
26#[derive(Default, Debug, Serialize, Deserialize)]
27#[serde(rename_all = "camelCase")]
28pub struct GameData {
29 pub game: Game,
30 pub teams: Teams,
31 pub players: HashMap<String, FullPlayer>,
32 pub abs_challenges: Option<AbsChallenges>,
33 pub status: Status,
34}
35
36#[derive(Default, Debug, Serialize, Deserialize)]
37#[serde(rename_all = "camelCase")]
38pub struct LiveData {
39 pub plays: Plays,
40 pub linescore: Linescore,
41 pub boxscore: Boxscore,
42}
43
44#[derive(Default, Debug, Serialize, Deserialize)]
45#[serde(rename_all = "camelCase")]
46pub struct Linescore {
47 pub current_inning: Option<u8>,
48 pub current_inning_ordinal: Option<String>,
49 pub inning_state: Option<String>,
50 pub inning_half: Option<String>,
51 pub is_top_inning: Option<bool>,
52 pub scheduled_innings: Option<u8>,
53 pub innings: Vec<Inning>,
54 pub offense: Offense,
57 pub balls: Option<u8>,
58 pub strikes: Option<u8>,
59 pub outs: Option<u8>,
60}
61
62#[derive(Default, Debug, Serialize, Deserialize)]
63#[serde(rename_all = "camelCase")]
64pub struct Inning {
65 pub num: u8,
66 pub ordinal_num: String,
67 pub home: TeamInningDetail,
68 pub away: TeamInningDetail,
69}
70
71#[derive(Default, Debug, Serialize, Deserialize)]
72#[serde(rename_all = "camelCase")]
73pub struct TeamInningDetail {
74 pub runs: Option<u8>,
75 pub hits: u8,
76 pub errors: u8,
77 pub left_on_base: u8,
78}
79
80#[derive(Default, Debug, Serialize, Deserialize)]
81#[serde(rename_all = "camelCase")]
82pub struct Offense {
83 pub on_deck: Option<PlayerIdName>,
84 pub in_hole: Option<PlayerIdName>,
85}
86
87#[derive(Default, Debug, Serialize, Deserialize)]
88pub struct PlayerIdName {
89 pub id: u64,
90 #[serde(rename = "fullName")]
91 pub full_name: String,
92}
93
94#[derive(Default, Debug, Serialize, Deserialize)]
95#[serde(rename_all = "camelCase")]
96pub struct Game {
97 pub pk: i64,
98 #[serde(rename = "type")]
99 pub type_field: String,
100 pub double_header: String,
101 pub id: String,
102 pub gameday_type: String,
103 pub tiebreaker: String,
104 pub game_number: i64,
105 #[serde(rename = "calendarEventID")]
106 pub calendar_event_id: String,
107 pub season: String,
108 pub season_display: String,
109}
110
111#[derive(Default, Debug, Serialize, Deserialize)]
112#[serde(rename_all = "camelCase")]
113pub struct PerTeamChallenges {
114 pub used_successful: u8,
115 pub used_failed: u8,
116 pub remaining: u8,
117}
118
119#[derive(Default, Debug, Serialize, Deserialize)]
120#[serde(rename_all = "camelCase")]
121pub struct AbsChallenges {
122 pub has_challenges: bool,
123 pub away: PerTeamChallenges,
124 pub home: PerTeamChallenges,
125}
126
127#[derive(Default, Debug, Serialize, Deserialize)]
128#[serde(rename_all = "camelCase")]
129pub struct Teams {
130 pub away: Team,
131 pub home: Team,
132}
133
134#[derive(Default, Debug, Serialize, Deserialize)]
135#[serde(rename_all = "camelCase")]
136pub struct Team {
137 pub id: u16,
138 pub name: String,
139 pub team_name: String,
140 pub short_name: String,
141 pub season: u16,
142 pub team_code: String,
143 pub abbreviation: String,
144}
145
146#[derive(Default, Debug, Serialize, Deserialize)]
147pub struct Person {
148 pub id: u64,
149 #[serde(rename = "fullName")]
150 pub full_name: String,
151 pub link: Option<String>,
152}
153
154#[derive(Debug, Serialize, Deserialize)]
155pub struct Side {
156 pub code: String,
157 pub description: String,
158}
159
160#[derive(Debug, Serialize, Deserialize)]
161pub struct PrimaryPosition {
162 pub code: String,
163 pub name: String,
164 #[serde(rename = "type")]
165 pub r#type: String,
166 pub abbreviation: String,
167}
168
169#[derive(Debug, Serialize, Deserialize)]
170#[serde(rename_all = "camelCase")]
171pub struct FullPlayer {
172 pub id: u64,
173 pub full_name: String,
174 pub link: Option<String>,
175 pub first_name: String,
176 pub last_name: String,
177 pub primary_number: Option<String>,
178 pub birth_date: Option<String>,
179 pub current_age: Option<i64>,
180 pub birth_city: Option<String>,
181 pub birth_state_province: Option<String>,
182 pub birth_country: Option<String>,
183 pub height: Option<String>,
184 pub weight: Option<u16>,
185 pub active: Option<bool>,
186 pub primary_position: Option<PrimaryPosition>,
187 pub use_name: Option<String>,
188 pub use_last_name: Option<String>,
189 pub middle_name: Option<String>,
190 pub boxscore_name: Option<String>,
191 pub gender: Option<String>,
192 pub is_player: Option<bool>,
193 pub is_verified: Option<bool>,
194 pub draft_year: Option<i64>,
195 pub mlb_debut_date: Option<String>,
196 pub bat_side: Option<Side>,
197 pub pitch_hand: Option<Side>,
198 pub name_first_last: Option<String>,
199 pub name_slug: Option<String>,
200 pub first_last_name: Option<String>,
201 pub last_first_name: Option<String>,
202 pub last_init_name: Option<String>,
203 pub init_last_name: String,
204 #[serde(rename = "fullFMLName")]
205 pub full_fmlname: Option<String>,
206 #[serde(rename = "fullLFMName")]
207 pub full_lfmname: Option<String>,
208 pub strike_zone_top: Option<f64>,
209 pub strike_zone_bottom: Option<f64>,
210}