Adds own/disown game logic
This commit is contained in:
36
gamenight-cli/src/flows/own.rs
Normal file
36
gamenight-cli/src/flows/own.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use gamenight_api_client_rs::{apis::default_api::own_post, models::GameId};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::{Flow, FlowOutcome, FlowResult, GamenightState};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Own {
|
||||
game_id: Uuid
|
||||
}
|
||||
|
||||
impl Own {
|
||||
pub fn new(game_id: Uuid) -> Self {
|
||||
Self {
|
||||
game_id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<'a> Flow<'a> for Own {
|
||||
async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> {
|
||||
let _ = own_post(&state.api_configuration, Some(GameId{game_id: self.game_id.to_string()})).await?;
|
||||
|
||||
clear_screen::clear();
|
||||
Ok((FlowOutcome::Successful, state))
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Own {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "Own")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user