neis_client/types/
meal_service.rs1#![allow(non_snake_case)]
2use super::ToQueryString;
3use super::deserialize_i32_from_f64;
4use form_urlencoded::Serializer;
5use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize)]
8pub struct MealServiceParams {
9 pub ATPT_OFCDC_SC_CODE: String,
11 pub SD_SCHUL_CODE: String,
13 pub MMEAL_SC_CODE: Option<String>,
15 pub MLSV_YMD: Option<String>,
17 pub MLSV_FROM_YMD: Option<String>,
19 pub MLSV_TO_YMD: Option<String>,
21}
22
23impl MealServiceParams {
24 pub fn new(atpt_ofcdc_sc_code: &str, sd_schul_code: &str) -> Self {
25 Self {
26 ATPT_OFCDC_SC_CODE: atpt_ofcdc_sc_code.to_owned(),
27 SD_SCHUL_CODE: sd_schul_code.to_owned(),
28 MMEAL_SC_CODE: None,
29 MLSV_YMD: None,
30 MLSV_FROM_YMD: None,
31 MLSV_TO_YMD: None,
32 }
33 }
34
35 pub fn ymd(mut self, year: i32, month: u8, day: u8) -> Self {
36 self.MLSV_YMD = Some(format!("{:04}{:02}{:02}", year, month, day));
37 self
38 }
39 pub fn from_ymd(mut self, year: i32, month: u8, day: u8) -> Self {
40 self.MLSV_FROM_YMD = Some(format!("{:04}{:02}{:02}", year, month, day));
41 self
42 }
43 pub fn to_ymd(mut self, year: i32, month: u8, day: u8) -> Self {
44 self.MLSV_TO_YMD = Some(format!("{:04}{:02}{:02}", year, month, day));
45 self
46 }
47}
48
49impl ToQueryString for MealServiceParams {
50 fn to_query_string(&self) -> String {
51 let mut serializer = Serializer::new(String::new());
52
53 serializer.append_pair("ATPT_OFCDC_SC_CODE", &self.ATPT_OFCDC_SC_CODE);
54 serializer.append_pair("SD_SCHUL_CODE", &self.SD_SCHUL_CODE);
55 if let Some(s) = &self.MMEAL_SC_CODE {
56 serializer.append_pair("MMEAL_SC_CODE", s);
57 }
58 if let Some(s) = &self.MLSV_YMD {
59 serializer.append_pair("MLSV_YMD", s);
60 }
61 if let Some(s) = &self.MLSV_FROM_YMD {
62 serializer.append_pair("MLSV_FROM_YMD", s);
63 }
64 if let Some(s) = &self.MLSV_TO_YMD {
65 serializer.append_pair("MLSV_TO_YMD", s);
66 }
67
68 serializer.finish()
69 }
70}
71
72#[derive(Debug, Clone, Deserialize, Hash)]
73pub struct MealServiceItem {
74 pub ATPT_OFCDC_SC_CODE: String,
77
78 pub ATPT_OFCDC_SC_NM: String,
81
82 pub SD_SCHUL_CODE: String,
85
86 pub SCHUL_NM: String,
89
90 pub MMEAL_SC_CODE: String,
93
94 pub MMEAL_SC_NM: String,
97
98 pub MLSV_YMD: String,
101
102 #[serde(deserialize_with = "deserialize_i32_from_f64")]
105 pub MLSV_FGR: i32,
106
107 pub DDISH_NM: String,
109
110 pub ORPLC_INFO: String,
112
113 pub CAL_INFO: Option<String>,
115
116 pub NTR_INFO: Option<String>,
118
119 pub MLSV_FROM_YMD: String,
122
123 pub MLSV_TO_YMD: String,
126
127 pub LOAD_DTM: String,
130}