use anyhow::Context; use gloo_net::http::Request; use protocol::{ bridge_engine::{TableStatePlayerView}, card::Card, Table, actions::Bid, }; use crate::utils::ok_json; pub async fn get_table_player_view( table: Table, ) -> Result { let response = Request::get(&format!("/api/table/{}", table.id)) .send() .await .context("fetching table data")?; let table = ok_json(response).await?; Ok(table) } pub async fn bid(table: Table, bid: Bid) -> Result<(), anyhow::Error> { let response = Request::post(&format!("/api/table/{}/bid", table.id)) .json(&bid)? .send() .await .context("submitting bid")?; ok_json(response).await } pub async fn play(table: Table, card: Card) -> Result<(), anyhow::Error> { let response = Request::post(&format!("/api/table/{}/play", table.id)) .json(&card)? .send() .await .context("submitting play")?; ok_json(response).await } pub async fn new_deal(table: Table) -> Result<(), anyhow::Error> { let response = Request::post(&format!("/api/table/{}/admin/deal", table.id)) .send() .await .context("requesting new deal")?; ok_json(response).await }