Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b411d2370f
|
||
|
|
4550702c7a
|
+15
-3
@@ -37,8 +37,6 @@ pub async fn send_message(
|
||||
|
||||
let params = init_params(contact, msg, config, param);
|
||||
|
||||
println!("Params: {params:?}");
|
||||
|
||||
let url = format!(
|
||||
"https://api.twilio.com/2010-04-01/Accounts/{}/Messages.json",
|
||||
config.account_sid
|
||||
@@ -76,7 +74,13 @@ fn init_params(
|
||||
params.insert(String::from("SmartEncoded"), String::from("true"));
|
||||
params.insert(String::from("ShortenUrls"), String::from("true"));
|
||||
let date = match param.schedule_at {
|
||||
Some(date_value) => date_value.to_string(),
|
||||
Some(date_value) => match convert_time_to_iso(date_value) {
|
||||
Ok(converted) => converted,
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
String::new()
|
||||
}
|
||||
},
|
||||
None => String::new(),
|
||||
};
|
||||
let scheduled_at = match param.schedule_at {
|
||||
@@ -117,6 +121,14 @@ fn init_params(
|
||||
params
|
||||
}
|
||||
|
||||
fn convert_time_to_iso(time: time::OffsetDateTime) -> Result<String, time::error::Format> {
|
||||
use time::format_description::well_known::Iso8601;
|
||||
match time.format(&Iso8601::DEFAULT) {
|
||||
Ok(converted) => Ok(converted),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_auth(
|
||||
config: &textsender_models::config::auxiliary::TwilioConfig,
|
||||
) -> Result<String, base64_ng::EncodeError> {
|
||||
|
||||
Reference in New Issue
Block a user