Skip to main content

nea_rs/
api.rs

1//! @generated by satay. Do not edit by hand.
2
3use super::{
4    AirTemperatureInput, AirTemperatureOperationResponse, FourDayOutlookInput,
5    FourDayOutlookOperationResponse, NeaWeatherSubApi, Pm25Input, Pm25OperationResponse, PsiInput,
6    PsiOperationResponse, RainfallInput, RainfallOperationResponse, RelativeHumidityInput,
7    RelativeHumidityOperationResponse, TwentyFourHrForecastInput,
8    TwentyFourHrForecastOperationResponse, TwoHrForecastInput, TwoHrForecastOperationResponse,
9    UvInput, UvOperationResponse, WeatherSubApiInput, WeatherSubApiOperationResponse,
10    WindDirectionInput, WindDirectionOperationResponse, WindSpeedInput, WindSpeedOperationResponse,
11    air_temperature_parts, decode_air_temperature_response, decode_four_day_outlook_response,
12    decode_pm25_response, decode_psi_response, decode_rainfall_response,
13    decode_relative_humidity_response, decode_twenty_four_hr_forecast_response,
14    decode_two_hr_forecast_response, decode_uv_response, decode_weather_sub_api_response,
15    decode_wind_direction_response, decode_wind_speed_response, four_day_outlook_parts, pm25_parts,
16    psi_parts, rainfall_parts, relative_humidity_parts, twenty_four_hr_forecast_parts,
17    two_hr_forecast_parts, uv_parts, weather_sub_api_parts, wind_direction_parts, wind_speed_parts,
18};
19#[derive(Debug, Clone)]
20pub struct Api {
21    base_url: String,
22    x_api_key: Option<String>,
23}
24impl Default for Api {
25    fn default() -> Self {
26        Self::new()
27    }
28}
29impl Api {
30    pub fn new() -> Self {
31        Self {
32            base_url: super::SERVER_URL.to_owned(),
33            x_api_key: None,
34        }
35    }
36    pub fn base_url(mut self, base_url: impl Into<String>) -> Self {
37        self.base_url = base_url.into();
38        self
39    }
40    pub fn x_api_key(mut self, value: impl Into<String>) -> Self {
41        self.x_api_key = Some(value.into());
42        self
43    }
44    /// <https://api-open.data.gov.sg/v2/real-time/api/psi>
45    ///
46    /// - Readings are provided for each major region in Singapore
47    ///
48    /// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
49    ///
50    /// - example: `?date=2024-07-16`
51    ///
52    /// - If `date` is not provided in query parameter, API will return the latest reading
53    ///
54    /// - The `region_metadata` field in the response provides longitude/latitude information for the regions. You can use that to place the readings on a map.
55    ///
56    /// - Unit of measure for readings is `PSI Value`
57    pub fn psi(&self) -> PsiAction<'_> {
58        PsiAction {
59            api: self,
60            input: PsiInput::new(),
61        }
62    }
63    /// <https://api-open.data.gov.sg/v2/real-time/api/pm25>
64    ///
65    /// - Readings are provided for each major region in Singapore
66    ///
67    /// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
68    ///
69    /// - example: `?date=2024-07-16`
70    ///
71    /// - If `date` is not provided in query parameter, API will return the latest reading
72    ///
73    /// - The `region_metadata` field in the response provides longitude/latitude information for the regions. You can use that to place the readings on a map.
74    ///
75    /// - Unit of measure for readings is `µg/m3`.
76    pub fn pm25(&self) -> Pm25Action<'_> {
77        Pm25Action {
78            api: self,
79            input: Pm25Input::new(),
80        }
81    }
82    /// <https://api-open.data.gov.sg/v2/real-time/api/air-temperature>
83    ///
84    /// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
85    ///
86    /// - example: `?date=2024-07-16`
87    ///
88    /// - If `date` is not provided in query parameter, API will return the latest reading
89    ///
90    /// - Unit of measure for readings is `°C`
91    pub fn air_temperature(&self) -> AirTemperatureAction<'_> {
92        AirTemperatureAction {
93            api: self,
94            input: AirTemperatureInput::new(),
95        }
96    }
97    /// <https://api-open.data.gov.sg/v2/real-time/api/relative-humidity>
98    ///
99    /// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
100    ///
101    /// - example: `?date=2024-07-16`
102    ///
103    /// - If `date` is not provided in query parameter, API will return the latest reading
104    ///
105    /// - Unit of measure for readings is `%`
106    pub fn relative_humidity(&self) -> RelativeHumidityAction<'_> {
107        RelativeHumidityAction {
108            api: self,
109            input: RelativeHumidityInput::new(),
110        }
111    }
112    /// <https://api-open.data.gov.sg/v2/real-time/api/wind-speed>
113    ///
114    /// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
115    ///
116    /// - example: `?date=2024-07-16`
117    ///
118    /// - If `date` is not provided in query parameter, API will return the latest reading
119    ///
120    /// - Unit of measure for readings is `Knots`
121    pub fn wind_speed(&self) -> WindSpeedAction<'_> {
122        WindSpeedAction {
123            api: self,
124            input: WindSpeedInput::new(),
125        }
126    }
127    /// <https://api-open.data.gov.sg/v2/real-time/api/wind-direction>
128    ///
129    /// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
130    ///
131    /// - example: `?date=2024-07-16`
132    ///
133    /// - If `date` is not provided in query parameter, API will return the latest reading
134    ///
135    /// - Unit of measure for readings is `°`
136    pub fn wind_direction(&self) -> WindDirectionAction<'_> {
137        WindDirectionAction {
138            api: self,
139            input: WindDirectionInput::new(),
140        }
141    }
142    /// <https://api-open.data.gov.sg/v2/real-time/api/rainfall>
143    ///
144    /// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
145    ///
146    /// - example: `?date=2024-07-16`
147    ///
148    /// - If `date` is not provided in query parameter, API will return the latest reading
149    ///
150    /// - Unit of measure for readings is `mm`
151    pub fn rainfall(&self) -> RainfallAction<'_> {
152        RainfallAction {
153            api: self,
154            input: RainfallInput::new(),
155        }
156    }
157    /// <https://api-open.data.gov.sg/v2/real-time/api/two-hr-forecast>
158    ///
159    /// - Forecasts are given for multiple areas in Singapore
160    ///
161    /// - Filter for specific date or date-time by providing `date` in query parameter (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS).
162    ///
163    /// - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`
164    ///
165    /// - Forecasts are valid for two hours, for example, the validity period of the forecast at 1pm is 1pm to 3pm
166    ///
167    /// - If `date` is not provided in query parameter, API will return the latest reading
168    pub fn two_hr_forecast(&self) -> TwoHrForecastAction<'_> {
169        TwoHrForecastAction {
170            api: self,
171            input: TwoHrForecastInput::new(),
172        }
173    }
174    /// <https://api-open.data.gov.sg/v2/real-time/api/twenty-four-hr-forecast>
175    ///
176    /// - Updated multiple times throughout the day
177    ///
178    /// - Filter for specific date or date-time by providing `date` in query parameter (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS).
179    ///
180    /// - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`
181    ///
182    /// - Forecasts are valid for twenty four hours, for example, the validity period of the forecast at 1st Jan 1pm is from 1st Jan 1pm to 2nd Jan 1pm
183    ///
184    /// - If `date` is not provided in query parameter, API will return the latest reading
185    pub fn twenty_four_hr_forecast(&self) -> TwentyFourHrForecastAction<'_> {
186        TwentyFourHrForecastAction {
187            api: self,
188            input: TwentyFourHrForecastInput::new(),
189        }
190    }
191    /// <https://api-open.data.gov.sg/v2/real-time/api/four-day-outlook>
192    ///
193    /// - The forecast is for the next 4 days.
194    ///
195    /// - Filter for specific date or date-time by providing `date` in query parameter (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS).
196    ///
197    /// - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`
198    ///
199    /// - Forecasts are valid for four days, for example, the validity period of the forecast at 1st Jan 1pm is from 1st Jan 1pm to 5th Jan 1pm
200    ///
201    /// - If `date` is not provided in query parameter, API will return the latest reading
202    pub fn four_day_outlook(&self) -> FourDayOutlookAction<'_> {
203        FourDayOutlookAction {
204            api: self,
205            input: FourDayOutlookInput::new(),
206        }
207    }
208    /// <https://api-open.data.gov.sg/v2/real-time/api/uv>
209    ///
210    /// - Updated between 7 AM and 7 PM everyday
211    ///
212    /// - The UV index value is averaged over the preceding hour
213    ///
214    /// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
215    ///
216    /// - example: `?date=2024-07-16`
217    ///
218    /// - If `date` is not provided in query parameter, API will return the latest reading
219    ///
220    /// - Unit of measure for readings is `Ultraviolet Index`
221    pub fn uv(&self) -> UvAction<'_> {
222        UvAction {
223            api: self,
224            input: UvInput::new(),
225        }
226    }
227    /// Unified weather sub-API endpoint.
228    ///
229    /// - `?api=lightning` — Cloud-to-ground and cloud-to-cloud lightning strikes. Updated every ~2–3 minutes.
230    ///
231    /// - `?api=wbgt` — Wet Bulb Globe Temperature heat stress readings. Updated every 15 minutes.
232    ///
233    /// <https://api-open.data.gov.sg/v2/real-time/api/weather?api=lightning>
234    ///
235    /// - Updated multiple times throughout the day
236    ///
237    /// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
238    ///
239    /// - example: `?date=2025-01-16`
240    ///
241    /// - If `date` is not provided in query parameter, API will return the latest lightning observation
242    pub fn weather_sub_api(&self, api: NeaWeatherSubApi) -> WeatherSubApiAction<'_> {
243        WeatherSubApiAction {
244            api: self,
245            input: WeatherSubApiInput::new(api),
246        }
247    }
248    fn apply<B>(
249        &self,
250        parts: &mut satay_runtime::RequestParts<B>,
251    ) -> Result<(), satay_runtime::Error> {
252        if let Some(value) = &self.x_api_key {
253            satay_runtime::insert_header(&mut parts.headers, "x-api-key", value)?;
254        }
255        if self.base_url.is_empty() {
256            return Ok(());
257        }
258        let path_and_query = parts.uri.as_str();
259        let base_url = self.base_url.trim_end_matches('/');
260        let separator = if path_and_query.starts_with('/') {
261            ""
262        } else {
263            "/"
264        };
265        parts.uri = format!("{base_url}{separator}{path_and_query}");
266        Ok(())
267    }
268}
269/// <https://api-open.data.gov.sg/v2/real-time/api/psi>
270///
271/// - Readings are provided for each major region in Singapore
272///
273/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
274///
275/// - example: `?date=2024-07-16`
276///
277/// - If `date` is not provided in query parameter, API will return the latest reading
278///
279/// - The `region_metadata` field in the response provides longitude/latitude information for the regions. You can use that to place the readings on a map.
280///
281/// - Unit of measure for readings is `PSI Value`
282#[derive(Debug, Clone)]
283pub struct PsiAction<'a> {
284    api: &'a Api,
285    input: PsiInput,
286}
287impl PsiAction<'_> {
288    pub fn date(mut self, date: satay_runtime::Date) -> Self {
289        self.input = self.input.date(date);
290        self
291    }
292    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
293        self.input = self.input.pagination_token(pagination_token);
294        self
295    }
296    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
297        self.input = self.input.x_api_key(x_api_key);
298        self
299    }
300    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
301        let api = self.api;
302        let mut parts = psi_parts(self.input)?;
303        api.apply(&mut parts)?;
304        satay_runtime::into_empty_request(parts)
305    }
306    pub fn decode<B: AsRef<[u8]>>(
307        response: satay_runtime::ResponseParts<B>,
308    ) -> Result<PsiOperationResponse, satay_runtime::Error> {
309        decode_psi_response(response)
310    }
311}
312impl satay_runtime::Action for PsiAction<'_> {
313    type Response = PsiOperationResponse;
314    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
315        self.request()
316    }
317    fn decode<B: AsRef<[u8]>>(
318        response: satay_runtime::ResponseParts<B>,
319    ) -> Result<Self::Response, satay_runtime::Error> {
320        Self::decode(response)
321    }
322}
323/// <https://api-open.data.gov.sg/v2/real-time/api/pm25>
324///
325/// - Readings are provided for each major region in Singapore
326///
327/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
328///
329/// - example: `?date=2024-07-16`
330///
331/// - If `date` is not provided in query parameter, API will return the latest reading
332///
333/// - The `region_metadata` field in the response provides longitude/latitude information for the regions. You can use that to place the readings on a map.
334///
335/// - Unit of measure for readings is `µg/m3`.
336#[derive(Debug, Clone)]
337pub struct Pm25Action<'a> {
338    api: &'a Api,
339    input: Pm25Input,
340}
341impl Pm25Action<'_> {
342    pub fn date(mut self, date: satay_runtime::Date) -> Self {
343        self.input = self.input.date(date);
344        self
345    }
346    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
347        self.input = self.input.pagination_token(pagination_token);
348        self
349    }
350    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
351        self.input = self.input.x_api_key(x_api_key);
352        self
353    }
354    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
355        let api = self.api;
356        let mut parts = pm25_parts(self.input)?;
357        api.apply(&mut parts)?;
358        satay_runtime::into_empty_request(parts)
359    }
360    pub fn decode<B: AsRef<[u8]>>(
361        response: satay_runtime::ResponseParts<B>,
362    ) -> Result<Pm25OperationResponse, satay_runtime::Error> {
363        decode_pm25_response(response)
364    }
365}
366impl satay_runtime::Action for Pm25Action<'_> {
367    type Response = Pm25OperationResponse;
368    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
369        self.request()
370    }
371    fn decode<B: AsRef<[u8]>>(
372        response: satay_runtime::ResponseParts<B>,
373    ) -> Result<Self::Response, satay_runtime::Error> {
374        Self::decode(response)
375    }
376}
377/// <https://api-open.data.gov.sg/v2/real-time/api/air-temperature>
378///
379/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
380///
381/// - example: `?date=2024-07-16`
382///
383/// - If `date` is not provided in query parameter, API will return the latest reading
384///
385/// - Unit of measure for readings is `°C`
386#[derive(Debug, Clone)]
387pub struct AirTemperatureAction<'a> {
388    api: &'a Api,
389    input: AirTemperatureInput,
390}
391impl AirTemperatureAction<'_> {
392    pub fn date(mut self, date: satay_runtime::Date) -> Self {
393        self.input = self.input.date(date);
394        self
395    }
396    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
397        self.input = self.input.pagination_token(pagination_token);
398        self
399    }
400    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
401        self.input = self.input.x_api_key(x_api_key);
402        self
403    }
404    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
405        let api = self.api;
406        let mut parts = air_temperature_parts(self.input)?;
407        api.apply(&mut parts)?;
408        satay_runtime::into_empty_request(parts)
409    }
410    pub fn decode<B: AsRef<[u8]>>(
411        response: satay_runtime::ResponseParts<B>,
412    ) -> Result<AirTemperatureOperationResponse, satay_runtime::Error> {
413        decode_air_temperature_response(response)
414    }
415}
416impl satay_runtime::Action for AirTemperatureAction<'_> {
417    type Response = AirTemperatureOperationResponse;
418    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
419        self.request()
420    }
421    fn decode<B: AsRef<[u8]>>(
422        response: satay_runtime::ResponseParts<B>,
423    ) -> Result<Self::Response, satay_runtime::Error> {
424        Self::decode(response)
425    }
426}
427/// <https://api-open.data.gov.sg/v2/real-time/api/relative-humidity>
428///
429/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
430///
431/// - example: `?date=2024-07-16`
432///
433/// - If `date` is not provided in query parameter, API will return the latest reading
434///
435/// - Unit of measure for readings is `%`
436#[derive(Debug, Clone)]
437pub struct RelativeHumidityAction<'a> {
438    api: &'a Api,
439    input: RelativeHumidityInput,
440}
441impl RelativeHumidityAction<'_> {
442    pub fn date(mut self, date: satay_runtime::Date) -> Self {
443        self.input = self.input.date(date);
444        self
445    }
446    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
447        self.input = self.input.pagination_token(pagination_token);
448        self
449    }
450    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
451        self.input = self.input.x_api_key(x_api_key);
452        self
453    }
454    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
455        let api = self.api;
456        let mut parts = relative_humidity_parts(self.input)?;
457        api.apply(&mut parts)?;
458        satay_runtime::into_empty_request(parts)
459    }
460    pub fn decode<B: AsRef<[u8]>>(
461        response: satay_runtime::ResponseParts<B>,
462    ) -> Result<RelativeHumidityOperationResponse, satay_runtime::Error> {
463        decode_relative_humidity_response(response)
464    }
465}
466impl satay_runtime::Action for RelativeHumidityAction<'_> {
467    type Response = RelativeHumidityOperationResponse;
468    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
469        self.request()
470    }
471    fn decode<B: AsRef<[u8]>>(
472        response: satay_runtime::ResponseParts<B>,
473    ) -> Result<Self::Response, satay_runtime::Error> {
474        Self::decode(response)
475    }
476}
477/// <https://api-open.data.gov.sg/v2/real-time/api/wind-speed>
478///
479/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
480///
481/// - example: `?date=2024-07-16`
482///
483/// - If `date` is not provided in query parameter, API will return the latest reading
484///
485/// - Unit of measure for readings is `Knots`
486#[derive(Debug, Clone)]
487pub struct WindSpeedAction<'a> {
488    api: &'a Api,
489    input: WindSpeedInput,
490}
491impl WindSpeedAction<'_> {
492    pub fn date(mut self, date: satay_runtime::Date) -> Self {
493        self.input = self.input.date(date);
494        self
495    }
496    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
497        self.input = self.input.pagination_token(pagination_token);
498        self
499    }
500    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
501        self.input = self.input.x_api_key(x_api_key);
502        self
503    }
504    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
505        let api = self.api;
506        let mut parts = wind_speed_parts(self.input)?;
507        api.apply(&mut parts)?;
508        satay_runtime::into_empty_request(parts)
509    }
510    pub fn decode<B: AsRef<[u8]>>(
511        response: satay_runtime::ResponseParts<B>,
512    ) -> Result<WindSpeedOperationResponse, satay_runtime::Error> {
513        decode_wind_speed_response(response)
514    }
515}
516impl satay_runtime::Action for WindSpeedAction<'_> {
517    type Response = WindSpeedOperationResponse;
518    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
519        self.request()
520    }
521    fn decode<B: AsRef<[u8]>>(
522        response: satay_runtime::ResponseParts<B>,
523    ) -> Result<Self::Response, satay_runtime::Error> {
524        Self::decode(response)
525    }
526}
527/// <https://api-open.data.gov.sg/v2/real-time/api/wind-direction>
528///
529/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
530///
531/// - example: `?date=2024-07-16`
532///
533/// - If `date` is not provided in query parameter, API will return the latest reading
534///
535/// - Unit of measure for readings is `°`
536#[derive(Debug, Clone)]
537pub struct WindDirectionAction<'a> {
538    api: &'a Api,
539    input: WindDirectionInput,
540}
541impl WindDirectionAction<'_> {
542    pub fn date(mut self, date: satay_runtime::Date) -> Self {
543        self.input = self.input.date(date);
544        self
545    }
546    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
547        self.input = self.input.pagination_token(pagination_token);
548        self
549    }
550    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
551        self.input = self.input.x_api_key(x_api_key);
552        self
553    }
554    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
555        let api = self.api;
556        let mut parts = wind_direction_parts(self.input)?;
557        api.apply(&mut parts)?;
558        satay_runtime::into_empty_request(parts)
559    }
560    pub fn decode<B: AsRef<[u8]>>(
561        response: satay_runtime::ResponseParts<B>,
562    ) -> Result<WindDirectionOperationResponse, satay_runtime::Error> {
563        decode_wind_direction_response(response)
564    }
565}
566impl satay_runtime::Action for WindDirectionAction<'_> {
567    type Response = WindDirectionOperationResponse;
568    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
569        self.request()
570    }
571    fn decode<B: AsRef<[u8]>>(
572        response: satay_runtime::ResponseParts<B>,
573    ) -> Result<Self::Response, satay_runtime::Error> {
574        Self::decode(response)
575    }
576}
577/// <https://api-open.data.gov.sg/v2/real-time/api/rainfall>
578///
579/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
580///
581/// - example: `?date=2024-07-16`
582///
583/// - If `date` is not provided in query parameter, API will return the latest reading
584///
585/// - Unit of measure for readings is `mm`
586#[derive(Debug, Clone)]
587pub struct RainfallAction<'a> {
588    api: &'a Api,
589    input: RainfallInput,
590}
591impl RainfallAction<'_> {
592    pub fn date(mut self, date: satay_runtime::Date) -> Self {
593        self.input = self.input.date(date);
594        self
595    }
596    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
597        self.input = self.input.pagination_token(pagination_token);
598        self
599    }
600    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
601        self.input = self.input.x_api_key(x_api_key);
602        self
603    }
604    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
605        let api = self.api;
606        let mut parts = rainfall_parts(self.input)?;
607        api.apply(&mut parts)?;
608        satay_runtime::into_empty_request(parts)
609    }
610    pub fn decode<B: AsRef<[u8]>>(
611        response: satay_runtime::ResponseParts<B>,
612    ) -> Result<RainfallOperationResponse, satay_runtime::Error> {
613        decode_rainfall_response(response)
614    }
615}
616impl satay_runtime::Action for RainfallAction<'_> {
617    type Response = RainfallOperationResponse;
618    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
619        self.request()
620    }
621    fn decode<B: AsRef<[u8]>>(
622        response: satay_runtime::ResponseParts<B>,
623    ) -> Result<Self::Response, satay_runtime::Error> {
624        Self::decode(response)
625    }
626}
627/// <https://api-open.data.gov.sg/v2/real-time/api/two-hr-forecast>
628///
629/// - Forecasts are given for multiple areas in Singapore
630///
631/// - Filter for specific date or date-time by providing `date` in query parameter (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS).
632///
633/// - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`
634///
635/// - Forecasts are valid for two hours, for example, the validity period of the forecast at 1pm is 1pm to 3pm
636///
637/// - If `date` is not provided in query parameter, API will return the latest reading
638#[derive(Debug, Clone)]
639pub struct TwoHrForecastAction<'a> {
640    api: &'a Api,
641    input: TwoHrForecastInput,
642}
643impl TwoHrForecastAction<'_> {
644    pub fn date(mut self, date: satay_runtime::Date) -> Self {
645        self.input = self.input.date(date);
646        self
647    }
648    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
649        self.input = self.input.pagination_token(pagination_token);
650        self
651    }
652    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
653        self.input = self.input.x_api_key(x_api_key);
654        self
655    }
656    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
657        let api = self.api;
658        let mut parts = two_hr_forecast_parts(self.input)?;
659        api.apply(&mut parts)?;
660        satay_runtime::into_empty_request(parts)
661    }
662    pub fn decode<B: AsRef<[u8]>>(
663        response: satay_runtime::ResponseParts<B>,
664    ) -> Result<TwoHrForecastOperationResponse, satay_runtime::Error> {
665        decode_two_hr_forecast_response(response)
666    }
667}
668impl satay_runtime::Action for TwoHrForecastAction<'_> {
669    type Response = TwoHrForecastOperationResponse;
670    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
671        self.request()
672    }
673    fn decode<B: AsRef<[u8]>>(
674        response: satay_runtime::ResponseParts<B>,
675    ) -> Result<Self::Response, satay_runtime::Error> {
676        Self::decode(response)
677    }
678}
679/// <https://api-open.data.gov.sg/v2/real-time/api/twenty-four-hr-forecast>
680///
681/// - Updated multiple times throughout the day
682///
683/// - Filter for specific date or date-time by providing `date` in query parameter (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS).
684///
685/// - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`
686///
687/// - Forecasts are valid for twenty four hours, for example, the validity period of the forecast at 1st Jan 1pm is from 1st Jan 1pm to 2nd Jan 1pm
688///
689/// - If `date` is not provided in query parameter, API will return the latest reading
690#[derive(Debug, Clone)]
691pub struct TwentyFourHrForecastAction<'a> {
692    api: &'a Api,
693    input: TwentyFourHrForecastInput,
694}
695impl TwentyFourHrForecastAction<'_> {
696    pub fn date(mut self, date: satay_runtime::Date) -> Self {
697        self.input = self.input.date(date);
698        self
699    }
700    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
701        self.input = self.input.pagination_token(pagination_token);
702        self
703    }
704    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
705        self.input = self.input.x_api_key(x_api_key);
706        self
707    }
708    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
709        let api = self.api;
710        let mut parts = twenty_four_hr_forecast_parts(self.input)?;
711        api.apply(&mut parts)?;
712        satay_runtime::into_empty_request(parts)
713    }
714    pub fn decode<B: AsRef<[u8]>>(
715        response: satay_runtime::ResponseParts<B>,
716    ) -> Result<TwentyFourHrForecastOperationResponse, satay_runtime::Error> {
717        decode_twenty_four_hr_forecast_response(response)
718    }
719}
720impl satay_runtime::Action for TwentyFourHrForecastAction<'_> {
721    type Response = TwentyFourHrForecastOperationResponse;
722    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
723        self.request()
724    }
725    fn decode<B: AsRef<[u8]>>(
726        response: satay_runtime::ResponseParts<B>,
727    ) -> Result<Self::Response, satay_runtime::Error> {
728        Self::decode(response)
729    }
730}
731/// <https://api-open.data.gov.sg/v2/real-time/api/four-day-outlook>
732///
733/// - The forecast is for the next 4 days.
734///
735/// - Filter for specific date or date-time by providing `date` in query parameter (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS).
736///
737/// - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`
738///
739/// - Forecasts are valid for four days, for example, the validity period of the forecast at 1st Jan 1pm is from 1st Jan 1pm to 5th Jan 1pm
740///
741/// - If `date` is not provided in query parameter, API will return the latest reading
742#[derive(Debug, Clone)]
743pub struct FourDayOutlookAction<'a> {
744    api: &'a Api,
745    input: FourDayOutlookInput,
746}
747impl FourDayOutlookAction<'_> {
748    pub fn date(mut self, date: satay_runtime::Date) -> Self {
749        self.input = self.input.date(date);
750        self
751    }
752    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
753        self.input = self.input.pagination_token(pagination_token);
754        self
755    }
756    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
757        self.input = self.input.x_api_key(x_api_key);
758        self
759    }
760    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
761        let api = self.api;
762        let mut parts = four_day_outlook_parts(self.input)?;
763        api.apply(&mut parts)?;
764        satay_runtime::into_empty_request(parts)
765    }
766    pub fn decode<B: AsRef<[u8]>>(
767        response: satay_runtime::ResponseParts<B>,
768    ) -> Result<FourDayOutlookOperationResponse, satay_runtime::Error> {
769        decode_four_day_outlook_response(response)
770    }
771}
772impl satay_runtime::Action for FourDayOutlookAction<'_> {
773    type Response = FourDayOutlookOperationResponse;
774    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
775        self.request()
776    }
777    fn decode<B: AsRef<[u8]>>(
778        response: satay_runtime::ResponseParts<B>,
779    ) -> Result<Self::Response, satay_runtime::Error> {
780        Self::decode(response)
781    }
782}
783/// <https://api-open.data.gov.sg/v2/real-time/api/uv>
784///
785/// - Updated between 7 AM and 7 PM everyday
786///
787/// - The UV index value is averaged over the preceding hour
788///
789/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
790///
791/// - example: `?date=2024-07-16`
792///
793/// - If `date` is not provided in query parameter, API will return the latest reading
794///
795/// - Unit of measure for readings is `Ultraviolet Index`
796#[derive(Debug, Clone)]
797pub struct UvAction<'a> {
798    api: &'a Api,
799    input: UvInput,
800}
801impl UvAction<'_> {
802    pub fn date(mut self, date: satay_runtime::Date) -> Self {
803        self.input = self.input.date(date);
804        self
805    }
806    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
807        self.input = self.input.pagination_token(pagination_token);
808        self
809    }
810    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
811        self.input = self.input.x_api_key(x_api_key);
812        self
813    }
814    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
815        let api = self.api;
816        let mut parts = uv_parts(self.input)?;
817        api.apply(&mut parts)?;
818        satay_runtime::into_empty_request(parts)
819    }
820    pub fn decode<B: AsRef<[u8]>>(
821        response: satay_runtime::ResponseParts<B>,
822    ) -> Result<UvOperationResponse, satay_runtime::Error> {
823        decode_uv_response(response)
824    }
825}
826impl satay_runtime::Action for UvAction<'_> {
827    type Response = UvOperationResponse;
828    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
829        self.request()
830    }
831    fn decode<B: AsRef<[u8]>>(
832        response: satay_runtime::ResponseParts<B>,
833    ) -> Result<Self::Response, satay_runtime::Error> {
834        Self::decode(response)
835    }
836}
837/// Unified weather sub-API endpoint.
838///
839/// - `?api=lightning` — Cloud-to-ground and cloud-to-cloud lightning strikes. Updated every ~2–3 minutes.
840///
841/// - `?api=wbgt` — Wet Bulb Globe Temperature heat stress readings. Updated every 15 minutes.
842///
843/// <https://api-open.data.gov.sg/v2/real-time/api/weather?api=lightning>
844///
845/// - Updated multiple times throughout the day
846///
847/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
848///
849/// - example: `?date=2025-01-16`
850///
851/// - If `date` is not provided in query parameter, API will return the latest lightning observation
852#[derive(Debug, Clone)]
853pub struct WeatherSubApiAction<'a> {
854    api: &'a Api,
855    input: WeatherSubApiInput,
856}
857impl WeatherSubApiAction<'_> {
858    pub fn date(mut self, date: satay_runtime::Date) -> Self {
859        self.input = self.input.date(date);
860        self
861    }
862    pub fn pagination_token(mut self, pagination_token: impl Into<String>) -> Self {
863        self.input = self.input.pagination_token(pagination_token);
864        self
865    }
866    pub fn x_api_key(mut self, x_api_key: impl Into<String>) -> Self {
867        self.input = self.input.x_api_key(x_api_key);
868        self
869    }
870    pub fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
871        let api = self.api;
872        let mut parts = weather_sub_api_parts(self.input)?;
873        api.apply(&mut parts)?;
874        satay_runtime::into_empty_request(parts)
875    }
876    pub fn decode<B: AsRef<[u8]>>(
877        response: satay_runtime::ResponseParts<B>,
878    ) -> Result<WeatherSubApiOperationResponse, satay_runtime::Error> {
879        decode_weather_sub_api_response(response)
880    }
881}
882impl satay_runtime::Action for WeatherSubApiAction<'_> {
883    type Response = WeatherSubApiOperationResponse;
884    fn request(self) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
885        self.request()
886    }
887    fn decode<B: AsRef<[u8]>>(
888        response: satay_runtime::ResponseParts<B>,
889    ) -> Result<Self::Response, satay_runtime::Error> {
890        Self::decode(response)
891    }
892}