From 66900d64d6bf666b59c20a4c58642600fc3f4a68 Mon Sep 17 00:00:00 2001 From: phoenix Date: Mon, 14 Jul 2025 20:43:02 -0400 Subject: [PATCH] Fixed function to create song and added Response --- src/the_rest.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/the_rest.rs b/src/the_rest.rs index fae5311..b55ba1e 100644 --- a/src/the_rest.rs +++ b/src/the_rest.rs @@ -1,7 +1,8 @@ // TODO: Refactor this file when this app is functional // TODO: Create song -pub async fn create_song(base_url: &String, metadata_queue: &crate::api::get_metadata_queue::response::Metadata, user_id: &uuid::Uuid, song_type: &String) -> Result { +pub mod create_song { +pub async fn create(base_url: &String, metadata_queue: &crate::api::get_metadata_queue::response::Metadata, user_id: &uuid::Uuid, song_type: &String) -> Result { let payload = serde_json::json!( { "album": &metadata_queue.album, @@ -14,7 +15,7 @@ pub async fn create_song(base_url: &String, metadata_queue: &crate::api::get_met "title": &metadata_queue.title, "track": metadata_queue.track, "track_count": metadata_queue.track_count, - "year": metadata_queue.year, + "date": metadata_queue.year.to_string(), "audio_type": &song_type, "user_id": &user_id, "song_queue_id": &metadata_queue.song_queue_id, @@ -26,12 +27,16 @@ pub async fn create_song(base_url: &String, metadata_queue: &crate::api::get_met let url = format!("{base_url}/api/v2/song"); let request = client.post(url).json(&payload); - let response = request.send().await?; - - Ok(response) + request.send().await } pub mod response { + #[derive(Debug, serde::Deserialize, serde::Serialize)] + pub struct Response { + pub message: String, + pub data: Vec, + } +} } /*