twilio_agnostic/twiml/
sms.rs1use super::{format_xml_string, Action, Method};
2use std::default::Default;
3
4pub struct Sms {
5 pub txt: String,
6 pub action: Option<String>,
7 pub method: Method,
8 pub from: Option<String>,
9 pub to: Option<String>,
10 pub status_callback: Option<String>,
11}
12
13impl Action for Sms {
14 fn as_twiml(&self) -> String {
15 let mut attrs = Vec::new();
16 let method_str = match self.method {
17 Method::Get => "GET",
18 Method::Post => "POST",
19 };
20 attrs.push(("method", method_str));
21 if let Some(ref a) = self.action {
22 attrs.push(("action", a));
23 }
24 if let Some(ref f) = self.from {
25 attrs.push(("from", f));
26 }
27 if let Some(ref t) = self.to {
28 attrs.push(("to", t));
29 }
30 if let Some(ref c) = self.status_callback {
31 attrs.push(("statusCallback", c));
32 }
33 format_xml_string("Sms", &attrs, self.txt.as_ref())
34 }
35}
36
37impl Default for Sms {
38 fn default() -> Sms {
39 Sms {
40 txt: "".to_string(),
41 action: None,
42 method: Method::Post,
43 from: None,
44 to: None,
45 status_callback: None,
46 }
47 }
48}