Code formatting
This commit is contained in:
+7
-5
@@ -61,11 +61,11 @@ impl Service {
|
||||
};
|
||||
let sch_msg = super::scheduler::ScheduledMessage {
|
||||
app: self.app.clone(),
|
||||
token: self.token.clone()
|
||||
token: self.token.clone(),
|
||||
};
|
||||
let mer_req = super::mer::MessageEventResponse {
|
||||
app: self.app.clone(),
|
||||
token: self.token.clone()
|
||||
token: self.token.clone(),
|
||||
};
|
||||
|
||||
let events = events.unwrap_or_default();
|
||||
@@ -98,13 +98,13 @@ impl Service {
|
||||
|
||||
let param = swoosh::twilio::types::Parameters {
|
||||
schedule: true,
|
||||
schedule_at: scheduled_message.scheduled
|
||||
schedule_at: scheduled_message.scheduled,
|
||||
};
|
||||
|
||||
let twilio_config = &self.app.twilio_config;
|
||||
|
||||
|
||||
match swoosh::twilio::api::send_message(&message, contact, ¶m, twilio_config).await {
|
||||
match swoosh::twilio::api::send_message(&message, contact, ¶m, twilio_config).await
|
||||
{
|
||||
Ok(resp) => {
|
||||
// MER response
|
||||
let result = swoosh::twilio::api::response_to_json(resp).await;
|
||||
@@ -133,6 +133,7 @@ impl Service {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
todo!(
|
||||
r#"
|
||||
Need to finish this
|
||||
@@ -153,6 +154,7 @@ impl Service {
|
||||
9. Add to scheduler
|
||||
"#
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
fn is_schedulable(
|
||||
|
||||
@@ -27,7 +27,9 @@ impl Event {
|
||||
},
|
||||
Err(err) => Err(std::io::Error::other(err)),
|
||||
},
|
||||
_ => Err(std::io::Error::other("Error getting token")),
|
||||
_ => Err(std::io::Error::other(
|
||||
"Error getting Scheduled Message Event",
|
||||
)),
|
||||
},
|
||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||
}
|
||||
|
||||
+8
-2
@@ -10,7 +10,7 @@ impl MessageEventResponse {
|
||||
) -> Result<textsender_models::message::event::MessageEventResponse, std::io::Error> {
|
||||
let client = reqwest::Client::new();
|
||||
let endpoint = String::from("api/v1/schedule/message/event/response/record");
|
||||
let api_url = format!("{}/{endpoint}", self.app.auth_url);
|
||||
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
||||
|
||||
println!("Url: {api_url:?}");
|
||||
|
||||
@@ -36,7 +36,13 @@ impl MessageEventResponse {
|
||||
|
||||
let (key, header) = super::auth_header(&self.token.access_token);
|
||||
|
||||
match client.post(api_url).json(&payload).header(key, header).send().await {
|
||||
match client
|
||||
.post(api_url)
|
||||
.json(&payload)
|
||||
.header(key, header)
|
||||
.send()
|
||||
.await
|
||||
{
|
||||
Ok(response) => match response.status() {
|
||||
reqwest::StatusCode::CREATED | reqwest::StatusCode::OK => {
|
||||
println!("Response: {response:?}");
|
||||
|
||||
@@ -9,7 +9,7 @@ impl ScheduledMessage {
|
||||
scheduled_message_id: &uuid::Uuid,
|
||||
) -> Result<textsender_models::message::scheduling::ScheduledMessage, std::io::Error> {
|
||||
let client = reqwest::Client::new();
|
||||
let endpoint = format!("api/v1/scheduled/message?id={scheduled_message_id}");
|
||||
let endpoint = format!("api/v1/schedule/message?id={scheduled_message_id}");
|
||||
let api_url = format!("{}/{endpoint}", self.app.api_url);
|
||||
|
||||
println!("Url: {api_url:?}");
|
||||
@@ -25,7 +25,7 @@ impl ScheduledMessage {
|
||||
},
|
||||
Err(err) => Err(std::io::Error::other(err)),
|
||||
},
|
||||
_ => Err(std::io::Error::other("Error getting token")),
|
||||
_ => Err(std::io::Error::other("Error getting Scheduled Message")),
|
||||
},
|
||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||
}
|
||||
@@ -41,12 +41,12 @@ async fn parse_response(
|
||||
if lrs.is_empty() {
|
||||
Err(std::io::Error::other("Error response is empty"))
|
||||
} else {
|
||||
let ll: textsender_models::message::scheduling::ScheduledMessage =
|
||||
match serde_json::from_value(lrs[0].clone()) {
|
||||
Ok(lr) => lr,
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err.to_string()));
|
||||
}
|
||||
let ll: textsender_models::message::scheduling::ScheduledMessage =
|
||||
match serde_json::from_value(lrs[0].clone()) {
|
||||
Ok(lr) => lr,
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err.to_string()));
|
||||
}
|
||||
};
|
||||
|
||||
Ok(ll)
|
||||
|
||||
Reference in New Issue
Block a user