1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
//! # sparkpost //! //! Rust bindings for sparkpost email api v1 //! ## WARNING! //! ### Work in Progress, Expect breaking changes //! ### Example //! ```rust //! extern crate sparkpost; //! //! use sparkpost::transmission::{Transmission, Message, EmailAddress, TransmissionResponse}; //! //! let tm = Transmission::new("api_key".to_string(), "https://api.eu.sparkpost.com/api/v1".to_string()); //! let mut email: Message = Message::new( //! EmailAddress::with_name("marketing@example.sink.sparkpostmail.com", "Example Company") //! ); //! //! email.add_recipient("name@domain.com".into()) //! .subject("My Awesome email 😎") //! .html("<h1>html body of the email</h1>") //! .text("text body of the email"); //! //! let result = tm.send(&email); //! //! match result { //! Ok(res) => { //! println!("{:?}", &res); //! match res { //! TransmissionResponse::ApiResponse(api_res) => { //! // assert_eq!(1, api_res.total_accepted_recipients); //! // assert_eq!(0, api_res.total_rejected_recipients); //! } //! TransmissionResponse::ApiError(errors) => { //! println!("res: \n {:#?}", &errors); //! } //! } //! } //! Err(error) => { //! println!("error \n {:#?}", error); //! } //!} //! //! ``` extern crate reqwest; extern crate serde_json; #[macro_use] extern crate serde_derive; extern crate serde; #[cfg(test)] extern crate base64; #[cfg(test)] #[macro_use] extern crate pretty_assertions; #[cfg(test)] extern crate dotenv; pub mod transmission;