Skip to main content

lta/get_traffic_flow/
json.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::parts::{GetTrafficFlowInput, GetTrafficFlowResponse, get_traffic_flow_parts};
12/// Returns a link to a JSON file containing hourly average traffic flow, taken from a representative month of every quarter during 0700-0900 hours.
13/// **Update freq**: Quarterly
14pub fn encode_get_traffic_flow(
15    input: GetTrafficFlowInput,
16) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
17    let parts = get_traffic_flow_parts(input)?;
18    satay_runtime::into_empty_request(parts)
19}
20pub fn decode_get_traffic_flow_response<B: AsRef<[u8]>>(
21    response: satay_runtime::ResponseParts<B>,
22) -> Result<GetTrafficFlowResponse, satay_runtime::Error> {
23    let status = response.status;
24    match status.as_u16() {
25        200 => {
26            let body = response.body;
27            let value = satay_runtime::from_projected_json_slice::<Vec<String>>(
28                body.as_ref(),
29                "value",
30                Some("Link"),
31            )?;
32            Ok(GetTrafficFlowResponse::Ok(value))
33        }
34        _ => {
35            let body = response.body;
36            Ok(GetTrafficFlowResponse::UnexpectedStatus(
37                status,
38                body.as_ref().to_vec(),
39            ))
40        }
41    }
42}