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, 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)
    }
}