First set of commits for realtime support
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
/***
|
||||
* Implementation of GTFS-R polling
|
||||
*/
|
||||
|
||||
use std::{str::FromStr, time::Duration};
|
||||
|
||||
use reqwest::{blocking::Client, header::{HeaderName, HeaderValue}};
|
||||
|
||||
use crate::gtfs::structs::{Arrival, Error, Gtfs};
|
||||
|
||||
impl Gtfs<'_> {
|
||||
fn realtime_update (&self, arrivals: Vec<Arrival<'_>>) -> Result<bool, Error>{
|
||||
|
||||
// Poll GTFS-R API
|
||||
let client = Client::builder()
|
||||
.timeout(Duration::from_secs(10))
|
||||
.connect_timeout(Duration::from_secs(5))
|
||||
.build()?;
|
||||
|
||||
let mut response = client
|
||||
.get(self.preferences.realtime_url)
|
||||
.header("x-api-key", self.preferences.realtime_api_key)
|
||||
.send()?;
|
||||
|
||||
// Parse response
|
||||
let response = json::rdr
|
||||
|
||||
// Match deltas to existing arrivals
|
||||
|
||||
// Update the arrival times
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user