Skip to content

Commit

Permalink
fix strings not being url encoded in ris client (other clients #todo)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmaboecker committed Aug 17, 2024
1 parent 9a91a64 commit 78dc12d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 6 additions & 6 deletions ris-client/src/endpoints/journey_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use chrono::NaiveDate;

pub use response::*;

use crate::{RisClient, RisOrRequestError};
use crate::request::ResponseOrRisError;
use crate::{RisClient, RisOrRequestError};

mod response;

Expand All @@ -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 {
Expand All @@ -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))
}
}
}
}
}
9 changes: 4 additions & 5 deletions ris-client/src/endpoints/station_search.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pub use response::*;

use crate::{RisClient, RisOrRequestError};
use crate::request::ResponseOrRisError;
use crate::{RisClient, RisOrRequestError};

mod response;

Expand All @@ -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
Expand All @@ -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))
}
}
}
}

0 comments on commit 78dc12d

Please sign in to comment.