More changes. Not functional yet
This commit is contained in:
@@ -39,7 +39,9 @@ impl ActionManager {
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
/**
|
||||
fn supported_actions(&self) {}
|
||||
*/
|
||||
|
||||
pub fn initialize(&mut self) {
|
||||
self.validate_flags();
|
||||
|
||||
@@ -3,7 +3,9 @@ use std::collections::HashMap;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::managers;
|
||||
use crate::models;
|
||||
use crate::parsers;
|
||||
use crate::utilities;
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
@@ -81,13 +83,30 @@ impl CommitManager {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
fn map_actions(&self) -> HashMap<String, ActionValues> {
|
||||
return HashMap::new();
|
||||
let mut actions: HashMap<String, ActionValues> = HashMap::new();
|
||||
actions.insert("download".to_string(), ActionValues::DownloadAct);
|
||||
actions.insert("upload".to_string(), ActionValues::UploadAct);
|
||||
actions.insert("upload-meta".to_string(), ActionValues::UploadSongWithMetadata);
|
||||
actions.insert("retrieve".to_string(), ActionValues::RetrieveAct);
|
||||
actions.insert("delete".to_string(), ActionValues::DeleteAct);
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
fn delete_song(&self) {
|
||||
let mut prsr = parsers::api_parser::APIParser {
|
||||
ica_act: self.ica_action.clone(),
|
||||
api: models::api::API::default(),
|
||||
};
|
||||
|
||||
let api = prsr.retrieve_api();
|
||||
|
||||
let song = models::song::Song::default();
|
||||
|
||||
for arg in &self.ica_action.flags {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
@@ -102,8 +121,25 @@ impl CommitManager {
|
||||
fn upload_song(&self) {
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
fn parse_token(&self, api: &models::api::API) {}
|
||||
fn parse_token(&self, api: &models::api::API) -> models::token::Token {
|
||||
println!("Fetching token");
|
||||
|
||||
let mut usr_mgr: managers::user_manager::UserManager = managers::user_manager::UserManager {
|
||||
user: models::user::User {
|
||||
username: String::new(),
|
||||
password: String::new(),
|
||||
},
|
||||
ica_action: self.ica_action.clone(),
|
||||
};
|
||||
|
||||
let usr = usr_mgr.retrieve_user();
|
||||
let tok_mgr = managers::token_manager::TokenManager {
|
||||
user: usr,
|
||||
api: api.clone(),
|
||||
};
|
||||
|
||||
return tok_mgr.request_token();
|
||||
}
|
||||
// TODO: Implement
|
||||
fn upload_song_with_metadata(&self) {}
|
||||
// TODO: Implement
|
||||
@@ -153,7 +189,18 @@ impl CommitManager {
|
||||
if k != end && dot != end {
|
||||
let st = k + 1;
|
||||
let ed = dot - 1;
|
||||
let t = &filename[&st..&ed];
|
||||
let mut t: String = String::new();
|
||||
let mut index = 0;
|
||||
for a in filename.chars() {
|
||||
if index <= ed {
|
||||
t.push(a);
|
||||
} else if index >= st {
|
||||
t.push(a);
|
||||
}
|
||||
|
||||
index += 1;
|
||||
}
|
||||
// let t = &filename[1..5];
|
||||
}
|
||||
},
|
||||
2 => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
pub mod action_managers;
|
||||
pub mod commit_manager;
|
||||
pub mod user_manager;
|
||||
pub mod token_manager;
|
||||
|
||||
@@ -2,24 +2,31 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::models;
|
||||
|
||||
// mod managers {
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
pub struct UserManager {
|
||||
user: models::user::User,
|
||||
ica_action: models::icarus_action::IcarusAction,
|
||||
pub user: models::user::User,
|
||||
pub ica_action: models::icarus_action::IcarusAction,
|
||||
}
|
||||
|
||||
impl UserManager {
|
||||
// TODO: Implement
|
||||
pub fn retrieve_user(&self) -> models::user::User {
|
||||
return models::user::User {
|
||||
username: String::from(""),
|
||||
password: String::from(""),
|
||||
};
|
||||
return self.user.clone();
|
||||
}
|
||||
|
||||
// TODO: Implement
|
||||
fn parse_user_from_actions(&self) {}
|
||||
pub fn parse_user_from_actions(&mut self) {
|
||||
let args = &self.ica_action.flags;
|
||||
|
||||
for arg in args {
|
||||
let flag = &arg.flag;
|
||||
|
||||
if flag == "-u" {
|
||||
self.user.username = String::from(&arg.value);
|
||||
}
|
||||
|
||||
if flag == "-p" {
|
||||
self.user.password = String::from(&arg.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
|
||||
+7
-1
@@ -2,7 +2,7 @@ use std::default::Default;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct User {
|
||||
pub username: String,
|
||||
pub password: String,
|
||||
@@ -16,3 +16,9 @@ impl Default for User {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl User {
|
||||
pub fn to_json(&self) -> Result<String, serde_json::Error> {
|
||||
return serde_json::to_string_pretty(&self);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user