aboutsummaryrefslogtreecommitdiffstats
path: root/src/api.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/api.rs')
-rw-r--r--src/api.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/api.rs b/src/api.rs
index f67408d..c31ea8f 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -17,6 +17,7 @@
*/
use reqwest;
+use crate::station::{Station, StationContainer};
const API_BASE: &'static str = "https://oslobysykkel.no/api/v1";
@@ -40,9 +41,12 @@ impl Api {
Api { client }
}
- pub fn stations(&self) -> String {
- self.client.get(&url_for("stations"))
+ pub fn stations(&self) -> Vec<Station> {
+ let response_json = self.client.get(&url_for("stations"))
.send().unwrap()
- .text().unwrap()
+ .text().unwrap();
+
+ let v: StationContainer = serde_json::from_str(&response_json).unwrap();
+ v.stations
}
}