Skip to main content

lta/
api.rs

1// @generated by satay. Do not edit by hand.
2#![allow(
3    clippy::doc_markdown,
4    clippy::missing_errors_doc,
5    clippy::must_use_candidate,
6    clippy::needless_pass_by_value,
7    clippy::return_self_not_must_use,
8    clippy::single_match_else
9)]
10
11use super::get_bus_arrival::{decode_get_bus_arrival_response, get_bus_arrival_parts};
12use super::get_bus_stops::{decode_get_bus_stops_response, get_bus_stops_parts};
13use super::get_facilities_maintenance::{
14    decode_get_facilities_maintenance_response, get_facilities_maintenance_parts,
15};
16use super::get_road_openings::{decode_get_road_openings_response, get_road_openings_parts};
17use super::get_road_works::{decode_get_road_works_response, get_road_works_parts};
18use super::get_taxi_availability::{
19    decode_get_taxi_availability_response, get_taxi_availability_parts,
20};
21use super::get_traffic_flow::{decode_get_traffic_flow_response, get_traffic_flow_parts};
22use super::get_traffic_images::{decode_get_traffic_images_response, get_traffic_images_parts};
23use super::get_traffic_incidents::{
24    decode_get_traffic_incidents_response, get_traffic_incidents_parts,
25};
26use super::get_traffic_speed_bands::{
27    decode_get_traffic_speed_bands_response, get_traffic_speed_bands_parts,
28};
29use super::{
30    BusServiceNumber, GetBusArrivalInput, GetBusArrivalResponse, GetBusStopsInput,
31    GetBusStopsResponse, GetFacilitiesMaintenanceInput, GetFacilitiesMaintenanceResponse,
32    GetRoadOpeningsInput, GetRoadOpeningsResponse, GetRoadWorksInput, GetRoadWorksResponse,
33    GetTaxiAvailabilityInput, GetTaxiAvailabilityResponse, GetTrafficFlowInput,
34    GetTrafficFlowResponse, GetTrafficImagesInput, GetTrafficImagesResponse,
35    GetTrafficIncidentsInput, GetTrafficIncidentsResponse, GetTrafficSpeedBandsInput,
36    GetTrafficSpeedBandsResponse, StationCode,
37};
38use crate::bus;
39use crate::facility;
40use crate::taxi;
41use crate::traffic;
42#[derive(Debug, Clone)]
43pub struct Api {
44    base_url: String,
45    account_key: Option<String>,
46}
47impl Default for Api {
48    fn default() -> Self {
49        Self::new()
50    }
51}
52impl Api {
53    pub fn new() -> Self {
54        Self {
55            base_url: super::SERVER_URL.to_owned(),
56            account_key: None,
57        }
58    }
59    pub fn base_url(mut self, base_url: impl Into<String>) -> Self {
60        self.base_url = base_url.into();
61        self
62    }
63    pub fn account_key(mut self, value: impl Into<String>) -> Self {
64        self.account_key = Some(value.into());
65        self
66    }
67    /// Access operations tagged `bus`.
68    pub fn bus(&self) -> bus::Api<'_> {
69        bus::Api { api: self }
70    }
71    /// Access operations tagged `traffic`.
72    pub fn traffic(&self) -> traffic::Api<'_> {
73        traffic::Api { api: self }
74    }
75    /// Access operations tagged `taxi`.
76    pub fn taxi(&self) -> taxi::Api<'_> {
77        taxi::Api { api: self }
78    }
79    /// Access operations tagged `facility`.
80    pub fn facility(&self) -> facility::Api<'_> {
81        facility::Api { api: self }
82    }
83    fn apply<B>(
84        &self,
85        parts: &mut satay_runtime::RequestParts<B>,
86    ) -> Result<(), satay_runtime::Error> {
87        if let Some(value) = &self.account_key {
88            satay_runtime::insert_header(&mut parts.headers, "AccountKey", value)?;
89        }
90        if self.base_url.is_empty() {
91            return Ok(());
92        }
93        let path_and_query = parts.uri.as_str();
94        let base_url = self.base_url.trim_end_matches('/');
95        let separator = if path_and_query.starts_with('/') {
96            ""
97        } else {
98            "/"
99        };
100        parts.uri = format!("{base_url}{separator}{path_and_query}");
101        Ok(())
102    }
103}
104/// Returns real-time Bus Arrival information of Bus Services at a queried Bus Stop, including
105/// - Estimated Arrival Time
106/// - Estimated Current Location
107/// - Estimated Current Load.
108///
109/// **Update freq**: 20s
110///
111/// Use the chainable methods to configure optional request settings, then call [`Self::request`] or use a transport adapter.
112#[must_use = "configure this action and execute it or call `.request()`"]
113#[derive(Debug, Clone)]
114pub struct GetBusArrivalAction<'a> {
115    api: &'a Api,
116    input: GetBusArrivalInput,
117}
118impl<'a> GetBusArrivalAction<'a> {
119    pub(crate) fn new(api: &'a Api, bus_stop_code: u32) -> Self {
120        Self {
121            api,
122            input: GetBusArrivalInput::new(bus_stop_code),
123        }
124    }
125    /// Optional bus service number filter.
126    #[must_use = "builder methods return the configured action"]
127    pub fn service_no(mut self, service_no: BusServiceNumber) -> Self {
128        self.input = self.input.service_no(service_no);
129        self
130    }
131    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
132        let api = self.api;
133        let mut parts = get_bus_arrival_parts(self.input)?;
134        api.apply(&mut parts)?;
135        satay_runtime::into_empty_request(parts)
136    }
137    pub fn decode<B: AsRef<[u8]>>(
138        response: satay_runtime::ResponseParts<B>,
139    ) -> Result<GetBusArrivalResponse, satay_runtime::Error> {
140        decode_get_bus_arrival_response(response)
141    }
142}
143impl satay_runtime::Action for GetBusArrivalAction<'_> {
144    type Response = GetBusArrivalResponse;
145    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
146        self.request()
147    }
148    fn decode<B: AsRef<[u8]>>(
149        response: satay_runtime::ResponseParts<B>,
150    ) -> Result<Self::Response, satay_runtime::Error> {
151        Self::decode(response)
152    }
153}
154/// Returns incidents currently happening on the roads, such as Accidents, Vehicle Breakdowns, Road Blocks, Traffic Diversions etc.
155/// **Update freq**: 2 min
156///
157/// Use the chainable methods to configure optional request settings, then call [`Self::request`] or use a transport adapter.
158#[must_use = "configure this action and execute it or call `.request()`"]
159#[derive(Debug, Clone)]
160pub struct GetTrafficIncidentsAction<'a> {
161    api: &'a Api,
162    input: GetTrafficIncidentsInput,
163}
164impl<'a> GetTrafficIncidentsAction<'a> {
165    pub(crate) fn new(api: &'a Api) -> Self {
166        Self {
167            api,
168            input: GetTrafficIncidentsInput::new(),
169        }
170    }
171    /// Number of records to skip for pagination.
172    #[must_use = "builder methods return the configured action"]
173    pub fn skip(mut self, skip: u32) -> Self {
174        self.input = self.input.skip(skip);
175        self
176    }
177    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
178        let api = self.api;
179        let mut parts = get_traffic_incidents_parts(self.input)?;
180        api.apply(&mut parts)?;
181        satay_runtime::into_empty_request(parts)
182    }
183    pub fn decode<B: AsRef<[u8]>>(
184        response: satay_runtime::ResponseParts<B>,
185    ) -> Result<GetTrafficIncidentsResponse, satay_runtime::Error> {
186        decode_get_traffic_incidents_response(response)
187    }
188}
189impl satay_runtime::Action for GetTrafficIncidentsAction<'_> {
190    type Response = GetTrafficIncidentsResponse;
191    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
192        self.request()
193    }
194    fn decode<B: AsRef<[u8]>>(
195        response: satay_runtime::ResponseParts<B>,
196    ) -> Result<Self::Response, satay_runtime::Error> {
197        Self::decode(response)
198    }
199}
200/// Returns links to images from traffic cameras located around Singapore, together with each camera's location coordinates.
201/// **Update freq**: 20 sec
202///
203/// Use the chainable methods to configure optional request settings, then call [`Self::request`] or use a transport adapter.
204#[must_use = "configure this action and execute it or call `.request()`"]
205#[derive(Debug, Clone)]
206pub struct GetTrafficImagesAction<'a> {
207    api: &'a Api,
208    input: GetTrafficImagesInput,
209}
210impl<'a> GetTrafficImagesAction<'a> {
211    pub(crate) fn new(api: &'a Api) -> Self {
212        Self {
213            api,
214            input: GetTrafficImagesInput::new(),
215        }
216    }
217    /// Number of records to skip for pagination.
218    #[must_use = "builder methods return the configured action"]
219    pub fn skip(mut self, skip: u32) -> Self {
220        self.input = self.input.skip(skip);
221        self
222    }
223    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
224        let api = self.api;
225        let mut parts = get_traffic_images_parts(self.input)?;
226        api.apply(&mut parts)?;
227        satay_runtime::into_empty_request(parts)
228    }
229    pub fn decode<B: AsRef<[u8]>>(
230        response: satay_runtime::ResponseParts<B>,
231    ) -> Result<GetTrafficImagesResponse, satay_runtime::Error> {
232        decode_get_traffic_images_response(response)
233    }
234}
235impl satay_runtime::Action for GetTrafficImagesAction<'_> {
236    type Response = GetTrafficImagesResponse;
237    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
238        self.request()
239    }
240    fn decode<B: AsRef<[u8]>>(
241        response: satay_runtime::ResponseParts<B>,
242    ) -> Result<Self::Response, satay_runtime::Error> {
243        Self::decode(response)
244    }
245}
246/// Returns current traffic speeds on expressways and arterial roads, expressed in speed bands.
247///
248/// **Update freq**: 5 min
249///
250/// Use the chainable methods to configure optional request settings, then call [`Self::request`] or use a transport adapter.
251#[must_use = "configure this action and execute it or call `.request()`"]
252#[derive(Debug, Clone)]
253pub struct GetTrafficSpeedBandsAction<'a> {
254    api: &'a Api,
255    input: GetTrafficSpeedBandsInput,
256}
257impl<'a> GetTrafficSpeedBandsAction<'a> {
258    pub(crate) fn new(api: &'a Api) -> Self {
259        Self {
260            api,
261            input: GetTrafficSpeedBandsInput::new(),
262        }
263    }
264    /// Number of records to skip for pagination.
265    #[must_use = "builder methods return the configured action"]
266    pub fn skip(mut self, skip: u32) -> Self {
267        self.input = self.input.skip(skip);
268        self
269    }
270    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
271        let api = self.api;
272        let mut parts = get_traffic_speed_bands_parts(self.input)?;
273        api.apply(&mut parts)?;
274        satay_runtime::into_empty_request(parts)
275    }
276    pub fn decode<B: AsRef<[u8]>>(
277        response: satay_runtime::ResponseParts<B>,
278    ) -> Result<GetTrafficSpeedBandsResponse, satay_runtime::Error> {
279        decode_get_traffic_speed_bands_response(response)
280    }
281}
282impl satay_runtime::Action for GetTrafficSpeedBandsAction<'_> {
283    type Response = GetTrafficSpeedBandsResponse;
284    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
285        self.request()
286    }
287    fn decode<B: AsRef<[u8]>>(
288        response: satay_runtime::ResponseParts<B>,
289    ) -> Result<Self::Response, satay_runtime::Error> {
290        Self::decode(response)
291    }
292}
293/// Returns a link to a JSON file containing hourly average traffic flow, taken from a representative month of every quarter during 0700-0900 hours.
294/// **Update freq**: Quarterly
295///
296/// Call [`Self::request`] or use a transport adapter.
297#[must_use = "configure this action and execute it or call `.request()`"]
298#[derive(Debug, Clone)]
299pub struct GetTrafficFlowAction<'a> {
300    api: &'a Api,
301    input: GetTrafficFlowInput,
302}
303impl<'a> GetTrafficFlowAction<'a> {
304    pub(crate) fn new(api: &'a Api) -> Self {
305        Self {
306            api,
307            input: GetTrafficFlowInput::new(),
308        }
309    }
310    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
311        let api = self.api;
312        let mut parts = get_traffic_flow_parts(self.input)?;
313        api.apply(&mut parts)?;
314        satay_runtime::into_empty_request(parts)
315    }
316    pub fn decode<B: AsRef<[u8]>>(
317        response: satay_runtime::ResponseParts<B>,
318    ) -> Result<GetTrafficFlowResponse, satay_runtime::Error> {
319        decode_get_traffic_flow_response(response)
320    }
321}
322impl satay_runtime::Action for GetTrafficFlowAction<'_> {
323    type Response = GetTrafficFlowResponse;
324    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
325        self.request()
326    }
327    fn decode<B: AsRef<[u8]>>(
328        response: satay_runtime::ResponseParts<B>,
329    ) -> Result<Self::Response, satay_runtime::Error> {
330        Self::decode(response)
331    }
332}
333/// Returns road works currently in progress or planned, together with event details and the responsible agency.
334///
335/// **Update freq**: 24 hours – whenever there are updates
336///
337/// Use the chainable methods to configure optional request settings, then call [`Self::request`] or use a transport adapter.
338#[must_use = "configure this action and execute it or call `.request()`"]
339#[derive(Debug, Clone)]
340pub struct GetRoadWorksAction<'a> {
341    api: &'a Api,
342    input: GetRoadWorksInput,
343}
344impl<'a> GetRoadWorksAction<'a> {
345    pub(crate) fn new(api: &'a Api) -> Self {
346        Self {
347            api,
348            input: GetRoadWorksInput::new(),
349        }
350    }
351    /// Number of records to skip for pagination.
352    #[must_use = "builder methods return the configured action"]
353    pub fn skip(mut self, skip: u32) -> Self {
354        self.input = self.input.skip(skip);
355        self
356    }
357    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
358        let api = self.api;
359        let mut parts = get_road_works_parts(self.input)?;
360        api.apply(&mut parts)?;
361        satay_runtime::into_empty_request(parts)
362    }
363    pub fn decode<B: AsRef<[u8]>>(
364        response: satay_runtime::ResponseParts<B>,
365    ) -> Result<GetRoadWorksResponse, satay_runtime::Error> {
366        decode_get_road_works_response(response)
367    }
368}
369impl satay_runtime::Action for GetRoadWorksAction<'_> {
370    type Response = GetRoadWorksResponse;
371    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
372        self.request()
373    }
374    fn decode<B: AsRef<[u8]>>(
375        response: satay_runtime::ResponseParts<B>,
376    ) -> Result<Self::Response, satay_runtime::Error> {
377        Self::decode(response)
378    }
379}
380/// Returns all planned road openings, including the new road name and the responsible agency.
381/// **Update freq**: 24 hours – whenever there are updates
382///
383/// Use the chainable methods to configure optional request settings, then call [`Self::request`] or use a transport adapter.
384#[must_use = "configure this action and execute it or call `.request()`"]
385#[derive(Debug, Clone)]
386pub struct GetRoadOpeningsAction<'a> {
387    api: &'a Api,
388    input: GetRoadOpeningsInput,
389}
390impl<'a> GetRoadOpeningsAction<'a> {
391    pub(crate) fn new(api: &'a Api) -> Self {
392        Self {
393            api,
394            input: GetRoadOpeningsInput::new(),
395        }
396    }
397    /// Number of records to skip for pagination.
398    #[must_use = "builder methods return the configured action"]
399    pub fn skip(mut self, skip: u32) -> Self {
400        self.input = self.input.skip(skip);
401        self
402    }
403    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
404        let api = self.api;
405        let mut parts = get_road_openings_parts(self.input)?;
406        api.apply(&mut parts)?;
407        satay_runtime::into_empty_request(parts)
408    }
409    pub fn decode<B: AsRef<[u8]>>(
410        response: satay_runtime::ResponseParts<B>,
411    ) -> Result<GetRoadOpeningsResponse, satay_runtime::Error> {
412        decode_get_road_openings_response(response)
413    }
414}
415impl satay_runtime::Action for GetRoadOpeningsAction<'_> {
416    type Response = GetRoadOpeningsResponse;
417    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
418        self.request()
419    }
420    fn decode<B: AsRef<[u8]>>(
421        response: satay_runtime::ResponseParts<B>,
422    ) -> Result<Self::Response, satay_runtime::Error> {
423        Self::decode(response)
424    }
425}
426/// Returns detailed information for all bus stops currently being serviced by buses, including bus stop codes and location coordinates.
427///
428/// **Update freq**: Ad-Hoc
429///
430/// Use the chainable methods to configure optional request settings, then call [`Self::request`] or use a transport adapter.
431#[must_use = "configure this action and execute it or call `.request()`"]
432#[derive(Debug, Clone)]
433pub struct GetBusStopsAction<'a> {
434    api: &'a Api,
435    input: GetBusStopsInput,
436}
437impl<'a> GetBusStopsAction<'a> {
438    pub(crate) fn new(api: &'a Api) -> Self {
439        Self {
440            api,
441            input: GetBusStopsInput::new(),
442        }
443    }
444    /// Number of records to skip for pagination.
445    #[must_use = "builder methods return the configured action"]
446    pub fn skip(mut self, skip: u32) -> Self {
447        self.input = self.input.skip(skip);
448        self
449    }
450    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
451        let api = self.api;
452        let mut parts = get_bus_stops_parts(self.input)?;
453        api.apply(&mut parts)?;
454        satay_runtime::into_empty_request(parts)
455    }
456    pub fn decode<B: AsRef<[u8]>>(
457        response: satay_runtime::ResponseParts<B>,
458    ) -> Result<GetBusStopsResponse, satay_runtime::Error> {
459        decode_get_bus_stops_response(response)
460    }
461}
462impl satay_runtime::Action for GetBusStopsAction<'_> {
463    type Response = GetBusStopsResponse;
464    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
465        self.request()
466    }
467    fn decode<B: AsRef<[u8]>>(
468        response: satay_runtime::ResponseParts<B>,
469    ) -> Result<Self::Response, satay_runtime::Error> {
470        Self::decode(response)
471    }
472}
473/// Returns the coordinates of all taxis currently available for hire.
474///
475/// **Update freq**: 1 min
476///
477/// Use the chainable methods to configure optional request settings, then call [`Self::request`] or use a transport adapter.
478#[must_use = "configure this action and execute it or call `.request()`"]
479#[derive(Debug, Clone)]
480pub struct GetTaxiAvailabilityAction<'a> {
481    api: &'a Api,
482    input: GetTaxiAvailabilityInput,
483}
484impl<'a> GetTaxiAvailabilityAction<'a> {
485    pub(crate) fn new(api: &'a Api) -> Self {
486        Self {
487            api,
488            input: GetTaxiAvailabilityInput::new(),
489        }
490    }
491    /// Number of records to skip for pagination.
492    #[must_use = "builder methods return the configured action"]
493    pub fn skip(mut self, skip: u32) -> Self {
494        self.input = self.input.skip(skip);
495        self
496    }
497    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
498        let api = self.api;
499        let mut parts = get_taxi_availability_parts(self.input)?;
500        api.apply(&mut parts)?;
501        satay_runtime::into_empty_request(parts)
502    }
503    pub fn decode<B: AsRef<[u8]>>(
504        response: satay_runtime::ResponseParts<B>,
505    ) -> Result<GetTaxiAvailabilityResponse, satay_runtime::Error> {
506        decode_get_taxi_availability_response(response)
507    }
508}
509impl satay_runtime::Action for GetTaxiAvailabilityAction<'_> {
510    type Response = GetTaxiAvailabilityResponse;
511    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
512        self.request()
513    }
514    fn decode<B: AsRef<[u8]>>(
515        response: satay_runtime::ResponseParts<B>,
516    ) -> Result<Self::Response, satay_runtime::Error> {
517        Self::decode(response)
518    }
519}
520/// Returns links to facility maintenance data files for a queried MRT/LRT station. Each link points to a JSON file describing the maintenance works currently in progress at that station.
521///
522/// **Update freq**: Ad-Hoc
523///
524/// Call [`Self::request`] or use a transport adapter.
525#[must_use = "configure this action and execute it or call `.request()`"]
526#[derive(Debug, Clone)]
527pub struct GetFacilitiesMaintenanceAction<'a> {
528    api: &'a Api,
529    input: GetFacilitiesMaintenanceInput,
530}
531impl<'a> GetFacilitiesMaintenanceAction<'a> {
532    pub(crate) fn new(api: &'a Api, station_code: StationCode) -> Self {
533        Self {
534            api,
535            input: GetFacilitiesMaintenanceInput::new(station_code),
536        }
537    }
538    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
539        let api = self.api;
540        let mut parts = get_facilities_maintenance_parts(self.input)?;
541        api.apply(&mut parts)?;
542        satay_runtime::into_empty_request(parts)
543    }
544    pub fn decode<B: AsRef<[u8]>>(
545        response: satay_runtime::ResponseParts<B>,
546    ) -> Result<GetFacilitiesMaintenanceResponse, satay_runtime::Error> {
547        decode_get_facilities_maintenance_response(response)
548    }
549}
550impl satay_runtime::Action for GetFacilitiesMaintenanceAction<'_> {
551    type Response = GetFacilitiesMaintenanceResponse;
552    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
553        self.request()
554    }
555    fn decode<B: AsRef<[u8]>>(
556        response: satay_runtime::ResponseParts<B>,
557    ) -> Result<Self::Response, satay_runtime::Error> {
558        Self::decode(response)
559    }
560}