Skip to content

Instantly share code, notes, and snippets.

@jayhuang75
Last active October 25, 2020 03:22
Show Gist options
  • Select an option

  • Save jayhuang75/022fde439d663456245ea07bc12504b8 to your computer and use it in GitHub Desktop.

Select an option

Save jayhuang75/022fde439d663456245ea07bc12504b8 to your computer and use it in GitHub Desktop.
SMS Alert Covid 2
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