1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// todo
// use crate::meta::GameType;
// use crate::person::PersonId;
// use crate::request::RequestURL;
// use crate::season::SeasonId;
// use crate::sport::SportId;
// use crate::meta::StatGroup;
// use crate::meta::StatType;
// use crate::stats::Stats;
// use crate::team::TeamId;
// use crate::{Copyright, MLB_API_DATE_FORMAT};
// use bon::Builder;
// use chrono::NaiveDate;
// use either::Either;
// use itertools::Itertools;
// use serde::Deserialize;
// use std::fmt::{Display, Formatter};
// use std::marker::PhantomData;
//
// #[derive(Debug, Deserialize, PartialEq, Clone)]
// #[serde(bound = "S: Stats")]
// pub struct TeamsStatsResponse<S: Stats> {
// pub copyright: Copyright,
// pub stats: S,
// }
//
// #[derive(Builder)]
// #[builder(derive(Into))]
// #[builder(start_fn(vis = ""))]
// pub struct TeamsStatsRequest<S: Stats> {
// #[builder(setters(vis = "", name = __id_internal))]
// pub id: Either<TeamId, SportId>,
// #[builder(into)]
// pub season: Option<SeasonId>,
// pub game_type: GameType,
// pub stat_types: Vec<StatType>,
// pub stat_groups: Vec<StatGroup>,
// pub start_date: Option<NaiveDate>,
// pub end_date: Option<NaiveDate>,
// #[builder(into)]
// pub opposing_player: Option<PersonId>,
// #[builder(into)]
// pub opposing_team: Option<PersonId>,
// #[builder(skip)]
// _marker: PhantomData<S>,
// }
//
// impl<S: Stats, State: teams_stats_request_builder::State + teams_stats_request_builder::IsComplete> crate::request::RequestURLBuilderExt for TeamsStatsRequestBuilder<S, State> {
// type Built = TeamsStatsRequest<S>;
// }
//
// impl<S: Stats> TeamsStatsRequest<S> {
// pub fn for_team(team_id: impl Into<TeamId>) -> TeamsStatsRequestBuilder<S, teams_stats_request_builder::SetId> {
// Self::builder().__id_internal(Either::Left(team_id.into()))
// }
//
// pub fn for_sport(sport_id: impl Into<SportId>) -> TeamsStatsRequestBuilder<S, teams_stats_request_builder::SetId> {
// Self::builder().__id_internal(Either::Right(sport_id.into()))
// }
// }
//
// impl<S: Stats> Display for TeamsStatsRequest<S> {
// #[allow(clippy::cognitive_complexity, reason = "still readable")]
// fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
// match self.id {
// Either::Left(id ) => write!(
// f,
// "http://statsapi.mlb.com/api/v1/teams/{id}/stats{params}",
// params = gen_params! {
// "season"?: self.season,
// "gameType": self.game_type,
// "stats": self.stat_types.iter().join(","),
// "group": self.stat_groups.iter().join(","),
// "startDate"?: self.start_date.map(|x| x.format(MLB_API_DATE_FORMAT)),
// "endDate"?: self.start_date.map(|x| x.format(MLB_API_DATE_FORMAT)),
// "opposingPlayerId"?: self.opposing_player,
// "opposingTeamId"?: self.opposing_team,
// }
// ),
// Either::Right(id) => write!(
// f,
// "http://statsapi.mlb.com/api/v1/teams/stats{params}",
// params = gen_params! {
// "season"?: self.season,
// "gameType": self.game_type,
// "stats": self.stat_types.iter().join(","),
// "group": self.stat_groups.iter().join(","),
// "sportId": id,
// "startDate"?: self.start_date.map(|x| x.format(MLB_API_DATE_FORMAT)),
// "endDate"?: self.start_date.map(|x| x.format(MLB_API_DATE_FORMAT)),
// "opposingPlayerId"?: self.opposing_player,
// "opposingTeamId"?: self.opposing_team,
// }
// ),
// }
// }
// }
//
// impl<S: Stats> RequestURL for TeamsStatsRequest<S> {
// type Response = TeamsStatsResponse<S>;
// }