Code formatting
All checks were successful
Rust Build / Check (pull_request) Successful in 34s
Rust Build / Test Suite (pull_request) Successful in 35s
Rust Build / Rustfmt (pull_request) Successful in 27s
Rust Build / Clippy (pull_request) Successful in 33s
Rust Build / build (pull_request) Successful in 41s
All checks were successful
Rust Build / Check (pull_request) Successful in 34s
Rust Build / Test Suite (pull_request) Successful in 35s
Rust Build / Rustfmt (pull_request) Successful in 27s
Rust Build / Clippy (pull_request) Successful in 33s
Rust Build / build (pull_request) Successful in 41s
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
pub async fn fetch_next_queue_item(
|
pub async fn fetch_next_queue_item(base_url: &String) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
base_url: &String,
|
|
||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
let fetch_endpoint = String::from("api/v2/song/queue/next");
|
let fetch_endpoint = String::from("api/v2/song/queue/next");
|
||||||
let api_url = format!("{base_url}/{fetch_endpoint}");
|
let api_url = format!("{base_url}/{fetch_endpoint}");
|
||||||
@@ -131,4 +129,3 @@ pub mod get_coverart_queue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
36
src/main.rs
36
src/main.rs
@@ -94,9 +94,19 @@ async fn some_work(
|
|||||||
let user_id = uuid::Uuid::new_v4();
|
let user_id = uuid::Uuid::new_v4();
|
||||||
// TODO: Place this somewhere else
|
// TODO: Place this somewhere else
|
||||||
let song_type = String::from("flac");
|
let song_type = String::from("flac");
|
||||||
// Err(std::io::Error::other(err.to_string()))
|
// Err(std::io::Error::other(err.to_string()))
|
||||||
match the_rest::create_song::create(app_base_url, &metadata, &user_id, &song_type).await {
|
match the_rest::create_song::create(
|
||||||
Ok(response) => match response.json::<the_rest::create_song::response::Response>().await {
|
app_base_url,
|
||||||
|
&metadata,
|
||||||
|
&user_id,
|
||||||
|
&song_type,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(response) => match response
|
||||||
|
.json::<the_rest::create_song::response::Response>()
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok(resp) => {
|
Ok(resp) => {
|
||||||
println!("Response: {resp:?}");
|
println!("Response: {resp:?}");
|
||||||
|
|
||||||
@@ -111,13 +121,9 @@ async fn some_work(
|
|||||||
// println!("Response json: {:?}", response.text().await);
|
// println!("Response json: {:?}", response.text().await);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
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())),
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
@@ -136,7 +142,15 @@ async fn some_work(
|
|||||||
async fn prep_song(
|
async fn prep_song(
|
||||||
api_url: &String,
|
api_url: &String,
|
||||||
song_queue_id: &uuid::Uuid,
|
song_queue_id: &uuid::Uuid,
|
||||||
) -> Result<(String, String, api::get_metadata_queue::response::Metadata, uuid::Uuid), reqwest::Error> {
|
) -> Result<
|
||||||
|
(
|
||||||
|
String,
|
||||||
|
String,
|
||||||
|
api::get_metadata_queue::response::Metadata,
|
||||||
|
uuid::Uuid,
|
||||||
|
),
|
||||||
|
reqwest::Error,
|
||||||
|
> {
|
||||||
match api::fetch_song_queue_data::get_data(api_url, song_queue_id).await {
|
match api::fetch_song_queue_data::get_data(api_url, song_queue_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
// Process data here...
|
// Process data here...
|
||||||
|
@@ -2,8 +2,13 @@
|
|||||||
|
|
||||||
// TODO: Create song
|
// TODO: Create song
|
||||||
pub mod create_song {
|
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> {
|
pub async fn create(
|
||||||
let payload = serde_json::json!(
|
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,
|
"album": &metadata_queue.album,
|
||||||
"album_artist": &metadata_queue.album_artist,
|
"album_artist": &metadata_queue.album_artist,
|
||||||
@@ -22,21 +27,21 @@ pub async fn create(base_url: &String, metadata_queue: &crate::api::get_metadata
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
let client = reqwest::Client::builder().build()?;
|
let client = reqwest::Client::builder().build()?;
|
||||||
|
|
||||||
let url = format!("{base_url}/api/v2/song");
|
let url = format!("{base_url}/api/v2/song");
|
||||||
|
|
||||||
let request = client.post(url).json(&payload);
|
let request = client.post(url).json(&payload);
|
||||||
request.send().await
|
request.send().await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod response {
|
pub mod response {
|
||||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||||
pub struct Response {
|
pub struct Response {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub data: Vec<icarus_models::song::Song>,
|
pub data: Vec<icarus_models::song::Song>,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Create coverart
|
// TODO: Create coverart
|
||||||
|
Reference in New Issue
Block a user