lta/get_bus_arrival/
parts.rs1#![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#[derive(Debug, Clone, PartialEq)]
19pub struct GetBusArrivalInput {
20 pub bus_stop_code: u32,
22 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#[derive(Debug, Clone, PartialEq)]
44pub enum GetBusArrivalResponse {
45 Ok(BusArrivalResponse),
47 UnexpectedStatus(http::StatusCode, Vec<u8>),
48}
49pub 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}