diff --git a/src/api.rs b/src/api.rs index 3673a36..a5a1470 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,12 +1,35 @@ -pub async fn fetch_next_queue_item( - app: &crate::config::App, -) -> Result { - let client = reqwest::Client::new(); - let fetch_endpoint = String::from("api/v2/song/queue/next"); - let api_url = format!("{}/{fetch_endpoint}", app.uri); - let (key, header) = auth_header(app).await; - client.get(api_url).header(key, header).send().await +pub mod fetch_next_queue_item { + + pub async fn fetch_next_queue_item( + app: &crate::config::App, + ) -> Result { + let client = reqwest::Client::new(); + let fetch_endpoint = String::from("api/v2/song/queue/next"); + let api_url = format!("{}/{fetch_endpoint}", app.uri); + let (key, header) = super::auth_header(app).await; + + client.get(api_url).header(key, header).send().await + } + + pub mod response { + use serde::{Deserialize, Serialize}; + + + #[derive(Debug, Deserialize, Serialize)] + pub struct QueueItem { + pub id: uuid::Uuid, + pub filename: String, + pub status: String, + pub user_id: uuid::Uuid, + } + + #[derive(Debug, Deserialize, Serialize)] + pub struct SongQueueItem { + pub message: String, + pub data: Vec, + } + } } pub async fn auth_header( diff --git a/src/main.rs b/src/main.rs index f898af4..e06b949 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,5 @@ pub mod api; pub mod config; -pub mod responses; pub mod the_rest; pub mod util; @@ -218,11 +217,11 @@ async fn cleanup( async fn is_queue_empty( app: &config::App, -) -> Result<(bool, responses::fetch_next_queue_item::SongQueueItem), reqwest::Error> { - match api::fetch_next_queue_item(app).await { +) -> Result<(bool, api::fetch_next_queue_item::response::SongQueueItem), reqwest::Error> { + match api::fetch_next_queue_item::fetch_next_queue_item(app).await { Ok(response) => { match response - .json::() + .json::() .await { Ok(response) => {