Skip to content

Commit

Permalink
Make block_id a required query parameter for most requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
FiveMovesAhead committed May 6, 2024
1 parent 5df2289 commit ca66baf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
16 changes: 4 additions & 12 deletions tig-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,23 @@ impl Api {

pub async fn get_challenges(&self, req: GetChallengesReq) -> Result<GetChallengesResp> {
let mut query = HashMap::<String, String>::new();
if let Some(block_id) = req.block_id {
query.insert("block_id".to_string(), block_id);
}
query.insert("block_id".to_string(), req.block_id);
let query = QueryMap::from(query);
self.get(format!("get-challenges?{}", query.to_query_string()))
.await
}

pub async fn get_algorithms(&self, req: GetAlgorithmsReq) -> Result<GetAlgorithmsResp> {
let mut query = HashMap::<String, String>::new();
if let Some(block_id) = req.block_id {
query.insert("block_id".to_string(), block_id);
}
query.insert("block_id".to_string(), req.block_id);
let query = QueryMap::from(query);
self.get(format!("get-algorithms?{}", query.to_query_string()))
.await
}

pub async fn get_players(&self, req: GetPlayersReq) -> Result<GetPlayersResp> {
let mut query = HashMap::<String, String>::new();
if let Some(block_id) = req.block_id {
query.insert("block_id".to_string(), block_id);
}
query.insert("block_id".to_string(), req.block_id);
query.insert("player_type".to_string(), req.player_type.to_string());
let query = QueryMap::from(query);
self.get(format!("get-players?{}", query.to_query_string()))
Expand All @@ -91,9 +85,7 @@ impl Api {

pub async fn get_benchmarks(&self, req: GetBenchmarksReq) -> Result<GetBenchmarksResp> {
let mut query = HashMap::<String, String>::new();
if let Some(block_id) = req.block_id {
query.insert("block_id".to_string(), block_id);
}
query.insert("block_id".to_string(), req.block_id);
query.insert("player_id".to_string(), req.player_id);
let query = QueryMap::from(query);
self.get(format!("get-benchmarks?{}", query.to_query_string()))
Expand Down
8 changes: 4 additions & 4 deletions tig-structs/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl PlayerType {

serializable_struct_with_getters! {
GetPlayersReq {
block_id: Option<String>,
block_id: String,
player_type: PlayerType,
}
}
Expand Down Expand Up @@ -69,7 +69,7 @@ serializable_struct_with_getters! {

serializable_struct_with_getters! {
GetChallengesReq {
block_id: Option<String>,
block_id: String,
}
}

Expand All @@ -83,7 +83,7 @@ serializable_struct_with_getters! {

serializable_struct_with_getters! {
GetAlgorithmsReq {
block_id: Option<String>,
block_id: String,
}
}

Expand All @@ -98,7 +98,7 @@ serializable_struct_with_getters! {

serializable_struct_with_getters! {
GetBenchmarksReq {
block_id: Option<String>,
block_id: String,
player_id: String,
}
}
Expand Down

0 comments on commit ca66baf

Please sign in to comment.