diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2019-02-23 22:35:08 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2019-02-23 22:35:08 +0100 |
commit | 2feeca134368f128e2133adc4be91d9bd17c0dc5 (patch) | |
tree | 49e5652a7002c6f68fceaa842e06f500adb7b3a5 /src/main.rs | |
parent | f1b68ffc0f539b7782ed5cc593cbebc360fe4791 (diff) | |
download | oslobike-2feeca134368f128e2133adc4be91d9bd17c0dc5.tar.gz oslobike-2feeca134368f128e2133adc4be91d9bd17c0dc5.tar.bz2 oslobike-2feeca134368f128e2133adc4be91d9bd17c0dc5.zip |
Add api to fetch availability data as well.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 8 |
1 files changed, 7 insertions, 1 deletions
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); } } |