Refactoring (#31)

* Refactoring code

* Code formatting

* More changes

* Moved to icarus-models::user

* Some refactoring

* Updated icarus-models

* Removing constants

* Replaced with icarus-models constants

* Formatting

* Switched to constants from icarus-models:

* Replaced Token with AccessToken from icarus-models

* Updated icarus-models

* Formatting

* Removing code
This commit was merged in pull request #31.
This commit is contained in:
KD
2025-03-13 21:40:22 -04:00
committed by GitHub
parent a372bfcc05
commit c575d2e523
18 changed files with 105 additions and 169 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ impl Default for Delete {
impl Delete {
pub async fn delete_song(
&mut self,
token: &models::token::Token,
token: &icarus_models::token::AccessToken,
song: &models::song::Song,
) -> Result<models::song::Song, std::io::Error> {
self.api.endpoint = "song/data/delete".to_owned();
+1 -1
View File
@@ -23,7 +23,7 @@ pub enum MyError {
impl Download {
pub async fn download_song(
&mut self,
token: &models::token::Token,
token: &icarus_models::token::AccessToken,
song: &models::song::Song,
) -> Result<String, MyError> {
self.api.endpoint = String::from("song/data/download");
+1 -1
View File
@@ -18,7 +18,7 @@ impl Default for RetrieveRecords {
impl RetrieveRecords {
pub async fn get_all_songs(
&mut self,
token: &models::token::Token,
token: &icarus_models::token::AccessToken,
) -> Result<Vec<models::song::Song>, Error> {
self.api.endpoint = String::from("song");
let mut songs: Vec<models::song::Song> = Vec::new();
+5 -6
View File
@@ -6,7 +6,6 @@ use reqwest;
use reqwest::multipart::Form;
use serde::{Deserialize, Serialize};
use crate::constants;
use crate::models;
pub struct Upload {
@@ -47,7 +46,7 @@ impl Default for Upload {
impl Upload {
pub async fn upload_song_with_metadata(
&mut self,
token: &models::token::Token,
token: &icarus_models::token::AccessToken,
song: &models::song::Song,
cover: &models::song::CoverArt,
album: &models::song::Album,
@@ -110,9 +109,9 @@ impl Upload {
let cover = reqwest::multipart::Part::bytes(cover_raw_data).headers(headers_i);
let mut song_filename = String::from("audio");
song_filename += constants::file_extensions::WAV_FILE_EXTENSION;
song_filename += icarus_models::constants::WAV_EXTENSION;
let mut cover_filename = String::from("cover");
cover_filename += constants::file_extensions::JPG_FILE_EXTENSION;
cover_filename += icarus_models::constants::JPG_EXTENSION;
return reqwest::multipart::Form::new()
.part("cover", cover.file_name(cover_filename))
@@ -128,9 +127,9 @@ impl Upload {
println!("\n{}\n", song_detail);
let mut song_filename = String::from("audio");
song_filename += constants::file_extensions::WAV_FILE_EXTENSION;
song_filename += icarus_models::constants::WAV_EXTENSION;
let mut cover_filename = String::from("cover");
cover_filename += constants::file_extensions::JPG_FILE_EXTENSION;
cover_filename += icarus_models::constants::JPG_EXTENSION;
let form = reqwest::multipart::Form::new()
.part(