diff options
author | stuebinm | 2022-02-08 16:55:51 +0100 |
---|---|---|
committer | stuebinm | 2022-02-08 16:56:21 +0100 |
commit | cf88935b5245daea51d2b513709b61a0e43483d6 (patch) | |
tree | a3900ac0ca602003a144aad8ca3e6336e1e9f165 /src/main.rs | |
parent | 36acf9b9e4d35dea60ef2bfe9998d09fd6a1ebef (diff) |
S-Bahns are weird
(added a simple zugportal.de api client, but can't do auto-checkin yet)
Diffstat (limited to '')
-rw-r--r-- | src/main.rs | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 1782953..7e1c85a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,7 +41,8 @@ enum Command { /// Undo the last checkin (if any). Undo, /// Query iceportal.de (for testing) - ICEPortal + ICEPortal, + Zugportal } #[derive(Deserialize)] @@ -213,6 +214,29 @@ fn main() -> Result<(), ureq::Error> { } } } + Command::Zugportal => { + match get_request::<traveltext::zugportal::Journey>( + // "https://iceportal.de/api1/rs/tripInfo/trip" + "https://zugportal.de/prd/zupo-travel-information/api/public/ri/journey" + ) { + Ok(resp) => { + println!( + "{}: Currently in {}\n", + traveltext, + resp.get_train_ref().to_string().green() + ); + // println!("guessing last stop was: {:?}\n", resp.guess_last_station()); + println!("Stops:\n{}", resp.trip()) + } + Err(err) => { + if cli.debug { + eprintln!("{:?}", err); + } + println!("either this tool or the zugportal broke or you're not actually on an ICE\n\ + (get a response but couldn't parse it)"); + } + } + } } Ok(()) } |