Last active
October 25, 2020 03:22
-
-
Save jayhuang75/022fde439d663456245ea07bc12504b8 to your computer and use it in GitHub Desktop.
SMS Alert Covid 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| impl Producer for Sms { | |
| async fn run(&self, covid: &CovidReport) -> Result<(), Box<dyn Error>> { | |
| // in the feature will loop the phone number in some of the use case | |
| let to = env::var("TWILIO_TO_NUM").unwrap().as_str().to_string(); | |
| let client = Client::new(&*TWILIO_ACCOUNT_ID, &*TWILIO_AUTH_TOKEN); | |
| let body = &format!( | |
| "Today Ontario has {} new cases, number of death {}. ", | |
| covid.report[0].numtoday, covid.report[0].numdeathstoday | |
| ); | |
| let send_msg = OutboundMessage::new(&*TWILIO_PHONE_NUM, &to, body); | |
| client.send_message(send_msg).await?; | |
| Ok(()) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment