Compare commits

..
Author SHA1 Message Date
phoenix d36483e6f8 Fix (#14)
swoosh Build / Test Suite (push) Successful in 1m6s
swoosh Build / Rustfmt (push) Successful in 33s
swoosh Build / Check (push) Successful in 1m46s
Release Tagging / release (push) Successful in 44s
swoosh Build / Clippy (push) Successful in 1m39s
swoosh Build / build (push) Successful in 1m39s
swoosh pr / Check (pull_request) Has been cancelled
swoosh pr / Rustfmt (pull_request) Has been cancelled
swoosh pr / Clippy (pull_request) Has been cancelled
Release Tagging / release (pull_request) Successful in 42s
Reviewed-on: #14
2026-07-04 20:59:05 -04:00
phoenix 768b2b6d08 tsk-11: New code to send message (#13)
Release Tagging / release (push) Successful in 46s
swoosh Build / Rustfmt (push) Successful in 32s
swoosh Build / Test Suite (push) Successful in 1m34s
swoosh Build / Check (push) Successful in 1m52s
swoosh Build / Clippy (push) Successful in 1m28s
swoosh Build / build (push) Successful in 1m15s
Closes #11

Reviewed-on: #13
2026-07-03 00:45:59 -04:00
4 changed files with 23 additions and 21 deletions
Generated
+3 -3
View File
@@ -81,9 +81,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]] [[package]]
name = "base64-ng" name = "base64-ng"
version = "1.2.3" version = "1.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "735259e24200bce69feb75fcb2f79f36129e54c3f3139da15880520988cd840c" checksum = "2b87dbd7e45c4885ad3432a2d125ddb155c5ee87046ab23bad043dfe84fedfa2"
[[package]] [[package]]
name = "bitflags" name = "bitflags"
@@ -2067,7 +2067,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]] [[package]]
name = "swoosh" name = "swoosh"
version = "0.5.0" version = "0.5.1"
dependencies = [ dependencies = [
"base64-ng", "base64-ng",
"reqwest", "reqwest",
+2 -2
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "swoosh" name = "swoosh"
version = "0.5.0" version = "0.5.1"
edition = "2024" edition = "2024"
rust-version = "1.96" rust-version = "1.96"
description = "Library to send text messages" description = "Library to send text messages"
@@ -10,7 +10,7 @@ serde = { version = "1.0.228", features = ["derive"] }
serde_json = { version = "1.0.150" } serde_json = { version = "1.0.150" }
reqwest = { version = "0.13.4", features = ["form", "json", "blocking", "multipart", "stream"] } reqwest = { version = "0.13.4", features = ["form", "json", "blocking", "multipart", "stream"] }
time = { version = "0.3.49", features = ["formatting", "macros", "parsing", "serde"] } 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"] } textsender_models = { git = "ssh://git@git.kundeng.us/phoenix/textsender_models.git", tag = "v0.5.0", features = ["config", "contact", "message"] }
[dev-dependencies] [dev-dependencies]
+17 -15
View File
@@ -13,13 +13,13 @@ impl SendMsg {
auth_token: &str, auth_token: &str,
phone_number: &str, phone_number: &str,
service_sid: &str, service_sid: &str,
auth_sid: &str, account_sid: &str,
) { ) {
self.config = VendorConfig { self.config = VendorConfig {
auth_token: auth_token.to_string(), auth_token: auth_token.to_string(),
phone_number: phone_number.to_string(), phone_number: phone_number.to_string(),
service_sid: service_sid.to_string(), service_sid: service_sid.to_string(),
auth_sid: auth_sid.to_string(), account_sid: account_sid.to_string(),
} }
} }
@@ -40,15 +40,15 @@ impl SendMsg {
param: &crate::twilio::types::Parameters, param: &crate::twilio::types::Parameters,
) -> Result<reqwest::Response, std::io::Error> { ) -> Result<reqwest::Response, std::io::Error> {
if self.recipient.phone_number.is_empty() { if self.recipient.phone_number.is_empty() {
return Err(std::io::Error::other("Recipient not provided")); Err(std::io::Error::other("Recipient not provided"))
} else if self.message.content.is_empty() { } else if self.message.content.is_empty() {
return Err(std::io::Error::other("Message not provided")); Err(std::io::Error::other("Message not provided"))
} else if self.config.phone_number.is_empty() } else if self.config.phone_number.is_empty()
|| self.config.service_sid.is_empty() || self.config.service_sid.is_empty()
|| self.config.auth_token.is_empty() || self.config.auth_token.is_empty()
|| self.config.auth_sid.is_empty() || self.config.account_sid.is_empty()
{ {
return Err(std::io::Error::other("Config not populated")); Err(std::io::Error::other("Config not populated"))
} else { } else {
let client = match reqwest::Client::builder().build() { let client = match reqwest::Client::builder().build() {
Ok(client) => client, Ok(client) => client,
@@ -57,14 +57,16 @@ impl SendMsg {
} }
}; };
let url = twilio::api::twilio_url(&self.config.auth_sid); let url = twilio::api::twilio_url(&self.config.account_sid);
let headers = let headers = match twilio::api::init_headers(
match twilio::api::init_headers(&self.config.auth_sid, &self.config.auth_token) { &self.config.account_sid,
Ok(headers) => headers, &self.config.auth_token,
Err(err) => { ) {
return Err(std::io::Error::other(err)); Ok(headers) => headers,
} Err(err) => {
}; return Err(std::io::Error::other(err));
}
};
let params = twilio::api::initial_params( let params = twilio::api::initial_params(
&self.recipient.phone_number, &self.recipient.phone_number,
&self.message.content, &self.message.content,
@@ -91,7 +93,7 @@ pub struct VendorConfig {
pub auth_token: String, pub auth_token: String,
pub phone_number: String, pub phone_number: String,
pub service_sid: String, pub service_sid: String,
pub auth_sid: String, pub account_sid: String,
} }
#[derive(Default, Debug)] #[derive(Default, Debug)]
+1 -1
View File
@@ -87,7 +87,7 @@ pub fn init_headers(
}; };
headers.insert( headers.insert(
"Authorization", "Authorization",
match auth.parse() { match format!("Basic {auth}").parse() {
Ok(auth) => auth, Ok(auth) => auth,
Err(err) => { Err(err) => {
return Err(std::io::Error::other(err)); return Err(std::io::Error::other(err));