mbp2 0.3.1

A common-utility library for federated projects.
Documentation
use futures_util::SinkExt;

#[tokio::test]
pub async fn testMailClient() {
   use crate::mail::transmission::*;
   use crate::mail::SparkClient;
   use std::fs::File;
   use std::io::Read;
   
   dotenvy::from_filename("config.env").unwrap();
   
   let token = dotenvy::var("MBP2_SPARK_API_TOKEN").expect("MBP2_SPARK_API_TOKEN not set");
   let client = SparkClient::new(token);

   let recipient = Recipient::new(EmailAddress{ email: "kell@mbp2.blog".into(), name: "Kell".into() }, None);

   let mut html = String::new();
   let mut file = File::open("test.html").expect("could not open file");
   file.read_to_string(&mut html).expect("could not read file");
   
   let content = Message::new(Some(EmailAddress{ email: "noreply@updates-api.mbp2.blog".into(), name: "No-reply".into() }))
      .addHtml(html)
      .addSubject("Test email".into())
      .addHeader("X-Custom-Test-Header".into(), "HeaderValueAwesomeSauce".into());
   
   let transmission = Transmission::default()
      .setContent(content)
      .setCampaignId("test-campaign".into())
      .setDescription("A test campaign".into())
      .setMetadata(Metadata{ userType: "test".into() })
      .addRecipient(recipient)
      .addSubstitutionData(hash_map!{ "name".to_string() => "Kell".to_string() });
   
   let response = client.transmit(transmission).await.unwrap();
}