mlb_api/endpoints/seasons/
mod.rs1pub mod season;
2
3mod types;
4
5use std::fmt::{Display, Formatter};
6pub use types::*;
7use crate::endpoints::sports::SportId;
8use crate::endpoints::Url;
9
10pub struct SeasonsEndpointUrl {
11 sport_id: SportId,
12}
13
14impl Display for SeasonsEndpointUrl {
15 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
16 write!(f, "https://statsapi.mlb.com/api/v1/seasons?sportId={sport_id}", sport_id = self.sport_id)
17 }
18}
19
20impl Url<SeasonsResponse> for SeasonsEndpointUrl {}
21
22#[cfg(test)]
23mod tests {
24 use crate::endpoints::seasons::SeasonsEndpointUrl;
25 use crate::endpoints::sports::SportId;
26 use crate::endpoints::Url;
27
28 #[tokio::test]
29 async fn parses_all_seasons() {
30 for id in SportId::IDS {
31 let _response = SeasonsEndpointUrl { sport_id: id }.get().await.unwrap();
32 }
33 }
34}