gingr/endpoint/
reference_data.rs1use super::{AnimalId, Method, Request, SpeciesId};
2
3#[derive(Clone, Debug, Default, PartialEq, Eq)]
4pub struct GetLocations;
6
7impl Request for GetLocations {
8 fn method(&self) -> Method {
9 Method::Get
10 }
11
12 fn path(&self) -> &'static str {
13 "/api/v1/get_locations"
14 }
15
16 fn parameters(&self) -> Vec<(String, String)> {
17 Vec::new()
18 }
19}
20
21macro_rules! simple_reference_endpoint {
22 ($name:ident, $path:literal) => {
23 #[derive(Clone, Debug, Default, PartialEq, Eq)]
24 pub struct $name;
26
27 impl Request for $name {
28 fn method(&self) -> Method {
29 Method::Get
30 }
31
32 fn path(&self) -> &'static str {
33 $path
34 }
35
36 fn parameters(&self) -> Vec<(String, String)> {
37 Vec::new()
38 }
39 }
40 };
41}
42
43simple_reference_endpoint!(GetSpecies, "/api/v1/get_species");
44simple_reference_endpoint!(GetBreeds, "/api/v1/get_breeds");
45simple_reference_endpoint!(GetTemperaments, "/api/v1/get_temperaments");
46
47#[derive(Clone, Debug, Default, PartialEq, Eq)]
48pub struct GetVets {
50 include_all_information: bool,
51}
52
53impl GetVets {
54 pub fn builder() -> GetVetsBuilder {
56 GetVetsBuilder::default()
57 }
58}
59
60#[derive(Clone, Debug, Default)]
61pub struct GetVetsBuilder {
63 include_all_information: bool,
64}
65
66impl GetVetsBuilder {
67 pub fn include_all_information(mut self, include_all_information: bool) -> Self {
69 self.include_all_information = include_all_information;
70 self
71 }
72
73 pub fn build(self) -> GetVets {
75 GetVets {
76 include_all_information: self.include_all_information,
77 }
78 }
79}
80
81impl Request for GetVets {
82 fn method(&self) -> Method {
83 Method::Get
84 }
85
86 fn path(&self) -> &'static str {
87 "/api/v1/get_vets"
88 }
89
90 fn parameters(&self) -> Vec<(String, String)> {
91 if self.include_all_information {
92 vec![("vetFlag".to_owned(), "true".to_owned())]
93 } else {
94 Vec::new()
95 }
96 }
97}
98
99#[derive(Clone, Debug, PartialEq, Eq)]
100pub struct GetImmunizationTypes {
102 species: SpeciesId,
103}
104
105impl GetImmunizationTypes {
106 pub const fn new(species: SpeciesId) -> Self {
108 Self { species }
109 }
110}
111
112impl Request for GetImmunizationTypes {
113 fn method(&self) -> Method {
114 Method::Get
115 }
116
117 fn path(&self) -> &'static str {
118 "/api/v1/get_immunization_types"
119 }
120
121 fn parameters(&self) -> Vec<(String, String)> {
122 vec![("species_id".to_owned(), self.species.to_string())]
123 }
124}
125
126#[derive(Clone, Debug, PartialEq, Eq)]
127pub struct GetAnimalImmunizations {
129 animal: AnimalId,
130}
131
132impl GetAnimalImmunizations {
133 pub const fn new(animal: AnimalId) -> Self {
135 Self { animal }
136 }
137}
138
139impl Request for GetAnimalImmunizations {
140 fn method(&self) -> Method {
141 Method::Get
142 }
143
144 fn path(&self) -> &'static str {
145 "/api/v1/get_animal_immunizations"
146 }
147
148 fn parameters(&self) -> Vec<(String, String)> {
149 vec![("animal_id".to_owned(), self.animal.to_string())]
150 }
151}