Updated icarus_models (#44)
* Updated icarus_models * Constants and url changes * Refactoring * Removed functions * Fixing tests
This commit was merged in pull request #44.
This commit is contained in:
+4
-21
@@ -4,6 +4,7 @@ use http::HeaderValue;
|
||||
use reqwest;
|
||||
|
||||
use crate::models;
|
||||
use crate::syncers;
|
||||
|
||||
pub struct Upload {
|
||||
pub api: models::api::API,
|
||||
@@ -25,7 +26,7 @@ impl Upload {
|
||||
cover: &icarus_models::coverart::CoverArt,
|
||||
) -> Result<reqwest::Response, reqwest::Error> {
|
||||
self.api.endpoint = String::from("song/data/upload/with/data");
|
||||
let url = self.retrieve_url();
|
||||
let url = syncers::common::retrieve_url(&self.api, false, 0);
|
||||
let access_token = token.bearer_token();
|
||||
|
||||
if url.is_empty() {
|
||||
@@ -80,9 +81,9 @@ impl Upload {
|
||||
println!("\n{}\n", song_detail);
|
||||
|
||||
let mut song_filename = String::from("audio");
|
||||
song_filename += icarus_models::constants::DEFAULTMUSICEXTENSION;
|
||||
song_filename += icarus_models::constants::file_extensions::audio::DEFAULTMUSICEXTENSION;
|
||||
let mut cover_filename = String::from("cover");
|
||||
cover_filename += icarus_models::constants::JPGEXTENSION;
|
||||
cover_filename += icarus_models::constants::file_extensions::image::JPGEXTENSION;
|
||||
|
||||
let form = reqwest::multipart::Form::new()
|
||||
.part(
|
||||
@@ -106,22 +107,4 @@ impl Upload {
|
||||
api.version = String::from("v1");
|
||||
self.api = api;
|
||||
}
|
||||
|
||||
fn retrieve_url(&self) -> String {
|
||||
let api = &self.api;
|
||||
let mut buffer = api.url.clone();
|
||||
let count = buffer.len();
|
||||
|
||||
if buffer.chars().nth(count - 1) != Some('/') {
|
||||
buffer += "/";
|
||||
}
|
||||
|
||||
let mut url: String = String::from(&buffer);
|
||||
url += &String::from("api/");
|
||||
url += &String::from(&api.version);
|
||||
url += &String::from("/");
|
||||
url += &String::from(&api.endpoint);
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user