Code formatting
catapult PR / Check (pull_request) Successful in 2m28s
catapult PR / Rustfmt (pull_request) Successful in 34s
catapult PR / Clippy (pull_request) Failing after 40s

This commit is contained in:
2026-06-24 14:40:03 -04:00
parent 5ae1715fb4
commit 75116d649e
2 changed files with 38 additions and 45 deletions
-1
View File
@@ -27,4 +27,3 @@ impl Service {
);
}
}
+38 -44
View File
@@ -1,6 +1,5 @@
pub mod core;
pub mod auth {
pub struct Auth {
pub app: crate::app::App,
@@ -22,28 +21,27 @@ pub mod auth {
println!("Payload: {payload:?}");
match client.post(api_url).json(&payload).send().await {
Ok(response) => {
match response.status() {
reqwest::StatusCode::OK => {
println!("Response: {response:?}");
match response.text().await {
Ok(val) => {
match parse_token_response(&val).await {
Ok(login_result) => Ok(login_result),
Err(err) => Err(err)
}
}
Err(err) => Err(std::io::Error::other(err)),
}
Ok(response) => match response.status() {
reqwest::StatusCode::OK => {
println!("Response: {response:?}");
match response.text().await {
Ok(val) => match parse_token_response(&val).await {
Ok(login_result) => Ok(login_result),
Err(err) => Err(err),
},
Err(err) => Err(std::io::Error::other(err)),
}
_ => Err(std::io::Error::other("Error getting token")),
}
}
_ => Err(std::io::Error::other("Error getting token")),
},
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
pub async fn get_refresh_token(&self, login_result: &textsender_models::token::Login) -> Result<textsender_models::token::Login, std::io::Error> {
pub async fn get_refresh_token(
&self,
login_result: &textsender_models::token::Login,
) -> Result<textsender_models::token::Login, std::io::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v1/token/refresh");
let api_url = format!("{}/{endpoint}", self.app.auth_url);
@@ -55,29 +53,27 @@ pub mod auth {
});
match client.post(api_url).json(&payload).send().await {
Ok(response) => {
match response.status() {
reqwest::StatusCode::OK => {
println!("Response: {response:?}");
match response.text().await {
Ok(val) => {
match parse_token_response(&val).await {
Ok(login_result) => Ok(login_result),
Err(err) => Err(err)
}
}
Err(err) => Err(std::io::Error::other(err)),
}
Ok(response) => match response.status() {
reqwest::StatusCode::OK => {
println!("Response: {response:?}");
match response.text().await {
Ok(val) => match parse_token_response(&val).await {
Ok(login_result) => Ok(login_result),
Err(err) => Err(err),
},
Err(err) => Err(std::io::Error::other(err)),
}
_ => Err(std::io::Error::other("Error getting token")),
}
}
_ => Err(std::io::Error::other("Error getting token")),
},
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
}
async fn parse_token_response(response: &String) -> Result<textsender_models::token::LoginResult, std::io::Error> {
async fn parse_token_response(
response: &String,
) -> Result<textsender_models::token::LoginResult, std::io::Error> {
match serde_json::from_str::<serde_json::Value>(response) {
Ok(j) => {
println!("Good");
@@ -89,22 +85,20 @@ pub mod auth {
match j.get("data") {
Some(serde_json::Value::Array(lrs)) => {
if lrs.is_empty() {
Err(std::io::Error::other(
"Error response is empty",
))
Err(std::io::Error::other("Error response is empty"))
} else {
let lr = lrs[0].clone();
let ll: textsender_models::token::LoginResult = match serde_json::from_value(lr) { Ok(lr) => lr,
Err(err) => {
return Err(std::io::Error::other(err.to_string()));
}
};
let ll: textsender_models::token::LoginResult =
match serde_json::from_value(lr) {
Ok(lr) => lr,
Err(err) => {
return Err(std::io::Error::other(err.to_string()));
}
};
Ok(ll)
}
}
_ => Err(std::io::Error::other(
"Error parsing response",
)),
_ => Err(std::io::Error::other("Error parsing response")),
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),