Skip to main content

fpl_rs/models/
bootstrap_static.rs

1use std::fmt::Display;
2
3use serde::Deserialize;
4use serde::Serialize;
5use serde_json::Value;
6
7
8pub type Players = Vec<Player>;
9
10#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
11pub struct BootstrapStatic {
12    pub events: Vec<Event>,
13    pub game_settings: GameSettings,
14    pub phases: Vec<Phase>,
15    pub teams: Vec<Team>,
16    pub total_players: i64,
17    pub elements: Players,
18    pub element_stats: Vec<PlayerStat>,
19    pub element_types: Vec<PlayerType>,
20}
21
22#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
23pub struct Event {
24    pub id: i64,
25    pub name: String,
26    pub deadline_time: String,
27    pub average_entry_score: i64,
28    pub finished: bool,
29    pub data_checked: bool,
30    pub highest_scoring_entry: Option<i64>,
31    pub deadline_time_epoch: i64,
32    pub deadline_time_game_offset: i64,
33    pub highest_score: Option<i64>,
34    pub is_previous: bool,
35    pub is_current: bool,
36    pub is_next: bool,
37    pub cup_leagues_created: bool,
38    pub h2h_ko_matches_created: bool,
39    pub chip_plays: Vec<ChipPlay>,
40    pub most_selected: Option<i64>,
41    pub most_transferred_in: Option<i64>,
42    pub top_element: Option<i64>,
43    pub top_element_info: Option<TopPlayerInfo>,
44    pub transfers_made: i64,
45    pub most_captained: Option<i64>,
46    pub most_vice_captained: Option<i64>,
47}
48
49#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
50pub struct ChipPlay {
51    pub chip_name: String,
52    pub num_played: i64,
53}
54
55#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
56pub struct TopPlayerInfo {
57    pub id: i64,
58    pub points: i64,
59}
60
61#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
62pub struct GameSettings {
63    pub league_join_private_max: i64,
64    pub league_join_public_max: i64,
65    pub league_max_size_public_classic: i64,
66    pub league_max_size_public_h2h: i64,
67    pub league_max_size_private_h2h: i64,
68    pub league_max_ko_rounds_private_h2h: i64,
69    pub league_prefix_public: String,
70    pub league_points_h2h_win: i64,
71    pub league_points_h2h_lose: i64,
72    pub league_points_h2h_draw: i64,
73    pub league_ko_first_instead_of_random: bool,
74    pub cup_start_event_id: Value,
75    pub cup_stop_event_id: Value,
76    pub cup_qualifying_method: Value,
77    pub cup_type: Value,
78    pub squad_squadplay: i64,
79    pub squad_squadsize: i64,
80    pub squad_team_limit: i64,
81    pub squad_total_spend: i64,
82    pub ui_currency_multiplier: i64,
83    pub ui_use_special_shirts: bool,
84    pub ui_special_shirt_exclusions: Vec<Value>,
85    pub stats_form_days: i64,
86    pub sys_vice_captain_enabled: bool,
87    pub transfers_cap: i64,
88    pub transfers_sell_on_fee: f64,
89    pub league_h2h_tiebreak_stats: Vec<String>,
90    pub timezone: String,
91}
92
93#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
94pub struct Phase {
95    pub id: i64,
96    pub name: String,
97    pub start_event: i64,
98    pub stop_event: i64,
99}
100
101#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
102pub struct Team {
103    pub code: i64,
104    pub draw: i64,
105    pub form: Value,
106    pub id: i64,
107    pub loss: i64,
108    pub name: String,
109    pub played: i64,
110    pub points: i64,
111    pub position: i64,
112    pub short_name: String,
113    pub strength: i64,
114    pub team_division: Value,
115    pub unavailable: bool,
116    pub win: i64,
117    pub strength_overall_home: i64,
118    pub strength_overall_away: i64,
119    pub strength_attack_home: i64,
120    pub strength_attack_away: i64,
121    pub strength_defence_home: i64,
122    pub strength_defence_away: i64,
123    pub pulse_id: i64,
124}
125
126#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
127pub struct Player {
128    pub chance_of_playing_next_round: Option<i64>,
129    pub chance_of_playing_this_round: Option<i64>,
130    pub code: i64,
131    pub cost_change_event: i64,
132    pub cost_change_event_fall: i64,
133    pub cost_change_start: i64,
134    pub cost_change_start_fall: i64,
135    pub dreamteam_count: i64,
136    pub element_type: i64,
137    pub ep_next: String,
138    pub ep_this: String,
139    pub event_points: i64,
140    pub first_name: String,
141    pub form: String,
142    pub id: i64,
143    pub in_dreamteam: bool,
144    pub news: String,
145    pub news_added: Option<String>,
146    pub now_cost: i64,
147    pub photo: String,
148    pub points_per_game: String,
149    pub second_name: String,
150    pub selected_by_percent: String,
151    pub special: bool,
152    pub squad_number: Value,
153    pub status: String,
154    pub team: i64,
155    pub team_code: i64,
156    pub total_points: i64,
157    pub transfers_in: i64,
158    pub transfers_in_event: i64,
159    pub transfers_out: i64,
160    pub transfers_out_event: i64,
161    pub value_form: String,
162    pub value_season: String,
163    pub web_name: String,
164    pub minutes: i64,
165    pub goals_scored: i64,
166    pub assists: i64,
167    pub clean_sheets: i64,
168    pub goals_conceded: i64,
169    pub own_goals: i64,
170    pub penalties_saved: i64,
171    pub penalties_missed: i64,
172    pub yellow_cards: i64,
173    pub red_cards: i64,
174    pub saves: i64,
175    pub bonus: i64,
176    pub bps: i64,
177    pub influence: String,
178    pub creativity: String,
179    pub threat: String,
180    pub ict_index: String,
181    pub starts: i64,
182    pub expected_goals: String,
183    pub expected_assists: String,
184    pub expected_goal_involvements: String,
185    pub expected_goals_conceded: String,
186    pub influence_rank: i64,
187    pub influence_rank_type: i64,
188    pub creativity_rank: i64,
189    pub creativity_rank_type: i64,
190    pub threat_rank: i64,
191    pub threat_rank_type: i64,
192    pub ict_index_rank: i64,
193    pub ict_index_rank_type: i64,
194    pub corners_and_indirect_freekicks_order: Option<i64>,
195    pub corners_and_indirect_freekicks_text: String,
196    pub direct_freekicks_order: Option<i64>,
197    pub direct_freekicks_text: String,
198    pub penalties_order: Option<i64>,
199    pub penalties_text: String,
200    pub expected_goals_per_90: f64,
201    pub saves_per_90: f64,
202    pub expected_assists_per_90: f64,
203    pub expected_goal_involvements_per_90: f64,
204    pub expected_goals_conceded_per_90: f64,
205    pub goals_conceded_per_90: f64,
206    pub now_cost_rank: i64,
207    pub now_cost_rank_type: i64,
208    pub form_rank: i64,
209    pub form_rank_type: i64,
210    pub points_per_game_rank: i64,
211    pub points_per_game_rank_type: i64,
212    pub selected_rank: i64,
213    pub selected_rank_type: i64,
214    pub starts_per_90: f64,
215    pub clean_sheets_per_90: f64,
216}
217
218#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
219pub struct PlayerStat {
220    pub label: String,
221    pub name: String,
222}
223
224#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
225pub struct PlayerType {
226    pub id: i64,
227    pub plural_name: String,
228    pub plural_name_short: String,
229    pub singular_name: String,
230    pub singular_name_short: String,
231    pub squad_select: i64,
232    pub squad_min_play: i64,
233    pub squad_max_play: i64,
234    pub ui_shirt_specific: bool,
235    pub sub_positions_locked: Vec<i64>,
236    pub element_count: i64,
237}
238
239impl Display for Player {
240    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
241        let full_name = self.first_name.to_owned() + " " + self.second_name.as_str();
242        write!(f, "<id: {}, name: {}>", self.id, full_name)
243    }
244}