Added functionality to wipe data from coverart_queue
This commit is contained in:
13
src/main.rs
13
src/main.rs
@@ -73,9 +73,16 @@ async fn wipe_data_from_queues(
|
|||||||
.json::<the_rest::wipe_data::song_queue::response::Response>()
|
.json::<the_rest::wipe_data::song_queue::response::Response>()
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_resp) => {
|
Ok(_resp) => match the_rest::wipe_data::coverart_queue::wipe_data(app_base_url, coverart_queue_id).await {
|
||||||
println!("Wiped data from song queue");
|
Ok(inner_response) => match inner_response.json::<the_rest::wipe_data::coverart_queue::response::Response>().await {
|
||||||
Ok(())
|
Ok(_inner_resp) => {
|
||||||
|
println!("Wiped data from CoverArt queue");
|
||||||
|
println!("Resp: {_inner_resp:?}");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string()))
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string()))
|
||||||
}
|
}
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
},
|
},
|
||||||
|
@@ -99,4 +99,27 @@ pub mod wipe_data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// TODO: Wipe data from queued coverart
|
// TODO: Wipe data from queued coverart
|
||||||
|
pub mod coverart_queue {
|
||||||
|
pub async fn wipe_data(
|
||||||
|
base_url: &String,
|
||||||
|
coverart_queue_id: &uuid::Uuid,
|
||||||
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
|
let client = reqwest::Client::builder().build()?;
|
||||||
|
let url = format!("{base_url}/api/v2/coverart/queue/data/wipe");
|
||||||
|
let payload = serde_json::json!({
|
||||||
|
"coverart_queue_id": coverart_queue_id
|
||||||
|
});
|
||||||
|
let request = client.patch(url).json(&payload);
|
||||||
|
|
||||||
|
request.send().await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub mod response {
|
||||||
|
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||||
|
pub struct Response {
|
||||||
|
pub message: String,
|
||||||
|
pub data: Vec<uuid::Uuid>,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user