From 2feeca134368f128e2133adc4be91d9bd17c0dc5 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 23 Feb 2019 22:35:08 +0100 Subject: Add api to fetch availability data as well. --- src/main.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 53752c0..014e8b2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,10 +22,16 @@ use oslobike; fn main() { let api_key = dotenv::var("OSLOBIKE_APIKEY").expect("No API key defined!"); let api = oslobike::Api::new(api_key).unwrap(); + let stations = api.stations().unwrap(); + let station_availability = api.station_availability().unwrap(); + for station in api.stations().unwrap() { - println!("{:>4} {}: {}", + let a = station_availability.iter().find(|s| s.id == station.id).unwrap(); + println!("{:>4} {:<32}: {:>2} bikes, {:>2} locks of {:>2} total", station.id, station.title, + a.availability.bikes, + a.availability.locks, station.number_of_locks); } } -- cgit v1.2.3