Skip to main content

gingr/endpoint/
reference_data.rs

1use super::{AnimalId, Method, Request, SpeciesId};
2
3#[derive(Clone, Debug, Default, PartialEq, Eq)]
4/// Request descriptor for Gingr location reference data used to scope resort operations.
5pub 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        /// Zero-parameter Gingr reference-data endpoint generated from a static API path.
25        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)]
48/// Request descriptor for Gingr veterinarian reference data observed by location and active flag.
49pub struct GetVets {
50    include_all_information: bool,
51}
52
53impl GetVets {
54    /// Starts a builder that makes each provider parameter explicit before request capture.
55    pub fn builder() -> GetVetsBuilder {
56        GetVetsBuilder::default()
57    }
58}
59
60#[derive(Clone, Debug, Default)]
61/// Builder for veterinarian lookup filters by provider location and active-only flag.
62pub struct GetVetsBuilder {
63    include_all_information: bool,
64}
65
66impl GetVetsBuilder {
67    /// Requests Gingr vet records with extended fields included.
68    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    /// Finalizes the provider request descriptor after required fields are present and wrappers have validated local invariants.
74    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)]
100/// Request descriptor for Gingr immunization/vaccine type reference data.
101pub struct GetImmunizationTypes {
102    species: SpeciesId,
103}
104
105impl GetImmunizationTypes {
106    /// Wraps an already-observed Gingr identifier without claiming anything beyond provider provenance.
107    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)]
127/// Request descriptor for Gingr animal immunization records; medical interpretation remains outside this boundary.
128pub struct GetAnimalImmunizations {
129    animal: AnimalId,
130}
131
132impl GetAnimalImmunizations {
133    /// Wraps an already-observed Gingr identifier without claiming anything beyond provider provenance.
134    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}