Converted the Api to a Restful api.
This commit is contained in:
@@ -3,7 +3,7 @@ use std::fmt::Display;
|
||||
use super::{Flow, FlowError, FlowOutcome, FlowResult, GamenightState};
|
||||
use crate::domain::location_select_data::LocationSelectData;
|
||||
use async_trait::async_trait;
|
||||
use gamenight_api_client_rs::models::OwnGameRequestBody;
|
||||
use gamenight_api_client_rs::models::OwnGame;
|
||||
use inquire::{Confirm, Select};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -24,8 +24,8 @@ impl Own {
|
||||
impl<'a> Flow<'a> for Own {
|
||||
async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> {
|
||||
|
||||
let mut own_game_request = OwnGameRequestBody {
|
||||
game_id: self.game_id.to_string(),
|
||||
let mut own_game_request = OwnGame {
|
||||
user_id: state.get_user_id()?.to_string(),
|
||||
location_id: None
|
||||
};
|
||||
|
||||
@@ -33,13 +33,13 @@ impl<'a> Flow<'a> for Own {
|
||||
if owned {
|
||||
if let Some(willing_to_travel) = Confirm::new("Are you willing to travel with this game?").prompt_skippable()? {
|
||||
if !willing_to_travel {
|
||||
let locations = state.api.locations_get().await?.iter().map(|x| { x.try_into() }).collect::<Result<Vec<LocationSelectData>, FlowError>>()?;
|
||||
let locations = state.api.get_locations().await?.iter().map(|x| { x.try_into() }).collect::<Result<Vec<LocationSelectData>, FlowError>>()?;
|
||||
if let Some(location) = Select::new("What location can this game be played?", locations).prompt_skippable()? {
|
||||
own_game_request.location_id = Some(location.id.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
let _ = state.api.own_post(Some(own_game_request)).await?;
|
||||
let _ = state.api.post_game_owners(&self.game_id.to_string(), Some(own_game_request)).await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user