nea-rs 0.5.0

A type-safe, sans-IO Rust client for Singapore NEA real-time weather and environmental APIs.
Documentation
// @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)
    }
}