fej/src/ivago/mod.rs

31 lines
813 B
Rust
Raw Normal View History

2021-03-15 14:48:20 +01:00
mod controller;
2021-04-02 21:20:36 +02:00
#[cfg(test)]
mod tests;
2021-03-06 00:25:40 +01:00
2021-03-21 16:18:53 +01:00
use chrono::NaiveDate;
2021-04-02 21:20:36 +02:00
use rocket_contrib::json::Json;
2021-03-12 22:17:59 +01:00
2021-03-06 00:25:40 +01:00
pub fn routes() -> Vec<rocket::Route> {
2021-04-02 21:20:36 +02:00
routes![route_search_streets,]
2021-03-06 00:25:40 +01:00
}
// URL: https://www.ivago.be/nl/particulier/autocomplete/garbage/streets?q=Lange
2021-03-12 22:17:59 +01:00
// TODO make this async
// TODO change this so it can return errors instead of empty json
2021-03-23 12:16:01 +01:00
#[get("/search?<street>")]
2021-03-15 14:48:20 +01:00
pub fn search_streets_json(street: String) -> Json<Vec<controller::Street>> {
match controller::search_streets(&street) {
2021-03-12 22:17:59 +01:00
Ok(streets) => Json(streets),
2021-03-21 16:18:53 +01:00
Err(err) => Json(Vec::new()),
2021-03-12 22:17:59 +01:00
}
2021-03-06 00:25:40 +01:00
}
2021-03-21 16:18:53 +01:00
#[get("/?<street>&<number>&<start_date>&<end_date>")]
pub fn route_get_pickup_times(
street: controller::Street,
number: u64,
start_date: NaiveDate,
2021-04-02 21:20:36 +02:00
end_date: NaiveDate,
) -> Json<Vec<controller::PickupTime>> {
2021-03-21 16:18:53 +01:00
}