Rewrite to a API trait.
This commit is contained in:
@@ -3,9 +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::apis::default_api::locations_get;
|
||||
use gamenight_api_client_rs::models::OwnGameRequestBody;
|
||||
use gamenight_api_client_rs::apis::default_api::own_post;
|
||||
use inquire::{Confirm, Select};
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -35,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 = locations_get(&state.api_configuration).await?.iter().map(|x| { x.try_into() }).collect::<Result<Vec<LocationSelectData>, FlowError>>()?;
|
||||
let locations = state.api.locations_get().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 _ = own_post(&state.api_configuration, Some(own_game_request)).await?;
|
||||
let _ = state.api.own_post(Some(own_game_request)).await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user