mlb_api/endpoints/jobs/umpire/
mod.rs

1use crate::endpoints::jobs::JobsResponse;
2use crate::endpoints::sports::SportId;
3use crate::endpoints::StatsAPIUrl;
4use crate::gen_params;
5use crate::types::MLB_API_DATE_FORMAT;
6use chrono::NaiveDate;
7use std::fmt::{Display, Formatter};
8
9// pub mod games; // needs private mlb-only api key -- absolutely not going to implement this.
10
11pub struct JobsUmpiresEndpointUrl {
12    pub sport_id: Option<SportId>,
13    pub date: Option<NaiveDate>,
14}
15
16impl Display for JobsUmpiresEndpointUrl {
17    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
18        write!(f, "http://statsapi.mlb.com/api/v1/jobs/umpires{}", gen_params! { "sportId"?: self.sport_id, "date"?: self.date.as_ref().map(|date| date.format(MLB_API_DATE_FORMAT)) })
19    }
20}
21
22impl StatsAPIUrl for JobsUmpiresEndpointUrl {
23	type Response = JobsResponse;
24}