use libtad_models::onthisday::EventType;
use serde::Serialize;
#[derive(Default, Serialize)]
pub struct OnThisDayRequest {
month: Option<u8>,
day: Option<u8>,
lang: Option<Vec<String>>,
types: Option<Vec<EventType>>,
}
impl OnThisDayRequest {
pub fn new() -> Self {
Default::default()
}
pub fn set_month(mut self, month: u8) -> Self {
self.month.insert(month);
self
}
pub fn set_day(mut self, day: u8) -> Self {
self.day.insert(day);
self
}
pub fn with_lang(mut self, lang: impl Into<String>) -> Self {
if let Some(ref mut langs) = self.lang {
langs.push(lang.into());
} else {
self.lang.insert(vec![lang.into()]);
}
self
}
pub fn with_type(mut self, event_type: EventType) -> Self {
if let Some(ref mut types) = self.types {
types.push(event_type);
} else {
self.types.insert(vec![event_type]);
}
self
}
}