Cargo formatting
This commit is contained in:
@@ -29,12 +29,13 @@ impl Delete {
|
||||
let url = self.retrieve_url(&song);
|
||||
let client = reqwest::Client::new();
|
||||
let access_token = token.bearer_token();
|
||||
let response = client.delete(&url)
|
||||
let response = client
|
||||
.delete(&url)
|
||||
.header(reqwest::header::AUTHORIZATION, access_token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
match response.status() {
|
||||
reqwest::StatusCode::OK => {
|
||||
println!("Success!");
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::default::Default;
|
||||
|
||||
use crate::models;
|
||||
|
||||
pub struct Download{
|
||||
pub struct Download {
|
||||
pub api: models::api::API,
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@ impl Download {
|
||||
let url = self.retrieve_url(&song);
|
||||
let access_token = token.bearer_token();
|
||||
let client = reqwest::Client::new();
|
||||
let response = client.get(&url)
|
||||
let response = client
|
||||
.get(&url)
|
||||
.header(reqwest::header::AUTHORIZATION, &access_token)
|
||||
.send()
|
||||
.await
|
||||
@@ -60,4 +61,4 @@ impl Download {
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,10 @@ use crate::models;
|
||||
|
||||
// use super::syncer_base::Result;
|
||||
|
||||
|
||||
pub struct RetrieveRecords {
|
||||
pub api: models::api::API,
|
||||
}
|
||||
|
||||
|
||||
impl Default for RetrieveRecords {
|
||||
fn default() -> Self {
|
||||
RetrieveRecords {
|
||||
@@ -19,31 +17,31 @@ impl Default for RetrieveRecords {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl RetrieveRecords {
|
||||
pub async fn get_all_songs(&self, token: &models::token::Token)
|
||||
-> Result<Vec<models::song::Song>, Error> {
|
||||
|
||||
pub async fn get_all_songs(
|
||||
&self,
|
||||
token: &models::token::Token,
|
||||
) -> Result<Vec<models::song::Song>, Error> {
|
||||
let mut songs: Vec<models::song::Song> = Vec::new();
|
||||
let url = self.retrieve_url();
|
||||
let access_token = token.bearer_token();
|
||||
let client = reqwest::Client::new();
|
||||
let response = client.get(&url)
|
||||
let response = client
|
||||
.get(&url)
|
||||
.header(reqwest::header::AUTHORIZATION, access_token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
match response.status() {
|
||||
reqwest::StatusCode::OK => {
|
||||
// on success, parse our JSON to an APIResponse
|
||||
let s = response.json::<Vec<models::song::Song>>().await;
|
||||
match s {
|
||||
//
|
||||
//
|
||||
Ok(parsed) => {
|
||||
songs = parsed;
|
||||
},
|
||||
}
|
||||
Err(_) => println!("Hm, the response didn't match the shape we expected."),
|
||||
};
|
||||
}
|
||||
@@ -54,7 +52,7 @@ impl RetrieveRecords {
|
||||
panic!("Uh oh! Something unexpected happened: {:?}", other);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return Ok(songs);
|
||||
}
|
||||
|
||||
@@ -71,4 +69,4 @@ impl RetrieveRecords {
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,5 +26,3 @@ pub enum Result {
|
||||
UNAUTHORIZED,
|
||||
NOTFOUND,
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,12 +22,13 @@ impl Upload {
|
||||
let url = self.retrieve_url(&song);
|
||||
let client = reqwest::Client::new();
|
||||
let access_token = token.bearer_token();
|
||||
let response = client.post(&url)
|
||||
let response = client
|
||||
.post(&url)
|
||||
.header(reqwest::header::AUTHORIZATION, access_token)
|
||||
.send()
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
|
||||
match response.status() {
|
||||
reqwest::StatusCode::OK => {
|
||||
println!("Success!");
|
||||
@@ -38,7 +39,6 @@ impl Upload {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn retrieve_url(&self, song: &models::song::Song) -> String {
|
||||
// let mut url: String = String::new();
|
||||
let api = &self.api;
|
||||
@@ -52,4 +52,4 @@ impl Upload {
|
||||
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user