1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// @generated by satay. Do not edit by hand.
#![allow(
clippy::doc_markdown,
clippy::missing_errors_doc,
clippy::must_use_candidate,
clippy::needless_pass_by_value,
clippy::return_self_not_must_use,
clippy::single_match_else
)]
use super::{
Api as RootApi, FourDayOutlookAction, TwentyFourHrForecastAction, TwoHrForecastAction,
};
/// Area and regional weather forecasts from NEA MSS.
#[derive(Debug, Clone, Copy)]
pub struct Api<'a> {
pub(crate) api: &'a RootApi,
}
impl<'a> Api<'a> {
/// <https://api-open.data.gov.sg/v2/real-time/api/two-hr-forecast>
///
/// - Forecasts are given for multiple areas in Singapore
///
/// - Filter for specific date or date-time by providing `date` in query parameter (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS).
///
/// - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`
///
/// - Forecasts are valid for two hours, for example, the validity period of the forecast at 1pm is 1pm to 3pm
///
/// - If `date` is not provided in query parameter, API will return the latest reading
///
/// # Optional request settings
///
/// - [`date`](TwoHrForecastAction::date): SGT date for which to retrieve data (YYYY-MM-DD). Omit for latest.
/// - [`pagination_token`](TwoHrForecastAction::pagination_token): Pagination token for subsequent pages (only when date filter is used and more pages exist).
/// - [`x_api_key`](TwoHrForecastAction::x_api_key): Optional API key for higher rate limits.
///
/// # Example
///
/// ```rust,ignore
/// let request = api
/// .weather_forecast()
/// .two_hr_forecast()
/// .date(date)
/// .request()?;
/// ```
pub fn two_hr_forecast(&self) -> TwoHrForecastAction<'a> {
TwoHrForecastAction::new(self.api)
}
/// <https://api-open.data.gov.sg/v2/real-time/api/twenty-four-hr-forecast>
///
/// - Updated multiple times throughout the day
///
/// - Filter for specific date or date-time by providing `date` in query parameter (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS).
///
/// - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`
///
/// - 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
///
/// - If `date` is not provided in query parameter, API will return the latest reading
///
/// # Optional request settings
///
/// - [`date`](TwentyFourHrForecastAction::date): SGT date for which to retrieve data (YYYY-MM-DD). Omit for latest.
/// - [`pagination_token`](TwentyFourHrForecastAction::pagination_token): Pagination token for subsequent pages (only when date filter is used and more pages exist).
/// - [`x_api_key`](TwentyFourHrForecastAction::x_api_key): Optional API key for higher rate limits.
///
/// # Example
///
/// ```rust,ignore
/// let request = api
/// .weather_forecast()
/// .twenty_four_hr_forecast()
/// .date(date)
/// .request()?;
/// ```
pub fn twenty_four_hr_forecast(&self) -> TwentyFourHrForecastAction<'a> {
TwentyFourHrForecastAction::new(self.api)
}
/// <https://api-open.data.gov.sg/v2/real-time/api/four-day-outlook>
///
/// - The forecast is for the next 4 days.
///
/// - Filter for specific date or date-time by providing `date` in query parameter (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SS).
///
/// - example: `?date=2024-07-16` or `?date=2024-07-16T23:59:00`
///
/// - 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
///
/// - If `date` is not provided in query parameter, API will return the latest reading
///
/// # Optional request settings
///
/// - [`date`](FourDayOutlookAction::date): SGT date for which to retrieve data (YYYY-MM-DD). Omit for latest.
/// - [`pagination_token`](FourDayOutlookAction::pagination_token): Pagination token for subsequent pages (only when date filter is used and more pages exist).
/// - [`x_api_key`](FourDayOutlookAction::x_api_key): Optional API key for higher rate limits.
///
/// # Example
///
/// ```rust,ignore
/// let request = api
/// .weather_forecast()
/// .four_day_outlook()
/// .date(date)
/// .request()?;
/// ```
pub fn four_day_outlook(&self) -> FourDayOutlookAction<'a> {
FourDayOutlookAction::new(self.api)
}
}