Skip to main content

lta/get_bus_arrival/
parts.rs

1// @generated by satay. Do not edit by hand.
2#![allow(
3    clippy::doc_markdown,
4    clippy::missing_errors_doc,
5    clippy::must_use_candidate,
6    clippy::needless_pass_by_value,
7    clippy::return_self_not_must_use,
8    clippy::single_match_else
9)]
10
11use super::super::types::{BusArrivalResponse, BusServiceNumber};
12/// Returns real-time Bus Arrival information of Bus Services at a queried Bus Stop, including
13/// - Estimated Arrival Time
14/// - Estimated Current Location
15/// - Estimated Current Load.
16///
17/// **Update freq**: 20s
18#[derive(Debug, Clone, PartialEq)]
19pub struct GetBusArrivalInput {
20    /// Bus stop reference code.
21    pub bus_stop_code: u32,
22    /// Optional bus service number filter.
23    pub service_no: Option<BusServiceNumber>,
24}
25impl GetBusArrivalInput {
26    pub fn new(bus_stop_code: u32) -> Self {
27        Self {
28            bus_stop_code,
29            service_no: None,
30        }
31    }
32    pub fn service_no(mut self, service_no: BusServiceNumber) -> Self {
33        self.service_no = Some(service_no);
34        self
35    }
36}
37/// Returns real-time Bus Arrival information of Bus Services at a queried Bus Stop, including
38/// - Estimated Arrival Time
39/// - Estimated Current Location
40/// - Estimated Current Load.
41///
42/// **Update freq**: 20s
43#[derive(Debug, Clone, PartialEq)]
44pub enum GetBusArrivalResponse {
45    /// Successful Bus Arrival response.
46    Ok(BusArrivalResponse),
47    UnexpectedStatus(http::StatusCode, Vec<u8>),
48}
49/// Returns real-time Bus Arrival information of Bus Services at a queried Bus Stop, including
50/// - Estimated Arrival Time
51/// - Estimated Current Location
52/// - Estimated Current Load.
53///
54/// **Update freq**: 20s
55pub fn get_bus_arrival_parts(
56    input: GetBusArrivalInput,
57) -> Result<satay_runtime::RequestParts<()>, satay_runtime::Error> {
58    let mut uri = String::with_capacity(14);
59    uri.push_str("/v3/BusArrival");
60    let mut first_query = true;
61    satay_runtime::append_query_pair(
62        &mut uri,
63        &mut first_query,
64        "BusStopCode",
65        &input.bus_stop_code.to_string(),
66    );
67    if let Some(value) = &input.service_no {
68        satay_runtime::append_query_pair(&mut uri, &mut first_query, "ServiceNo", value.as_ref());
69    }
70    let headers = http::HeaderMap::new();
71    Ok(satay_runtime::RequestParts {
72        method: http::Method::GET,
73        uri,
74        headers,
75        body: (),
76    })
77}