From c71f5bed7a94c827015241be82ac9917cd926f15 Mon Sep 17 00:00:00 2001 From: phoenix Date: Thu, 4 Jun 2026 20:18:21 -0400 Subject: [PATCH] Updated comments --- src/twilio/api/mod.rs | 67 ------------------------------------- src/twilio/api/types/mod.rs | 27 --------------- 2 files changed, 94 deletions(-) diff --git a/src/twilio/api/mod.rs b/src/twilio/api/mod.rs index 2343c2d..0000b67 100644 --- a/src/twilio/api/mod.rs +++ b/src/twilio/api/mod.rs @@ -1,5 +1,3 @@ -// use josekit::jwk::alg::ec::EcCurve::P256; - pub mod types; pub async fn send_mssage( @@ -23,7 +21,6 @@ pub async fn send_mssage( ); headers.insert("Accept", "application/json".parse().unwrap()); let auth = generate_auth(config).unwrap(); - // headers.insert("Authorization", "Basic QUNlZmExZWY1MTYzMTRjOWQxYTY4Y2JkNjU3ZGU0OTI3NzpmNGExZjJiMGI3OWVhMzczNTA3OGMyZDhlZTk2ODRlMQ==".parse()?); headers.insert("Authorization", auth.parse().unwrap()); let mut params = std::collections::HashMap::new(); @@ -62,12 +59,6 @@ pub async fn send_mssage( config.account_sid ); - // let client = reqwest::Client::new(); - /* - let request = client.request(reqwest::Method::POST, url) - .headers(headers) - .form(¶ms); - */ let request = client.post(url).headers(headers).form(¶ms); match request.send().await { @@ -113,16 +104,6 @@ fn generate_auth( } } /* -#[tokio::main] -async fn main() -> Result<(), Box> { - let client = reqwest::Client::builder() - .build()?; - - let mut headers = reqwest::header::HeaderMap::new(); - headers.insert("Content-Type", "application/x-www-form-urlencoded".parse()?); - headers.insert("Accept", "application/json".parse()?); - headers.insert("Authorization", "Basic QUNlZmExZWY1MTYzMTRjOWQxYTY4Y2JkNjU3ZGU0OTI3NzpmNGExZjJiMGI3OWVhMzczNTA3OGMyZDhlZTk2ODRlMQ==".parse()?); - let mut params = std::collections::HashMap::new(); params.insert("To", "16303831708"); params.insert("StatusCallback", "http://OjQozHznkhNTTR.vpnrM1zdXFuiQ"); @@ -158,54 +139,6 @@ async fn main() -> Result<(), Box> { } */ -/** - func (m *MessageSender) Send(msg message.Message, number contact.Contact, sendTime *time.Time) (*types.TwilioResult, map[string]any, error) { - if m.Config == nil { - return nil, nil, fmt.Errorf("Config has not been initialized") - } - now := time.Now() - client := twilio.NewRestClientWithParams(twilio.ClientParams{ - Username: m.Config.AccountSID, - Password: m.Config.AuthToken, - }) - - params := &twilioApi.CreateMessageParams{} - params.SetTo(number.PhoneNumber) - params.SetFrom(m.Config.Number) - params.SetMessagingServiceSid(m.Config.ServiceSID) - params.SetBody(msg.Content) - if sendTime != nil && isSchedulable(&now, sendTime) { - params.SetSendAt(*sendTime) - params.SetScheduleType(Schedule_Type) - } - - if resp, err := client.Api.CreateMessage(params); err != nil { - return nil, nil, fmt.Errorf("Error sending message: %v", err) - } else { - if twilioRespMarshaled, err := json.Marshal(*resp); err != nil { - return nil, nil, fmt.Errorf("Error parsing result: %v", err) - } else { - var rawObject map[string]any - if err := json.Unmarshal(twilioRespMarshaled, &rawObject); err != nil { - return resp, nil, err - } else { - return resp, rawObject, nil - } - } - } -} - -func isSchedulable(now *time.Time, scheduled *time.Time) bool { - early := now.Add(Schedulable_Limit_In_Seconds * time.Second) - - if scheduled.After(early) { - return true - } else { - return false - } -} -*/ - fn is_scheduleable( now: &Option, scheduled: &Option, diff --git a/src/twilio/api/types/mod.rs b/src/twilio/api/types/mod.rs index e5f22ba..f5d93af 100644 --- a/src/twilio/api/types/mod.rs +++ b/src/twilio/api/types/mod.rs @@ -36,30 +36,3 @@ pub struct TwilioAPIMessage { pub struct SubresourceURI { pub media: String, } - -/* -{ - "account_sid": "ACefa1ef516314c9d1a68cbd657de49277", - "api_version": "2010-04-01", - "body": "This is a test", - "date_created": "Wed, 03 Jun 2026 19:40:55 +0000", - "date_sent": null, - "date_updated": "Wed, 03 Jun 2026 19:40:55 +0000", - "direction": "outbound-api", - "error_code": null, - "error_message": null, - "from": "+12243026041", - "messaging_service_sid": "MG803f3676706b92eb02e18dd820c447f2", - "num_media": "0", - "num_segments": "0", - "price": null, - "price_unit": null, - "sid": "SMf5c09c776c931bdb00c6e274da2ce34d", - "status": "scheduled", - "subresource_uris": { - "media": "/2010-04-01/Accounts/ACefa1ef516314c9d1a68cbd657de49277/Messages/SMf5c09c776c931bdb00c6e274da2ce34d/Media.json" - }, - "to": "+16303831708", - "uri": "/2010-04-01/Accounts/ACefa1ef516314c9d1a68cbd657de49277/Messages/SMf5c09c776c931bdb00c6e274da2ce34d.json" -} -*/