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
// @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, Pm25Action, PsiAction};
/// PSI and PM2.5 readings by region. Updated every 15 minutes.
#[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/psi>
///
/// - Readings are provided for each major region in Singapore
///
/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
///
/// - example: `?date=2024-07-16`
///
/// - If `date` is not provided in query parameter, API will return the latest reading
///
/// - 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.
///
/// - Unit of measure for readings is `PSI Value`
///
/// # Optional request settings
///
/// - [`date`](PsiAction::date): SGT date for which to retrieve data (YYYY-MM-DD). Omit for latest.
/// - [`pagination_token`](PsiAction::pagination_token): Pagination token for subsequent pages (only when date filter is used and more pages exist).
/// - [`x_api_key`](PsiAction::x_api_key): Optional API key for higher rate limits.
///
/// # Example
///
/// ```rust,ignore
/// let request = api
/// .air_quality()
/// .psi()
/// .date(date)
/// .request()?;
/// ```
pub fn psi(&self) -> PsiAction<'a> {
PsiAction::new(self.api)
}
/// <https://api-open.data.gov.sg/v2/real-time/api/pm25>
///
/// - Readings are provided for each major region in Singapore
///
/// - Filter for a specific date by providing `date` in query parameter (YYYY-MM-DD).
///
/// - example: `?date=2024-07-16`
///
/// - If `date` is not provided in query parameter, API will return the latest reading
///
/// - 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.
///
/// - Unit of measure for readings is `µg/m3`.
///
/// # Optional request settings
///
/// - [`date`](Pm25Action::date): SGT date for which to retrieve data (YYYY-MM-DD). Omit for latest.
/// - [`pagination_token`](Pm25Action::pagination_token): Pagination token for subsequent pages (only when date filter is used and more pages exist).
/// - [`x_api_key`](Pm25Action::x_api_key): Optional API key for higher rate limits.
///
/// # Example
///
/// ```rust,ignore
/// let request = api
/// .air_quality()
/// .pm25()
/// .date(date)
/// .request()?;
/// ```
pub fn pm25(&self) -> Pm25Action<'a> {
Pm25Action::new(self.api)
}
}