diff --git a/ris-client/src/endpoints/journey_search.rs b/ris-client/src/endpoints/journey_search.rs index 45e690c..c7c1068 100644 --- a/ris-client/src/endpoints/journey_search.rs +++ b/ris-client/src/endpoints/journey_search.rs @@ -2,8 +2,8 @@ use chrono::NaiveDate; pub use response::*; -use crate::{RisClient, RisOrRequestError}; use crate::request::ResponseOrRisError; +use crate::{RisClient, RisOrRequestError}; mod response; @@ -18,9 +18,11 @@ impl RisClient { let url = format!("{}/db/apis/ris-journeys/v1/byrelation", self.base_url); + let number = urlencoding::encode(number); + let mut query = vec![ ("category", category.to_owned()), - ("number", number.to_owned()), + ("number", number.into_owned()), ]; if let Some(date) = date { @@ -41,12 +43,10 @@ impl RisClient { match response { ResponseOrRisError::Response(response) => Ok(*response), - ResponseOrRisError::Error(error) => { - Err(RisOrRequestError::RisError(error)) - } + ResponseOrRisError::Error(error) => Err(RisOrRequestError::RisError(error)), ResponseOrRisError::UnauthorizedError(error) => { Err(RisOrRequestError::RisUnauthorizedError(error)) } } } -} \ No newline at end of file +} diff --git a/ris-client/src/endpoints/station_search.rs b/ris-client/src/endpoints/station_search.rs index d5b6e13..fec1d45 100644 --- a/ris-client/src/endpoints/station_search.rs +++ b/ris-client/src/endpoints/station_search.rs @@ -1,7 +1,7 @@ pub use response::*; -use crate::{RisClient, RisOrRequestError}; use crate::request::ResponseOrRisError; +use crate::{RisClient, RisOrRequestError}; mod response; @@ -15,6 +15,8 @@ impl RisClient { let limit = limit.unwrap_or(25); + let query = urlencoding::encode(query); + let url = format!( "{}/db/apis/ris-stations/v1/stop-places/by-name/{query}", self.base_url @@ -33,13 +35,10 @@ impl RisClient { match response { ResponseOrRisError::Response(response) => Ok(response.stop_places), - ResponseOrRisError::Error(error) => { - Err(RisOrRequestError::RisError(error)) - } + ResponseOrRisError::Error(error) => Err(RisOrRequestError::RisError(error)), ResponseOrRisError::UnauthorizedError(error) => { Err(RisOrRequestError::RisUnauthorizedError(error)) } } } } -