Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d36483e6f8 |
Generated
+3
-3
@@ -81,9 +81,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "base64-ng"
|
||||
version = "1.2.3"
|
||||
version = "1.3.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "735259e24200bce69feb75fcb2f79f36129e54c3f3139da15880520988cd840c"
|
||||
checksum = "2b87dbd7e45c4885ad3432a2d125ddb155c5ee87046ab23bad043dfe84fedfa2"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
@@ -2067,7 +2067,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||
|
||||
[[package]]
|
||||
name = "swoosh"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
dependencies = [
|
||||
"base64-ng",
|
||||
"reqwest",
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "swoosh"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
edition = "2024"
|
||||
rust-version = "1.96"
|
||||
description = "Library to send text messages"
|
||||
@@ -10,7 +10,7 @@ serde = { version = "1.0.228", features = ["derive"] }
|
||||
serde_json = { version = "1.0.150" }
|
||||
reqwest = { version = "0.13.4", features = ["form", "json", "blocking", "multipart", "stream"] }
|
||||
time = { version = "0.3.49", features = ["formatting", "macros", "parsing", "serde"] }
|
||||
base64-ng = { version = "1.0.8" }
|
||||
base64-ng = { version = "1.3.5" }
|
||||
textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.5.0", features = ["config", "contact", "message"] }
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
+14
-12
@@ -13,13 +13,13 @@ impl SendMsg {
|
||||
auth_token: &str,
|
||||
phone_number: &str,
|
||||
service_sid: &str,
|
||||
auth_sid: &str,
|
||||
account_sid: &str,
|
||||
) {
|
||||
self.config = VendorConfig {
|
||||
auth_token: auth_token.to_string(),
|
||||
phone_number: phone_number.to_string(),
|
||||
service_sid: service_sid.to_string(),
|
||||
auth_sid: auth_sid.to_string(),
|
||||
account_sid: account_sid.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ impl SendMsg {
|
||||
} else if self.config.phone_number.is_empty()
|
||||
|| self.config.service_sid.is_empty()
|
||||
|| self.config.auth_token.is_empty()
|
||||
|| self.config.auth_sid.is_empty()
|
||||
|| self.config.account_sid.is_empty()
|
||||
{
|
||||
Err(std::io::Error::other("Config not populated"))
|
||||
} else {
|
||||
@@ -57,14 +57,16 @@ impl SendMsg {
|
||||
}
|
||||
};
|
||||
|
||||
let url = twilio::api::twilio_url(&self.config.auth_sid);
|
||||
let headers =
|
||||
match twilio::api::init_headers(&self.config.auth_sid, &self.config.auth_token) {
|
||||
Ok(headers) => headers,
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err));
|
||||
}
|
||||
};
|
||||
let url = twilio::api::twilio_url(&self.config.account_sid);
|
||||
let headers = match twilio::api::init_headers(
|
||||
&self.config.account_sid,
|
||||
&self.config.auth_token,
|
||||
) {
|
||||
Ok(headers) => headers,
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err));
|
||||
}
|
||||
};
|
||||
let params = twilio::api::initial_params(
|
||||
&self.recipient.phone_number,
|
||||
&self.message.content,
|
||||
@@ -91,7 +93,7 @@ pub struct VendorConfig {
|
||||
pub auth_token: String,
|
||||
pub phone_number: String,
|
||||
pub service_sid: String,
|
||||
pub auth_sid: String,
|
||||
pub account_sid: String,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug)]
|
||||
|
||||
@@ -87,7 +87,7 @@ pub fn init_headers(
|
||||
};
|
||||
headers.insert(
|
||||
"Authorization",
|
||||
match auth.parse() {
|
||||
match format!("Basic {auth}").parse() {
|
||||
Ok(auth) => auth,
|
||||
Err(err) => {
|
||||
return Err(std::io::Error::other(err));
|
||||
|
||||
Reference in New Issue
Block a user