Rewrite to chatty but functional API.
This commit is contained in:
34
gamenight-cli/src/flows/join.rs
Normal file
34
gamenight-cli/src/flows/join.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use std::fmt::Display;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use gamenight_api_client_rs::{apis::default_api::join_post, models::GamenightId};
|
||||
use uuid::Uuid;
|
||||
|
||||
use super::{Flow, FlowOutcome, FlowResult, GamenightState};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Join {
|
||||
gamenight_id: Uuid
|
||||
}
|
||||
|
||||
impl Join {
|
||||
pub fn new(gamenight_id: Uuid) -> Self {
|
||||
Self {
|
||||
gamenight_id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
impl<'a> Flow<'a> for Join {
|
||||
async fn run(&self, state: &'a mut GamenightState) -> FlowResult<'a> {
|
||||
let _ = join_post(&state.configuration, Some(GamenightId{gamenight_id: self.gamenight_id.to_string()})).await?;
|
||||
Ok((FlowOutcome::Successful, state))
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Join {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "Join")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user