Fixed function to create song and added Response
This commit is contained in:
@@ -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<reqwest::Response, reqwest::Error> {
|
||||
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<reqwest::Response, reqwest::Error> {
|
||||
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<icarus_models::song::Song>,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user