From 6278a212c2d9457835f39f2674ce34e2c5a8b9f4 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sat, 30 Aug 2025 12:03:26 -0400 Subject: [PATCH 1/5] Able to retrieve songs --- src/managers/commit_manager.rs | 5 +++-- src/syncers/common.rs | 2 +- src/syncers/retrieve_records.rs | 23 +++++++++++++++++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/managers/commit_manager.rs b/src/managers/commit_manager.rs index a08c96f..1c787b5 100644 --- a/src/managers/commit_manager.rs +++ b/src/managers/commit_manager.rs @@ -251,10 +251,11 @@ impl CommitManager { let api = prsr.retrieve_api(parsers::api_parser::APIType::Main); let mut repo = syncers::retrieve_records::RetrieveRecords { api: api.clone() }; - let result_fut = repo.get_all_songs(&token); - match Runtime::new().unwrap().block_on(result_fut) { + match repo.get_all_songs(&token).await { Ok(o) => { + println!("Songs"); + println!("====="); for song in o { println!("Title: {:?}", song.title); println!("Artist: {:?}", song.artist); diff --git a/src/syncers/common.rs b/src/syncers/common.rs index 2bc1873..095b39b 100644 --- a/src/syncers/common.rs +++ b/src/syncers/common.rs @@ -9,7 +9,7 @@ pub fn retrieve_url(api: &models::api::Api, with_id: bool, id: &uuid::Uuid) -> S } fn retrieve_url_reg(api: &models::api::Api) -> String { - let url = format!("{}/api/{}/{}/", api.url, api.version, api.endpoint); + let url = format!("{}api/{}/{}/", api.url, api.version, api.endpoint); url } diff --git a/src/syncers/retrieve_records.rs b/src/syncers/retrieve_records.rs index dc906b8..f0be59a 100644 --- a/src/syncers/retrieve_records.rs +++ b/src/syncers/retrieve_records.rs @@ -9,15 +9,27 @@ pub struct RetrieveRecords { pub api: models::api::Api, } +mod response { + pub mod get_all_songs { + #[derive(Debug, serde::Deserialize)] + pub struct Response { + pub message: String, + pub data: Vec + } + } +} + impl RetrieveRecords { pub async fn get_all_songs( &mut self, token: &icarus_models::token::AccessToken, ) -> Result, Error> { - self.api.endpoint = String::from("song"); - let url = syncers::common::retrieve_url(&self.api, false, &uuid::Uuid::nil()); + self.api.endpoint = String::from("api/v2/song/all"); + let url = format!("{}{}", self.api.url, self.api.endpoint); let access_token = token.bearer_token(); + println!("url: {url:?}"); + let client = reqwest::Client::builder().build().unwrap(); let response = client .get(&url) @@ -29,8 +41,11 @@ impl RetrieveRecords { match response.status() { reqwest::StatusCode::OK => { // on success, parse our JSON to an API Response - match response.json::>().await { - Ok(parsed) => Ok(parsed), + match response.json::().await { + Ok(parsed) => { + println!("Response message: {:?}", parsed.message); + Ok(parsed.data) + } Err(err) => Err(std::io::Error::other(err.to_string())), } } -- 2.47.3 From bf2c46d27ceb3bc2db6a5aab01d475bea39fa304 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sat, 30 Aug 2025 12:04:02 -0400 Subject: [PATCH 2/5] Updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 996cbfc..064638d 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ icarus-dm upload-meta -u spacecadet -p stellar40 -h https://icarus.com -ha https ### Retrieving Song in json ```Bash -icarus-dm retrieve -u spacecadet -p stellar40 -h https://icarus.com -rt songs +icarus-dm retrieve -u spacecadet -p stellar40 -h https://icarus.com -ha https://auth.icarus.com -rt songs ``` ### Deleting Song -- 2.47.3 From 409612210a2b5aadc2e871ba5eed63579c185136 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sat, 30 Aug 2025 12:04:43 -0400 Subject: [PATCH 3/5] Removed unused import --- src/syncers/retrieve_records.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/syncers/retrieve_records.rs b/src/syncers/retrieve_records.rs index f0be59a..0a05235 100644 --- a/src/syncers/retrieve_records.rs +++ b/src/syncers/retrieve_records.rs @@ -2,7 +2,6 @@ use std::default::Default; use std::io::Error; use crate::models; -use crate::syncers; #[derive(Default)] pub struct RetrieveRecords { -- 2.47.3 From d903f51026b0d50c9eac426afca30fe926ffb9f6 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sat, 30 Aug 2025 12:06:27 -0400 Subject: [PATCH 4/5] Code formatting --- src/syncers/retrieve_records.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/syncers/retrieve_records.rs b/src/syncers/retrieve_records.rs index 0a05235..96752c0 100644 --- a/src/syncers/retrieve_records.rs +++ b/src/syncers/retrieve_records.rs @@ -13,7 +13,7 @@ mod response { #[derive(Debug, serde::Deserialize)] pub struct Response { pub message: String, - pub data: Vec + pub data: Vec, } } } @@ -44,7 +44,7 @@ impl RetrieveRecords { Ok(parsed) => { println!("Response message: {:?}", parsed.message); Ok(parsed.data) - } + } Err(err) => Err(std::io::Error::other(err.to_string())), } } -- 2.47.3 From c3a25c607009ff88d6183b2eb6a820116adb582f Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sat, 30 Aug 2025 12:06:35 -0400 Subject: [PATCH 5/5] Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b8b6f27..1befee6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -479,7 +479,7 @@ dependencies = [ [[package]] name = "icarus-dm" -version = "0.6.6" +version = "0.6.7" dependencies = [ "futures", "http", diff --git a/Cargo.toml b/Cargo.toml index 4b42cd5..261a223 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icarus-dm" -version = "0.6.6" +version = "0.6.7" rust-version = "1.88" edition = "2024" -- 2.47.3