From 4b596c9c849b310d8b7952a4c16fcdd33b34e902 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 1 Feb 2022 16:59:23 +0100 Subject: add `traveltext destination` I have no intention of going to Hamburg today, so I need to check out earlier --- src/main.rs | 17 +++++++++++++++++ src/travelynx.rs | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/main.rs b/src/main.rs index a0984e6..1712545 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,10 @@ enum Command { #[clap(flatten)] train: TrainRef, }, + /// (If already checked in) change the trip's destination + Destination { + to: String + }, /// If iceportal.de is available, ask it which train we're in and /// check in Autocheckin, @@ -101,6 +105,19 @@ fn main() -> Result<(), ureq::Error> { cli.debug, ); + println!("{}: {}", traveltext, resp); + }, + Command::Destination { to } => { + let resp: Response = exiting_post_request( + &format!("{}/api/v1/travel", cli.baseurl), + Action::CheckOut { + to_station: to, + force: false, + token: config.token_travel, + comment: None + }, + cli.debug + ); println!("{}: {}", traveltext, resp); } Command::Undo => { diff --git a/src/travelynx.rs b/src/travelynx.rs index 0188f32..5457641 100644 --- a/src/travelynx.rs +++ b/src/travelynx.rs @@ -28,11 +28,13 @@ pub enum Action { comment: Option, }, #[serde(rename = "checkout")] + #[serde(rename_all = "camelCase")] CheckOut { to_station: String, force: bool, #[serde(skip_serializing_if = "Option::is_none")] comment: Option, + token: String }, Undo {token: String}, } -- cgit v1.2.3