gingr/endpoint/
report_cards_files.rs1use super::{LocationId, Method, Request};
2
3fn push_optional<T: core::fmt::Display>(
4 params: &mut Vec<(String, String)>,
5 key: &str,
6 value: Option<T>,
7) {
8 if let Some(value) = value {
9 params.push((key.to_owned(), value.to_string()));
10 }
11}
12
13#[derive(Clone, Debug, Default, PartialEq, Eq)]
14pub struct ReportCardFiles {
16 number_days: Option<u64>,
17 limit: Option<u64>,
18 location_id: Option<LocationId>,
19}
20
21impl ReportCardFiles {
22 pub fn builder() -> ReportCardFilesBuilder {
24 ReportCardFilesBuilder::default()
25 }
26}
27
28#[derive(Clone, Debug, Default)]
29pub struct ReportCardFilesBuilder {
31 number_days: Option<u64>,
32 limit: Option<u64>,
33 location_id: Option<LocationId>,
34}
35
36impl ReportCardFilesBuilder {
37 pub fn number_days(mut self, number_days: u64) -> Self {
39 self.number_days = Some(number_days);
40 self
41 }
42
43 pub fn limit(mut self, limit: u64) -> Self {
45 self.limit = Some(limit);
46 self
47 }
48
49 pub fn location_id(mut self, location_id: LocationId) -> Self {
51 self.location_id = Some(location_id);
52 self
53 }
54
55 pub fn build(self) -> ReportCardFiles {
57 ReportCardFiles {
58 number_days: self.number_days,
59 limit: self.limit,
60 location_id: self.location_id,
61 }
62 }
63}
64
65impl Request for ReportCardFiles {
66 fn method(&self) -> Method {
67 Method::Get
68 }
69
70 fn path(&self) -> &'static str {
71 "/api/v1/report_card_files"
72 }
73
74 fn parameters(&self) -> Vec<(String, String)> {
75 let mut params = Vec::new();
76 push_optional(&mut params, "number_days", self.number_days);
77 push_optional(&mut params, "limit", self.limit);
78 push_optional(&mut params, "location_id", self.location_id);
79 params
80 }
81}